View Javadoc

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