Lines Matching full:fakeftpserver
2 FakeFtpServer Getting Started
5 FakeFtpServer - Getting Started
8 <<FakeFtpServer>> is a "fake" implementation of an FTP server. It provides a high-level abstraction for
15 <<FakeFtpServer>> processes FTP client requests and responds with reply codes and reply messages
19 See the {{{./fakeftpserver-features.html}FakeFtpServer Features and Limitations}} page for more information on
22 In general the steps for setting up and starting the <<<FakeFtpServer>>> are:
24 * Create a new <<<FakeFtpServer>>> instance, and optionally set the server control port (use a value of 0
27 * Create and configure a <<<FileSystem>>>, and attach to the <<<FakeFtpServer>>> instance.
29 * Create and configure one or more <<<UserAccount>>> objects and attach to the <<<FakeFtpServer>>> instance.
33 Here is an example showing configuration and starting of an <<FakeFtpServer>> with a single user
37 FakeFtpServer fakeFtpServer = new FakeFtpServer();
38 fakeFtpServer.addUserAccount(new UserAccount("user", "password", "c:\\data"));
44 fakeFtpServer.setFileSystem(fileSystem);
46 fakeFtpServer.start();
51 <<<FakeFtpServer.setServerControlPort(int serverControlPort)>>> method to use a different port
56 <<FakeFtpServer>> can be fully configured programmatically or within the
58 The {{{#Example}Example Test Using FakeFtpServer}} below illustrates programmatic configuration of
59 <<<FakeFtpServer>>>. Alternatively, the {{{#Spring}Configuration}} section later on illustrates how to use
60 the <Spring Framework> to configure a <<<FakeFtpServer>>> instance.
62 * {Example} Test Using FakeFtpServer
66 test for it that programmatically configures and uses <<FakeFtpServer>>.
112 ** JUnit Test For FTP Client Code Using FakeFtpServer
116 <<FakeFtpServer>>.
122 import org.mockftpserver.fake.FakeFtpServer;
136 private FakeFtpServer fakeFtpServer;
155 fakeFtpServer = new FakeFtpServer();
156 fakeFtpServer.setServerControlPort(0); // use any free port
160 fakeFtpServer.setFileSystem(fileSystem);
163 fakeFtpServer.addUserAccount(userAccount);
165 fakeFtpServer.start();
166 int port = fakeFtpServer.getServerControlPort();
175 fakeFtpServer.stop();
182 * The <<<FakeFtpServer>>> instance is created and started in the <<<setUp()>>> method and
185 * The server control port is set to 0 using <<<fakeFtpServer.setServerControlPort(PORT)>>>.
189 * The <<<UnixFakeFileSystem>>> filesystem is configured and attached to the <<<FakeFtpServer>>> instance
197 attached to the <<<FakeFtpServer>>> instance in the <<<setUp()>>> method. That configured user ("user")
198 is the only one that will be able to sucessfully log in to the <<<FakeFtpServer>>>.
204 You can easily configure a <<<FakeFtpServer>>> instance in the
210 The following example shows a <Spring> configuration file for a simple <<<FakeFtpServer>>> instance.
220 <bean id="fakeFtpServer" class="org.mockftpserver.fake.FakeFtpServer">
257 * The <<<FakeFtpServer>>> instance has a single user account for username "joe", password "password"
266 configured <<FakeFtpServer>>.
269 ApplicationContext context = new ClassPathXmlApplicationContext("fakeftpserver-beans.xml");
270 FakeFtpServer = (FakeFtpServer) context.getBean("FakeFtpServer");
271 FakeFtpServer.start();
278 The following example shows a <Spring> configuration file for a <<<FakeFtpServer>>> instance that
279 also configures file and directory permissions. This will enable the <<<FakeFtpServer>>> to reply
291 <bean id="fakeFtpServer" class="org.mockftpserver.fake.FakeFtpServer">
344 * The <<<FakeFtpServer>>> instance is configured with a <<<WindowsFakeFileSystem>>> and a "c:\" root
358 <<FakeFtpServer>> is intentionally designed to keep the lower-level details of FTP server implementation
368 * You want to add support for a command that is not provided out of the box by <<FakeFtpServer>>
380 <CommandHandler> for a new command (i.e., one that is not supported out of the box by <<FakeFtpServer>>).
386 FakeFtpServer ftpServer = new FakeFtpServer()
407 FakeFtpServer ftpServer = new FakeFtpServer()
440 <<<FakeFtpServer.setReplyTextBaseName(String)>>> method.
445 Note that <<FakeFtpServer>> uses {{{http://www.slf4j.org/}SLF4J}} for logging. If you want to