org.mockftpserver.fake.filesystem.WindowsFakeFileSystem Java Examples

The following examples show how to use org.mockftpserver.fake.filesystem.WindowsFakeFileSystem. 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 File: TestURL.java    From konduit-serving with Apache License 2.0 5 votes vote down vote up
@Test
public void testFTP() throws IOException, InterruptedException {
    assumeTrue(SystemUtils.IS_OS_WINDOWS);
    FakeFtpServer fakeFtpServer = new FakeFtpServer();
    String homeDir = testDir.newFolder().getAbsolutePath();
    fakeFtpServer.addUserAccount(new UserAccount("user", "password",
                                homeDir));
    val fileSystem = new WindowsFakeFileSystem();
    fileSystem.add(new DirectoryEntry(homeDir));
    fileSystem.add(new FileEntry(homeDir + File.separator + "config.json", "{\"pipelineSteps\": []}"));
    fakeFtpServer.setFileSystem(fileSystem);

    fakeFtpServer.start();
    System.out.println("FTP started on : " + fakeFtpServer.getServerControlPort());

    FtpClient ftpClient = new FtpClient();
    ftpClient.connect("localhost");
    if (ftpClient.login("user", "password")) {
        String url = FTP + "user:password@" + HOST + ":" + 21 + "/config.json";
        File dataFile = URIResolver.getFile(url);
        String data = FileUtils.readFileToString(dataFile, "UTF-8");
        assertTrue(data.contains("pipelineSteps"));
        fakeFtpServer.stop();
    }
    else {
        fakeFtpServer.stop();
        fail();
    }
}
 
Example #2
Source File: TestFTP.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    fakeFtpServer.setServerControlPort(0);
    fakeFtpServer.addUserAccount(new UserAccount(username, password, "c:\\data"));

    FileSystem fileSystem = new WindowsFakeFileSystem();
    fileSystem.add(new DirectoryEntry("c:\\data"));
    fakeFtpServer.setFileSystem(fileSystem);

    fakeFtpServer.start();

    ftpPort = fakeFtpServer.getServerControlPort();
}
 
Example #3
Source File: TestFTP.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    fakeFtpServer.setServerControlPort(0);
    fakeFtpServer.addUserAccount(new UserAccount(username, password, "c:\\data"));

    FileSystem fileSystem = new WindowsFakeFileSystem();
    fileSystem.add(new DirectoryEntry("c:\\data"));
    fakeFtpServer.setFileSystem(fileSystem);

    fakeFtpServer.start();

    ftpPort = fakeFtpServer.getServerControlPort();
}