View Javadoc

1   /*
2    * $Id: ImapNamespaceHandlerTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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          // authenticator?
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          // authenticator?
56  
57          //The full path gets resolved, we're just checkng that the property got set
58          assertTrue(c.getClientKeyStore().endsWith("/empty.jks"));
59          assertEquals("password", c.getClientKeyStorePassword());
60          //The full path gets resolved, we're just checkng that the property got set
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  }