title: How to create a "FTPS" Mock Server to unit test File Transfer in Java
body: <p>I have a CreateFTPConnection class which create a FTPS connection. Using this connection, files are transferred. Here is the code of TransferFile class</p>
  
  <pre><code>public class TransferFile
  {
     private CreateFTPConnection ftpConnection;
     private FTPSClient client;
  
  public TransferFile(CreateFTPConnection ftpConnection) {
      this.ftpConnection = ftpConnection;
      this.client = ftpConnection.getClient();
  }
  
  public void transfer(Message&lt;?&gt; msg)
  {
      InputStream inputStream = null;
      try
      {
          if(!client.isConnected()){
              ftpConnection.init();
              client = ftpConnection.getClient();
          }
          File file = (File) msg.getPayload();
          inputStream = new FileInputStream(file);
          client.storeFile(file.getName(), inputStream);
          client.sendNoOp();
      } catch (Exception e) {
          try
          {
              client.disconnect();
          }
          catch (IOException e1) {
              e1.printStackTrace();
          }
      }
      finally
      {
          try {
              inputStream.close();
          } 
          catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  }
  </code></pre>
  
  <p>I have to write jUnit Testcase for this class. For this, I have to create a FTPS Mock Server connection and have to use that connection to test the File Transfer. So can anyone plz give me any idea of how to make FTPS Mock Server and do the test case. I googled on this, but what I get is on FTP or SFTP, not FTPS. Please help me.</p>