blob: 49b5b17adb06cd3b54d6a11540fb37db288eb1e5 [file] [log] [blame]
chrismair00dc7bd2014-05-11 21:21:28 +00001/*
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 */
16package org.mockftpserver.fake
17
18import org.mockftpserver.fake.FakeFtpServer
19import org.mockftpserver.fake.UserAccount
20import org.mockftpserver.fake.filesystem.DirectoryEntry
21import org.mockftpserver.fake.filesystem.FileEntry
22import org.mockftpserver.fake.filesystem.UnixFakeFileSystem
23
24/**
25 * Run the FakeFtpServer with a minimal configuration for interactive testing and exploration.
26 *
27 * @version $Revision$ - $Date$
28 *
29 * @author Chris Mair
30 */
31class RunFakeFtpServer {
32
33 static final ANONYMOUS = 'anonymous'
34 static final HOME_DIR = '/home'
35
36 static main(args) {
37 def fileSystem = new UnixFakeFileSystem()
38 fileSystem.createParentDirectoriesAutomatically = true
39 fileSystem.add(new DirectoryEntry(HOME_DIR))
40 fileSystem.add(new DirectoryEntry("$HOME_DIR/subdir"))
41 fileSystem.add(new DirectoryEntry("$HOME_DIR/subdir2"))
42 fileSystem.add(new FileEntry(path: "$HOME_DIR/abc.txt", contents: '1234567890'))
43 fileSystem.add(new FileEntry(path: "$HOME_DIR/def.txt", contents: '1234567890'))
44 fileSystem.add(new FileEntry(path: "$HOME_DIR/subdir/xyz.txt", contents: '1234567890'))
45
46 def userAccount = new UserAccount(username: ANONYMOUS, passwordRequiredForLogin: false, homeDirectory: HOME_DIR)
47
48 def ftpServer = new FakeFtpServer()
49 ftpServer.fileSystem = fileSystem
50 ftpServer.userAccounts = [userAccount]
51 ftpServer.run()
52 }
53}