View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.email.config;
8   
9   import org.mule.api.MuleException;
10  import org.mule.transport.email.Pop3Connector;
11  import org.mule.transport.email.Pop3sConnector;
12  
13  import javax.mail.Flags;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
18  import static org.junit.Assert.assertNotNull;
19  import static org.junit.Assert.assertTrue;
20  
21  public class Pop3NamespaceHandlerTestCase extends AbstractEmailNamespaceHandlerTestCase
22  {
23      
24      @Override
25      protected String getConfigResources()
26      {
27          return "pop3-namespace-config.xml";
28      }
29  
30      @Test
31      public void testConfig() throws Exception
32      {
33          Pop3Connector c = (Pop3Connector)muleContext.getRegistry().lookupConnector("pop3Connector");
34          assertNotNull(c);
35  
36          assertTrue(c.isBackupEnabled());
37          assertEquals("newBackup", c.getBackupFolder());
38          assertEquals(1234, c.getCheckFrequency());
39          assertEquals("newMailbox", c.getMailboxFolder());
40          assertEquals(false, c.isDeleteReadMessages());
41  
42          // authenticator?
43  
44          assertTrue(c.isConnected());
45          assertTrue(c.isStarted());
46  
47          assertEquals(Flags.Flag.SEEN, c.getDefaultProcessMessageAction());
48      }
49  
50      @Test
51      public void testSecureConfig() throws Exception
52      {
53          Pop3sConnector c = (Pop3sConnector)muleContext.getRegistry().lookupConnector("pop3sConnector");
54          assertNotNull(c);
55  
56          assertTrue(c.isBackupEnabled());
57          assertEquals("newBackup", c.getBackupFolder());
58          assertEquals(1234, c.getCheckFrequency());
59          assertEquals("newMailbox", c.getMailboxFolder());
60          assertEquals(false, c.isDeleteReadMessages());
61  
62          // authenticator?
63  
64          //The full path gets resolved, we're just checkng that the property got set
65          assertTrue(c.getClientKeyStore().endsWith("/empty.jks"));
66          assertEquals("password", c.getClientKeyStorePassword());
67          //The full path gets resolved, we're just checkng that the property got set
68          assertTrue(c.getTrustStore().endsWith("/empty.jks"));
69          assertEquals("password", c.getTrustStorePassword());
70  
71          assertTrue(c.isConnected());
72          assertTrue(c.isStarted());
73          
74          assertEquals(Flags.Flag.ANSWERED, c.getDefaultProcessMessageAction());
75      }
76  
77      @Test
78      public void testEndpoint() throws MuleException
79      {
80          testInboundEndpoint("global1", Pop3Connector.POP3);
81          testInboundEndpoint("global2", Pop3Connector.POP3);
82          testInboundEndpoint("global1s", Pop3sConnector.POP3S);
83          testInboundEndpoint("global2s", Pop3sConnector.POP3S);
84      }
85  
86  }