1   /*
2    * $Id: ImapNamespaceHandlerTestCase.java 10489 2008-01-23 17:53:38Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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  public class ImapNamespaceHandlerTestCase extends AbstractEmailNamespaceHandlerTestCase
17  {
18      protected String getConfigResources()
19      {
20          return "imap-namespace-config.xml";
21      }
22  
23      public void testConfig() throws Exception
24      {
25          ImapConnector c = (ImapConnector)muleContext.getRegistry().lookupConnector("imapConnector");
26          assertNotNull(c);
27  
28          assertTrue(c.isBackupEnabled());
29          assertEquals("newBackup", c.getBackupFolder());
30          assertEquals(1234, c.getCheckFrequency());
31          assertEquals("newMailbox", c.getMailboxFolder());
32          assertEquals(false, c.isDeleteReadMessages());
33  
34          // authenticator?
35  
36          assertTrue(c.isConnected());
37          assertTrue(c.isStarted());
38      }
39  
40      public void testSecureConfig() throws Exception
41      {
42          ImapsConnector c = (ImapsConnector)muleContext.getRegistry().lookupConnector("imapsConnector");
43          assertNotNull(c);
44  
45          assertFalse(c.isBackupEnabled());
46          assertEquals("newBackup", c.getBackupFolder());
47          assertEquals(1234, c.getCheckFrequency());
48          assertEquals("newMailbox", c.getMailboxFolder());
49          assertEquals(false, c.isDeleteReadMessages());
50  
51          // authenticator?
52  
53          //The full path gets resolved, we're just checkng that the property got set
54          assertTrue(c.getClientKeyStore().endsWith("/greenmail-truststore"));
55          assertEquals("password", c.getClientKeyStorePassword());
56          //The full path gets resolved, we're just checkng that the property got set
57          assertTrue(c.getTrustStore().endsWith("/greenmail-truststore"));
58          assertEquals("password", c.getTrustStorePassword());
59  
60          assertTrue(c.isConnected());
61          assertTrue(c.isStarted());
62      }
63  
64      public void testEndpoint() throws MuleException
65      {
66          testEndpoint("global1", ImapConnector.IMAP);
67          testEndpoint("global2", ImapConnector.IMAP);
68          testEndpoint("global1s", ImapsConnector.IMAPS);
69          testEndpoint("global2s", ImapsConnector.IMAPS);
70      }
71  
72  }