Java Code Examples for org.mockftpserver.fake.filesystem.UnixFakeFileSystem

The following examples show how to use org.mockftpserver.fake.filesystem.UnixFakeFileSystem. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: davos   Source File: FakeFTPServerFactory.java    License: MIT License 6 votes vote down vote up
public static FakeFtpServer setup() {

        server = new FakeFtpServer();
        server.addUserAccount(new UserAccount("user", "password", "/tmp"));
        server.setServerControlPort(0);

        FileSystem fileSystem = new UnixFakeFileSystem();
        fileSystem.add(new DirectoryEntry("/tmp"));
        fileSystem.add(new FileEntry("/tmp/file1.txt", "hello world"));
        fileSystem.add(new FileEntry("/tmp/file2.txt", "hello world"));
        fileSystem.add(new FileEntry("/tmp/file3.txt", "hello world"));

        server.setFileSystem(fileSystem);
        server.start();

        return server;
    }
 
Example 2
@BeforeClass
 protected void startftp() throws Exception
 {
    fakeFtpServer = new FakeFtpServer();
    fakeFtpServer.setServerControlPort(8089);  // use any free port

    FileSystem fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new FileEntry("/data/s1-level-1-calibration.xsd", "<schema/>"));
    fileSystem.add(new FileEntry("/data/s1-object-types.xsd", "<schema/>"));
    fileSystem.add(new FileEntry("/data/GOM_EXT_2PNPDE20070312_232536_000000542056_00202_26308_1271.N1", "GOMOS DATA!"));
    fileSystem.add(new FileEntry ("/data/S1A_IW_SLC__1SDV_20141003T054235_20141003T054304_002661_002F66_D5C8.SAFE/manifest.safe", "<XFDU/>"));
    fileSystem.add(new FileEntry ("/data/S1A_EW_GRDH_1SSH_20120101T022934_20120101T022945_001770_000001_AF02.SAFE/manifest.safe", "<XFDU/>"));
    fileSystem.add(new FileEntry("/data/manifest.safe", "<XFDU/>"));
    
    fakeFtpServer.setFileSystem(fileSystem);

    UserAccount userAccount = new UserAccount("user", "password", "/");
    fakeFtpServer.addUserAccount(userAccount);
    
    fakeFtpServer.start();
}
 
Example 3
Source Project: cs-actions   Source File: PutTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry("/data"));

    fakeFtpServer = new FakeFtpServer();
    fakeFtpServer.setFileSystem(fileSystem);
    fakeFtpServer.setServerControlPort(0);
    fakeFtpServer.addUserAccount(new UserAccount("user", "password", "/data"));
    fakeFtpServer.start();

    putOperation = new Put();
    ftpService = new FTPService();
    localFile = temporaryFolder.newFile("localfile.txt");

}
 
Example 4
Source Project: cs-actions   Source File: GetTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

    FileSystem fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry("/data"));
    fileSystem.add(new FileEntry("/data/foobar.txt","abdef 1234567890"));

    fakeFtpServer = new FakeFtpServer();
    fakeFtpServer.setFileSystem(fileSystem);
    fakeFtpServer.setServerControlPort(0);
    fakeFtpServer.addUserAccount(new UserAccount("user","password","/data"));
    fakeFtpServer.start();

    getOperation  = new Get();
    ftpService  = new FTPService();

}
 
Example 5
Source Project: tutorials   Source File: FtpClientIntegrationTest.java    License: MIT License 6 votes vote down vote up
@Before
public void setup() throws IOException {
    fakeFtpServer = new FakeFtpServer();
    fakeFtpServer.addUserAccount(new UserAccount("user", "password", "/data"));

    FileSystem fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry("/data"));
    fileSystem.add(new FileEntry("/data/foobar.txt", "abcdef 1234567890"));
    fakeFtpServer.setFileSystem(fileSystem);
    fakeFtpServer.setServerControlPort(0);

    fakeFtpServer.start();

    ftpClient = new FtpClient("localhost", fakeFtpServer.getServerControlPort(), "user", "password");
    ftpClient.open();
}
 
Example 6
@Override
protected void starting(org.junit.runner.Description description)
{
  UnixFakeFileSystem fileSystem = new UnixFakeFileSystem();
  DirectoryEntry homeDirectory = new DirectoryEntry("/home/test");
  fileSystem.add(homeDirectory);
  fileSystem.add(new FileEntry(homeDirectory.getPath() + "/1.txt", "1\n10\n"));
  fileSystem.add(new FileEntry(homeDirectory.getPath() + "/2.txt", "2\n20\n"));

  fakeFtpServer = new FakeFtpServer();
  fakeFtpServer.setServerControlPort(0);
  fakeFtpServer.addUserAccount(new UserAccount("testUser", "test", homeDirectory.getPath()));


  fakeFtpServer.setFileSystem(fileSystem);
  fakeFtpServer.start();

  ftpOperator = new FTPStringInputOperator();
  ftpOperator.setHost("localhost");
  ftpOperator.setPort(fakeFtpServer.getServerControlPort());
  ftpOperator.setUserName("testUser");
  ftpOperator.setPassword("test");

  ftpOperator.setDirectory(homeDirectory.getPath());
  ftpOperator.setup(mockOperatorContext(11, new Attribute.AttributeMap.DefaultAttributeMap()));

  sink = new CollectorTestSink<>();
  ftpOperator.output.setSink(sink);
}
 
Example 7
Source Project: tutorials   Source File: JdkFtpClientIntegrationTest.java    License: MIT License 5 votes vote down vote up
@Before
public void setup() throws IOException {
    fakeFtpServer = new FakeFtpServer();
    fakeFtpServer.addUserAccount(new UserAccount("user", "password", "/data"));

    FileSystem fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry("/data"));
    fileSystem.add(new FileEntry("/data/foobar.txt", "abcdef 1234567890"));
    fakeFtpServer.setFileSystem(fileSystem);
    fakeFtpServer.setServerControlPort(0);

    fakeFtpServer.start();
}