This unitils module makes it easy to use a fake FTP server during your tests.
A fake FTP server will be started before your unit test. You can configure it to point to a location on your filesystem.
Your application can do normal ftp calls to this location
Cleanup is done for you by the module.
@TestFtpServer
public FakeFtpServer server;
@Test
public void testDoSomething() throws IOException {
//do some FTP calls.
myApp.doSomeFtpThings();
//verification
server.getFileSystem().exists("file.txt");
}
So what happens behind this code:
Before each test the module checks if their is a field with @TestFtpServer. If this is true, than a fake FTP server is initialized with the properties out of the unitils.properties.
The username and the password are the credentials that are used to logon.
The filesystem of the fake server is imitated with the files in the basefolder.
After each test the server is stopped.
This runs best if the test and the SUT(System Under Test) is on the same JVM.
The test will fail if it is on a different machine.
Unitils FTP module
This unitils module makes it easy to use a fake FTP server during your tests.
A fake FTP server will be started before your unit test. You can configure it to point to a location on your filesystem.
Your application can do normal ftp calls to this location
Cleanup is done for you by the module.
This module makes use of MockFtpServer: http://mockftpserver.sourceforge.net/
FTP Module load artifact (maven)
FTP Module project configuration
Example
So what happens behind this code:
Before each test the module checks if their is a field with @TestFtpServer. If this is true, than a fake FTP server is initialized with the properties out of the unitils.properties.
The username and the password are the credentials that are used to logon.
The filesystem of the fake server is imitated with the files in the basefolder.
After each test the server is stopped.
This runs best if the test and the SUT(System Under Test) is on the same JVM.
The test will fail if it is on a different machine.
Last edit: Willemijn Wouters 2013-10-16