1c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair/*
2c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Copyright 2008 the original author or authors.
3c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair *
4c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Licensed under the Apache License, Version 2.0 (the "License");
5c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * you may not use this file except in compliance with the License.
6c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * You may obtain a copy of the License at
7c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair *
8c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair *      http://www.apache.org/licenses/LICENSE-2.0
9c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair *
10c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Unless required by applicable law or agreed to in writing, software
11c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * distributed under the License is distributed on an "AS IS" BASIS,
12c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * See the License for the specific language governing permissions and
14c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * limitations under the License.
15c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */
16c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairpackage org.mockftpserver.fake
17c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair
18c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairimport org.mockftpserver.fake.FakeFtpServer
19c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairimport org.mockftpserver.fake.UserAccount
20c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairimport org.mockftpserver.fake.filesystem.DirectoryEntry
21c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairimport org.mockftpserver.fake.filesystem.FileEntry
22c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairimport org.mockftpserver.fake.filesystem.UnixFakeFileSystem
23c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair
24c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair/**
25c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * Run the FakeFtpServer with a minimal configuration for interactive testing and exploration.
26c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair *
27c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @version $Revision$ - $Date$
28c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair *
29c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair * @author Chris Mair
30c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair */
31c1de24f1bfa6699e54b069e300af5e4246b34a34chrismairclass RunFakeFtpServer {
32c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair
33c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair    static final ANONYMOUS = 'anonymous'
34c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair    static final HOME_DIR = '/home'
35c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair
36c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair    static main(args) {
37c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        def fileSystem = new UnixFakeFileSystem()
38c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        fileSystem.createParentDirectoriesAutomatically = true
39c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        fileSystem.add(new DirectoryEntry(HOME_DIR))
40c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        fileSystem.add(new DirectoryEntry("$HOME_DIR/subdir"))
41c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        fileSystem.add(new FileEntry(path: "$HOME_DIR/abc.txt", contents: '1234567890'))
42c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        fileSystem.add(new FileEntry(path: "$HOME_DIR/def.txt", contents: '1234567890'))
43c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair
44c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        def userAccount = new UserAccount(username: ANONYMOUS, passwordRequiredForLogin: false, homeDirectory: HOME_DIR)
45c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair
46c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        def ftpServer = new FakeFtpServer()
47c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        ftpServer.fileSystem = fileSystem
48c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        ftpServer.userAccounts = [userAccount]
49c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair        ftpServer.run()
50c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair    }
51c1de24f1bfa6699e54b069e300af5e4246b34a34chrismair}