Skip to content

Instantly share code, notes, and snippets.

@helpermethod
Created August 7, 2017 14:02
Show Gist options
  • Save helpermethod/91782438a29f7d8a5e825db62116d5b0 to your computer and use it in GitHub Desktop.
Save helpermethod/91782438a29f7d8a5e825db62116d5b0 to your computer and use it in GitHub Desktop.
A groovy kind of MockFtpServer
@Grab('org.mockftpserver:MockFtpServer:2.7.1')

import org.mockftpserver.fake.FakeFtpServer
import org.mockftpserver.fake.UserAccount
import org.mockftpserver.fake.filesystem.DirectoryEntry
import org.mockftpserver.fake.filesystem.UnixFakeFileSystem

new FakeFtpServer().with {
    serverControlPort = 9981
    systemName = 'UNIX'

    addUserAccount new UserAccount(username: 'admin', password: 'admin', homeDirectory: '/')

    fileSystem = new UnixFakeFileSystem().with {
        createParentDirectoriesAutomatically = true

        entries = [new DirectoryEntry('/in'), new DirectoryEntry('/out')]

        it
    }

    it
}.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment