View Javadoc

1   /*
2    * $Id: Pop3NamespaceHandlerTestCase.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.Pop3Connector;
14  import org.mule.transport.email.Pop3sConnector;
15  
16  import javax.mail.Flags;
17  
18  /**
19   * TODO
20   */
21  public class Pop3NamespaceHandlerTestCase extends AbstractEmailNamespaceHandlerTestCase
22  {
23      protected String getConfigResources()
24      {
25          return "pop3-namespace-config.xml";
26      }
27  
28      public void testConfig() throws Exception
29      {
30          Pop3Connector c = (Pop3Connector)muleContext.getRegistry().lookupConnector("pop3Connector");
31          assertNotNull(c);
32  
33          assertTrue(c.isBackupEnabled());
34          assertEquals("newBackup", c.getBackupFolder());
35          assertEquals(1234, c.getCheckFrequency());
36          assertEquals("newMailbox", c.getMailboxFolder());
37          assertEquals(false, c.isDeleteReadMessages());
38  
39          // authenticator?
40  
41          assertTrue(c.isConnected());
42          assertTrue(c.isStarted());
43  
44          assertEquals(Flags.Flag.SEEN, c.getDefaultProcessMessageAction());
45      }
46  
47      public void testSecureConfig() throws Exception
48      {
49          Pop3sConnector c = (Pop3sConnector)muleContext.getRegistry().lookupConnector("pop3sConnector");
50          assertNotNull(c);
51  
52          assertTrue(c.isBackupEnabled());
53          assertEquals("newBackup", c.getBackupFolder());
54          assertEquals(1234, c.getCheckFrequency());
55          assertEquals("newMailbox", c.getMailboxFolder());
56          assertEquals(false, c.isDeleteReadMessages());
57  
58          // authenticator?
59  
60          //The full path gets resolved, we're just checkng that the property got set
61          assertTrue(c.getClientKeyStore().endsWith("/empty.jks"));
62          assertEquals("password", c.getClientKeyStorePassword());
63          //The full path gets resolved, we're just checkng that the property got set
64          assertTrue(c.getTrustStore().endsWith("/empty.jks"));
65          assertEquals("password", c.getTrustStorePassword());
66  
67          assertTrue(c.isConnected());
68          assertTrue(c.isStarted());
69          
70          assertEquals(Flags.Flag.ANSWERED, c.getDefaultProcessMessageAction());
71      }
72  
73      public void testEndpoint() throws MuleException
74      {
75          testInboundEndpoint("global1", Pop3Connector.POP3);
76          testInboundEndpoint("global2", Pop3Connector.POP3);
77          testInboundEndpoint("global1s", Pop3sConnector.POP3S);
78          testInboundEndpoint("global2s", Pop3sConnector.POP3S);
79      }
80  
81  }