How to create a Mock-server "FTPS" for unit test in Java File Transfer

I have CreateFTPConnection class that creates a connection to FTPS. Using this connection, the files are transferred. Here is the code class TransferFile

public class TransferFile { private CreateFTPConnection ftpConnection; private FTPSClient client; public TransferFile(CreateFTPConnection ftpConnection) { this.ftpConnection = ftpConnection; this.client = ftpConnection.getClient(); } public void transfer(Message<?> 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(); } } } } 

I need to write jUnit Testcase for this class. To do this I need to create a connection FTPS Mock Server and use this link to check 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 this, but what I'm getting to an FTP or SFTP, FTPS instead. Please help me.

+4
source share
1 answer

You can find this useful MockFTPServer

The problem is that these mock servers do not implement TLS part of what I see. You may need to do a little work to allow connections over TLS.

You should be able to seek and find here some articles on how to handle the certificates (or, in some cases, get them) for your testing.

Here is another article that passes steps to create FTP-server base dough.

With the exception of full FTP-server (the Apache http of w / mod_ftp add) seems nothing useful to do does not work.

+6
source

All Articles