1
2
3
4
5
6
7
8
9
10 package org.mule.transport.email.config;
11
12 import org.mule.api.MuleException;
13 import org.mule.transport.email.ImapConnector;
14 import org.mule.transport.email.ImapsConnector;
15
16 import javax.mail.Flags;
17
18 import org.junit.Test;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertFalse;
22 import static org.junit.Assert.assertNotNull;
23 import static org.junit.Assert.assertNull;
24 import static org.junit.Assert.assertTrue;
25
26 public class ImapNamespaceHandlerTestCase extends AbstractEmailNamespaceHandlerTestCase
27 {
28
29 @Override
30 protected String getConfigResources()
31 {
32 return "imap-namespace-config.xml";
33 }
34
35 @Test
36 public void testConfig() throws Exception
37 {
38 ImapConnector c = (ImapConnector)muleContext.getRegistry().lookupConnector("imapConnector");
39 assertNotNull(c);
40
41 assertTrue(c.isBackupEnabled());
42 assertEquals("newBackup", c.getBackupFolder());
43 assertEquals(1234, c.getCheckFrequency());
44 assertEquals("newMailbox", c.getMailboxFolder());
45 assertEquals(false, c.isDeleteReadMessages());
46
47
48
49 assertTrue(c.isConnected());
50 assertTrue(c.isStarted());
51
52 assertEquals(Flags.Flag.SEEN, c.getDefaultProcessMessageAction());
53 }
54
55 @Test
56 public void testSecureConfig() throws Exception
57 {
58 ImapsConnector c = (ImapsConnector)muleContext.getRegistry().lookupConnector("imapsConnector");
59 assertNotNull(c);
60
61 assertFalse(c.isBackupEnabled());
62 assertEquals("newBackup", c.getBackupFolder());
63 assertEquals(1234, c.getCheckFrequency());
64 assertEquals("newMailbox", c.getMailboxFolder());
65 assertEquals(false, c.isDeleteReadMessages());
66
67
68
69
70 assertTrue(c.getClientKeyStore().endsWith("/empty.jks"));
71 assertEquals("password", c.getClientKeyStorePassword());
72
73 assertTrue(c.getTrustStore().endsWith("/empty.jks"));
74 assertEquals("password", c.getTrustStorePassword());
75
76 assertTrue(c.isConnected());
77 assertTrue(c.isStarted());
78
79 assertNull(c.getDefaultProcessMessageAction());
80 }
81
82 @Test
83 public void testEndpoint() throws MuleException
84 {
85 testInboundEndpoint("global1", ImapConnector.IMAP);
86 testInboundEndpoint("global2", ImapConnector.IMAP);
87 testInboundEndpoint("global1s", ImapsConnector.IMAPS);
88 testInboundEndpoint("global2s", ImapsConnector.IMAPS);
89 }
90
91 }