1b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair/*
2b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * Copyright 2008 the original author or authors.
3b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *
4b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * Licensed under the Apache License, Version 2.0 (the "License");
5b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * you may not use this file except in compliance with the License.
6b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * You may obtain a copy of the License at
7b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *
8b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *      http://www.apache.org/licenses/LICENSE-2.0
9b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair *
10b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * Unless required by applicable law or agreed to in writing, software
11b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * distributed under the License is distributed on an "AS IS" BASIS,
12b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * See the License for the specific language governing permissions and
14b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * limitations under the License.
15b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair */
16b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairpackage org.mockftpserver.fake.example;
17b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
18b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.fake.FakeFtpServer;
19b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.fake.UserAccount;
20b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.fake.filesystem.DirectoryEntry;
21b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.fake.filesystem.FileEntry;
22b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.fake.filesystem.FileSystem;
23b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.fake.filesystem.WindowsFakeFileSystem;
24b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.test.AbstractTest;
25b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairimport org.mockftpserver.test.IntegrationTest;
26b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
27b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair/**
28b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * Example code illustrating how to programmatically configure a FakeFtpServer with a (simulated) Windows
29b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair * filesystem.
30b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair */
31b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismairpublic class SimpleWindowsFakeFtpServerTest extends AbstractTest implements IntegrationTest {
32b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
33b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    public void testConfigureAndStart() throws Exception {
34b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        FakeFtpServer fakeFtpServer = new FakeFtpServer();
35b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        fakeFtpServer.setServerControlPort(9981);
36b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        fakeFtpServer.addUserAccount(new UserAccount("user", "password", "c:\\data"));
37b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
38b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        FileSystem fileSystem = new WindowsFakeFileSystem();
39b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        fileSystem.add(new DirectoryEntry("c:\\data"));
40b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        fileSystem.add(new FileEntry("c:\\data\\file1.txt", "abcdef 1234567890"));
41b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        fileSystem.add(new FileEntry("c:\\data\\run.exe"));
42b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        fakeFtpServer.setFileSystem(fileSystem);
43b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
44b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        fakeFtpServer.start();
45b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
46b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair        fakeFtpServer.stop();
47b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair    }
48b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair
49b2f4a2dfc590c250e42b21eb40d9539ac135b495chrismair}