The MockFtpServer project provides a mock/dummy FTP server implementations that can be very useful for testing of FTP client code.
MockFtpServer version 2.0 includes a new "fake" implementation of an FTP server. It provides a high-level abstraction for an FTP Server and is suitable for most testing and simulation scenarios. You define a virtual filesystem (internal, in-memory) containing an arbitrary set of files and directories. These files and directories can (optionally) have associated access permissions. You also configure a set of one or more user accounts that control which users can login to the FTP server, and their home (default) directories. The user account is also used when assigning file and directory ownership for new files.
FakeFtpServer processes FTP client requests and responds with reply codes and reply messages consistent with its configured file system and user accounts, including file and directory permissions, if they have been configured.
Here is an example showing configuration and starting of an FakeFtpServer with a single user account and a (simulated) Windows file system, defining a directory containing two files. If you wish, you can define a Unix file system, instead.
// Create the server and add a user account
FakeFtpServer fakeFtpServer = new FakeFtpServer();
fakeFtpServer.addUserAccount(new UserAccount("user", "password", "c:
data"));
// Set up the Windows filesystem
FileSystem fileSystem = new WindowsFakeFileSystem();
fileSystem.add(new DirectoryEntry("c:
data"));
fileSystem.add(new FileEntry("c:\\data
file1.txt", "abcdef 1234567890"));
fileSystem.add(new FileEntry("c:\\data
run.exe"));
fakeFtpServer.setFileSystem(fileSystem);
fakeFtpServer.start();
-
MockFtpServer 2.0 (final) (3 messages)
- Posted by: Chris Mair
- Posted on: January 06 2009 06:52 EST
Threaded Messages (3)
- Congrats by Dave Sims on January 06 2009 11:00 EST
- Re: MockFtpServer 2.0 (final) by brad mcevoy on January 06 2009 17:04 EST
- MockFtpServer - not quite a real server by Chris Mair on January 09 2009 08:54 EST
-
Congrats[ Go to top ]
- Posted by: Dave Sims
- Posted on: January 06 2009 11:00 EST
- in response to Chris Mair
Congratulations on the final 2.0 release. It's nice to see your FTP server supporting much of the FTP standard. Like the SQL standard, the FTP standard isn't exactly followed the same way by all FTP server implementations. It'd be great to have a kind of "standard reference" against which to check spec-compliant behavior, although, of course, that never replaces testing against the real FTP servers that will be used in production. :) Cheers, David Flux - http://www.fluxcorp.com - Java Job Scheduler. File Transfer. Workflow. -
Re: MockFtpServer 2.0 (final)[ Go to top ]
- Posted by: brad mcevoy
- Posted on: January 06 2009 17:04 EST
- in response to Chris Mair
That looks awesome. What limitations prevent its use as a real FTP server? -
MockFtpServer - not quite a real server[ Go to top ]
- Posted by: Chris Mair
- Posted on: January 09 2009 08:54 EST
- in response to brad mcevoy
Thanks. The FakeFtpServer is not really intended as a real FTP server. I tried to capture the essential behavior, but because of the focus of this project on simulation, and the lack of full compliance with all of the intricacies of the FTP spec, there are probably shortcomings in the behavior that you would expect from a real server. There are other open source FTP Server projects, including http://incubator.apache.org/projects/ftpserver.html, if you do need a real server.