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 public class ImapNamespaceHandlerTestCase extends AbstractEmailNamespaceHandlerTestCase
19 {
20 protected String getConfigResources()
21 {
22 return "imap-namespace-config.xml";
23 }
24
25 public void testConfig() throws Exception
26 {
27 ImapConnector c = (ImapConnector)muleContext.getRegistry().lookupConnector("imapConnector");
28 assertNotNull(c);
29
30 assertTrue(c.isBackupEnabled());
31 assertEquals("newBackup", c.getBackupFolder());
32 assertEquals(1234, c.getCheckFrequency());
33 assertEquals("newMailbox", c.getMailboxFolder());
34 assertEquals(false, c.isDeleteReadMessages());
35
36
37
38 assertTrue(c.isConnected());
39 assertTrue(c.isStarted());
40
41 assertEquals(Flags.Flag.SEEN, c.getDefaultProcessMessageAction());
42 }
43
44 public void testSecureConfig() throws Exception
45 {
46 ImapsConnector c = (ImapsConnector)muleContext.getRegistry().lookupConnector("imapsConnector");
47 assertNotNull(c);
48
49 assertFalse(c.isBackupEnabled());
50 assertEquals("newBackup", c.getBackupFolder());
51 assertEquals(1234, c.getCheckFrequency());
52 assertEquals("newMailbox", c.getMailboxFolder());
53 assertEquals(false, c.isDeleteReadMessages());
54
55
56
57
58 assertTrue(c.getClientKeyStore().endsWith("/empty.jks"));
59 assertEquals("password", c.getClientKeyStorePassword());
60
61 assertTrue(c.getTrustStore().endsWith("/empty.jks"));
62 assertEquals("password", c.getTrustStorePassword());
63
64 assertTrue(c.isConnected());
65 assertTrue(c.isStarted());
66
67 assertNull(c.getDefaultProcessMessageAction());
68 }
69
70 public void testEndpoint() throws MuleException
71 {
72 testInboundEndpoint("global1", ImapConnector.IMAP);
73 testInboundEndpoint("global2", ImapConnector.IMAP);
74 testInboundEndpoint("global1s", ImapsConnector.IMAPS);
75 testInboundEndpoint("global2s", ImapsConnector.IMAPS);
76 }
77
78 }