View Javadoc

1   /*
2    * $Id: FtpNamespaceHandlerTestCase.java 22414 2011-07-14 13:24:46Z 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.ftp;
11  
12  import org.mule.api.endpoint.EndpointException;
13  import org.mule.endpoint.MuleEndpointURI;
14  import org.mule.tck.junit4.FunctionalTestCase;
15  import org.mule.transport.file.DummyFilenameParser;
16  import org.mule.transport.file.FilenameParser;
17  
18  import org.apache.commons.pool.impl.GenericObjectPool;
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertEquals;
22  import static org.junit.Assert.assertNotNull;
23  import static org.junit.Assert.assertTrue;
24  
25  /**
26   * Load a mule config and verify that the parameters are set as expected
27   */
28  public class FtpNamespaceHandlerTestCase extends FunctionalTestCase
29  {
30  
31      @Override
32      protected String getConfigResources()
33      {
34          return "ftp-namespace-config.xml";
35      }
36  
37      @Test
38      public void testConfig() throws Exception
39      {
40          FtpConnector c = (FtpConnector)muleContext.getRegistry().lookupConnector("ftpConnector");
41          assertNotNull(c);
42  
43          assertEquals("abc", c.getOutputPattern());
44          assertEquals(1234, c.getPollingFrequency());
45          assertEquals(false, c.isBinary());
46          assertEquals(false, c.isPassive());
47          assertEquals(false, c.isValidateConnections());
48          assertEquals(FTPConnectorTestCase.TestFtpConnectionFactory.class.getName(), c.getConnectionFactoryClass());
49  
50          FilenameParser parser = c.getFilenameParser();
51          assertTrue(parser.getClass().getName(), c.getFilenameParser() instanceof DummyFilenameParser);
52  
53          assertTrue(c.isConnected());
54          assertTrue(c.isStarted());
55      }
56      
57      @Test
58      public void testReceiverFtpConnector() throws EndpointException 
59      {
60          FtpConnector c = (FtpConnector)muleContext.getRegistry().lookupConnector("receiverFtpConnector");
61          assertNotNull(c);
62          
63          MuleEndpointURI uri = new MuleEndpointURI("http://localhost", null);
64          GenericObjectPool objectPool = (GenericObjectPool) c.getFtpPool(uri);
65          assertEquals(GenericObjectPool.WHEN_EXHAUSTED_FAIL, objectPool.getWhenExhaustedAction());
66      }
67  }