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.ftp.server;
8   
9   import org.mule.tck.junit4.rule.DynamicPort;
10  
11  import org.apache.commons.net.ftp.FTPClient;
12  import org.junit.After;
13  import org.junit.Before;
14  import org.junit.Rule;
15  import org.junit.Test;
16  
17  /**
18   * Tests for the embedded ftp server startup, log in, and shutdown.
19   */
20  public class ServerTest
21  {
22  
23      private Server ftpServer = null;
24  
25      @Rule
26      public DynamicPort dynamicPort = new DynamicPort("port1");
27  
28      @Before
29      public void setUpServer() throws Exception
30      {
31          ftpServer = new Server(dynamicPort.getNumber());
32      }
33  
34      @After
35      public void tearDown()
36      {
37          ftpServer.stop();
38      }
39  
40      /**
41       * Sanity test that the embedded ftp server is working. Useful as a first step if
42       * the ftp transport tests are failing.
43       *
44       * @throws Exception
45       */
46      @Test
47      public void testServerLogin() throws Exception
48      {
49          FTPClient ftpClient = new FTPClient();
50          ftpClient.connect("localhost", dynamicPort.getNumber());
51          ftpClient.login("admin", "admin");
52      }
53  }