View Javadoc

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