View Javadoc

1   /*
2    * $Id: SftpSendReceiveLargeFileFunctionalTestCase.java 22475 2011-07-20 14:30:04Z justin.calleja $
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  
11  package org.mule.transport.sftp;
12  
13  import java.util.Arrays;
14  import java.util.Collection;
15  
16  import org.junit.Test;
17  import org.junit.runners.Parameterized.Parameters;
18  
19  /**
20   * Test sending and receiving a very large message.
21   * <p/>
22   * This test will probably fail due to the standard timeout. According to
23   * http://www.mulesource.org/display/MULE2USER/Functional+Testing the only way to
24   * change the timeout is "add -Dmule.test.timeoutSecs=XX either to the mvn command
25   * you use to run Mule or to the JUnit test runner in your IDE." Tested with
26   * '-Dmule.test.timeoutSecs=300'
27   */
28  public class SftpSendReceiveLargeFileFunctionalTestCase extends AbstractSftpTestCase
29  {
30      private static final long TIMEOUT = 600000;
31  
32      // Size of the generated stream - 200 Mb
33      final static int SEND_SIZE = 1024 * 1024 * 200;
34  
35      public SftpSendReceiveLargeFileFunctionalTestCase(ConfigVariant variant, String configResources)
36      {
37          super(variant, configResources);
38  
39          // Increase the timeout of the test to 300 s
40          logger.info("Timeout was set to: " + System.getProperty(TEST_TIMEOUT_SYSTEM_PROPERTY, "-1"));
41          System.setProperty(TEST_TIMEOUT_SYSTEM_PROPERTY, "600000");
42          logger.info("Timeout is now set to: " + System.getProperty(TEST_TIMEOUT_SYSTEM_PROPERTY, "-1"));
43      }
44  
45      @Parameters
46      public static Collection<Object[]> parameters()
47      {        
48          return Arrays.asList(new Object[][]{
49              {ConfigVariant.SERVICE, "mule-send-receive-large-file-test-config-service.xml"},
50              {ConfigVariant.FLOW, "mule-send-receive-large-file-test-config-flow.xml"}});
51      }
52  
53      @Override
54      protected void doSetUp() throws Exception
55      {
56          super.doSetUp();
57  
58          initEndpointDirectory("inboundEndpoint");
59      }
60  
61      /**
62       * Test sending and receiving a large file.
63       */
64      @Test
65      public void testSendAndReceiveLargeFile() throws Exception
66      {
67          executeBaseTest("inboundEndpoint", "vm://test.upload", "bigfile.txt", SEND_SIZE, "receiving", TIMEOUT);
68      }
69  }