1
2
3
4
5
6
7 package org.mule.transport.email.config;
8
9 import org.mule.api.MuleException;
10 import org.mule.transport.email.SmtpConnector;
11 import org.mule.transport.email.SmtpsConnector;
12
13 import java.util.Properties;
14
15 import org.junit.Test;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertTrue;
20
21 public class SmtpNamespaceHandlerTestCase extends AbstractEmailNamespaceHandlerTestCase
22 {
23
24 @Override
25 protected String getConfigResources()
26 {
27 return "smtp-namespace-config.xml";
28 }
29
30 @Test
31 public void testConfig() throws Exception
32 {
33 SmtpConnector c = (SmtpConnector)muleContext.getRegistry().lookupConnector("smtpConnector");
34 assertNotNull(c);
35
36 assertEquals("abc@example.com", c.getBccAddresses());
37 assertEquals("bcd@example.com", c.getCcAddresses());
38 assertEquals("foo/bar", c.getContentType());
39 Properties headers = c.getCustomHeaders();
40 assertEquals(2, headers.size());
41 assertEquals("bar", headers.getProperty("foo"));
42 assertEquals("boz", headers.getProperty("baz"));
43 assertEquals("cde@example.com", c.getFromAddress());
44 assertEquals("def@example.com", c.getReplyToAddresses());
45 assertEquals("subject", c.getSubject());
46
47
48
49 assertTrue(c.isConnected());
50 assertTrue(c.isStarted());
51 }
52
53 @Test
54 public void testSecureConfig() throws Exception
55 {
56 SmtpsConnector c = (SmtpsConnector)muleContext.getRegistry().lookupConnector("smtpsConnector");
57 assertNotNull(c);
58
59 assertEquals("abc@example.com", c.getBccAddresses());
60 assertEquals("bcd@example.com", c.getCcAddresses());
61 assertEquals("foo/bar", c.getContentType());
62 Properties headers = c.getCustomHeaders();
63 assertEquals(2, headers.size());
64 assertEquals("bar", headers.getProperty("foo"));
65 assertEquals("boz", headers.getProperty("baz"));
66 assertEquals("cde@example.com", c.getFromAddress());
67 assertEquals("def@example.com", c.getReplyToAddresses());
68 assertEquals("subject", c.getSubject());
69
70
71
72
73 assertTrue(c.getClientKeyStore().endsWith("/empty.jks"));
74 assertEquals("password", c.getClientKeyStorePassword());
75
76 assertTrue(c.getTrustStore().endsWith("/empty.jks"));
77 assertEquals("password", c.getTrustStorePassword());
78
79 assertTrue(c.isConnected());
80 assertTrue(c.isStarted());
81 }
82
83 @Test
84 public void testEndpoint() throws MuleException
85 {
86 testOutboundEndpoint("global1", SmtpConnector.SMTP);
87 testOutboundEndpoint("global2", SmtpConnector.SMTP);
88 testOutboundEndpoint("global1s", SmtpsConnector.SMTPS);
89 testOutboundEndpoint("global2s", SmtpsConnector.SMTPS);
90 }
91 }