View Javadoc

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