사용자 도구

사이트 도구


java:ftp

문서의 이전 판입니다!


Java FTP

apache commons net FTPClient

Passive Mode

MockFtpServer

  • MockFtpServer FTP 서버를 mocking하여 테스트를 할 수 있다.
public class FtpClientIntegrationTest {
 
    private FakeFtpServer fakeFtpServer;
 
    private FtpClient ftpClient;
 
    @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();
    }
 
    @After
    public void teardown() throws IOException {
        ftpClient.close();
        fakeFtpServer.stop();
    }
}

참조

java/ftp.1553229082.txt.gz · 마지막으로 수정됨: 2019/03/22 13:31 저자 kwon37xi