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.sftp;
8   
9   import static org.junit.Assert.assertEquals;
10  import static org.junit.Assert.assertNotNull;
11  import static org.junit.Assert.assertTrue;
12  
13  import org.mule.api.endpoint.ImmutableEndpoint;
14  import org.mule.tck.junit4.FunctionalTestCase;
15  
16  import org.junit.Test;
17  
18  public class SftpNamespaceHandlerTestCase extends FunctionalTestCase
19  {
20  
21      @Override
22      protected String getConfigResources()
23      {
24          return "sftp-namespace-config.xml";
25      }
26  
27      @Test
28      public void testSftpConnectorConfig() throws Exception
29      {
30          SftpConnector c = (SftpConnector) muleContext.getRegistry().lookupConnector("sftpConnector");
31          assertNotNull(c);
32          assertTrue(c.isConnected());
33          assertTrue(c.isStarted());
34          assertTrue(c.isAutoDelete());
35          assertEquals(c.getPollingFrequency(), 15000);
36          assertEquals(1234, c.getFileAge());
37          assertEquals("uploading", c.getTempDirOutbound());
38          assertEquals(42, c.getMaxConnectionPoolSize());
39      }
40  
41      @Test
42      public void testSftpEndpointConfig() throws Exception
43      {
44          ImmutableEndpoint inboundEndpoint = (ImmutableEndpoint) muleContext.getRegistry().lookupObject("inboundEndpoint");
45          SftpConnector connector = (SftpConnector) inboundEndpoint.getConnector();
46          Object[] receivers = connector.getReceivers().values().toArray();
47          SftpMessageReceiver receiver = (SftpMessageReceiver) receivers[0];
48          assertEquals(10000, receiver.getFrequency());
49      }
50  }