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