1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.transport.mail;
18
19 import org.custommonkey.xmlunit.XMLAssert;
20 import org.jvnet.mock_javamail.Mailbox;
21 import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
22 import org.springframework.ws.client.core.WebServiceTemplate;
23 import org.springframework.xml.transform.StringResult;
24 import org.springframework.xml.transform.StringSource;
25
26 public class MailIntegrationTest extends AbstractDependencyInjectionSpringContextTests {
27
28 private WebServiceTemplate webServiceTemplate;
29
30 protected String[] getConfigLocations() {
31 return new String[]{"classpath:org/springframework/ws/transport/mail/mail-applicationContext.xml"};
32 }
33
34 protected void onTearDown() throws Exception {
35 Mailbox.clearAll();
36 }
37
38 public void setWebServiceTemplate(WebServiceTemplate webServiceTemplate) {
39 this.webServiceTemplate = webServiceTemplate;
40 }
41
42 public void testMailTransport() throws Exception {
43 String content = "<root xmlns='http://springframework.org/spring-ws'><child/></root>";
44 StringResult result = new StringResult();
45 webServiceTemplate.sendSourceAndReceiveToResult(new StringSource(content), result);
46 applicationContext.close();
47 assertEquals("Server mail message not deleted", 0, Mailbox.get("[email protected]").size());
48 assertEquals("No client mail message received", 1, Mailbox.get("[email protected]").size());
49 XMLAssert.assertXMLEqual("Invalid content received", content, result.toString());
50
51 }
52
53 }