Search in sources :

Example 1 with FtpInfo

use of org.codelibs.fess.crawler.client.ftp.FtpClient.FtpInfo in project fess-crawler by codelibs.

the class FtpClientTest method test_ftpInfo.

public void test_ftpInfo() {
    String value;
    FtpInfo ftpInfo;
    try {
        ftpInfo = new FtpClient.FtpInfo(null);
        fail();
    } catch (CrawlingAccessException e) {
    // ignore
    }
    try {
        ftpInfo = new FtpClient.FtpInfo("");
        fail();
    } catch (CrawlingAccessException e) {
    // ignore
    }
    try {
        ftpInfo = new FtpClient.FtpInfo("abc");
        fail();
    } catch (CrawlingAccessException e) {
    // ignore
    }
    value = "ftp://123.123.123.123:9999/";
    ftpInfo = new FtpClient.FtpInfo(value);
    assertEquals(value, ftpInfo.toUrl());
    assertEquals("123.123.123.123:9999", ftpInfo.getCacheKey());
    assertEquals("123.123.123.123", ftpInfo.getHost());
    assertEquals(9999, ftpInfo.getPort());
    assertEquals("/", ftpInfo.getParent());
    assertNull(ftpInfo.getName());
    value = "ftp://123.123.123.123/test.txt";
    ftpInfo = new FtpClient.FtpInfo(value);
    assertEquals(value, ftpInfo.toUrl());
    assertEquals("123.123.123.123:21", ftpInfo.getCacheKey());
    assertEquals("123.123.123.123", ftpInfo.getHost());
    assertEquals(21, ftpInfo.getPort());
    assertEquals("/", ftpInfo.getParent());
    assertEquals("test.txt", ftpInfo.getName());
    value = "ftp://123.123.123.123/aaa/../test.txt";
    ftpInfo = new FtpClient.FtpInfo(value);
    assertEquals("ftp://123.123.123.123/test.txt", ftpInfo.toUrl());
    assertEquals("123.123.123.123:21", ftpInfo.getCacheKey());
    assertEquals("123.123.123.123", ftpInfo.getHost());
    assertEquals(21, ftpInfo.getPort());
    assertEquals("/", ftpInfo.getParent());
    assertEquals("test.txt", ftpInfo.getName());
    assertEquals("ftp://123.123.123.123/", ftpInfo.toUrl("/"));
    value = "ftp://123.123.123.123:21/test1/test.txt";
    ftpInfo = new FtpClient.FtpInfo(value);
    assertEquals("ftp://123.123.123.123/test1/test.txt", ftpInfo.toUrl());
    assertEquals("123.123.123.123:21", ftpInfo.getCacheKey());
    assertEquals("123.123.123.123", ftpInfo.getHost());
    assertEquals(21, ftpInfo.getPort());
    assertEquals("/test1", ftpInfo.getParent());
    assertEquals("test.txt", ftpInfo.getName());
    assertEquals("ftp://123.123.123.123/", ftpInfo.toUrl("/"));
    assertEquals("ftp://123.123.123.123/aaa/bbb/ccc.txt", ftpInfo.toUrl("/aaa//bbb/ccc.txt"));
    assertEquals("ftp://123.123.123.123/ccc.txt", ftpInfo.toUrl("/aaa/../ccc.txt"));
    value = "ftp://123.123.123.123/test test.txt";
    ftpInfo = new FtpClient.FtpInfo(value);
    assertEquals(value, ftpInfo.toUrl());
    assertEquals("123.123.123.123:21", ftpInfo.getCacheKey());
    assertEquals("123.123.123.123", ftpInfo.getHost());
    assertEquals(21, ftpInfo.getPort());
    assertEquals("/", ftpInfo.getParent());
    assertEquals("test test.txt", ftpInfo.getName());
    value = "ftp://123.123.123.123/テスト.txt";
    ftpInfo = new FtpClient.FtpInfo(value);
    assertEquals(value, ftpInfo.toUrl());
    assertEquals("123.123.123.123:21", ftpInfo.getCacheKey());
    assertEquals("123.123.123.123", ftpInfo.getHost());
    assertEquals(21, ftpInfo.getPort());
    assertEquals("/", ftpInfo.getParent());
    assertEquals("テスト.txt", ftpInfo.getName());
    value = "ftp://123.123.123.123/";
    ftpInfo = new FtpClient.FtpInfo(value);
    assertEquals(value, ftpInfo.toUrl());
    assertEquals("123.123.123.123:21", ftpInfo.getCacheKey());
    assertEquals("123.123.123.123", ftpInfo.getHost());
    assertEquals(21, ftpInfo.getPort());
    assertEquals("/", ftpInfo.getParent());
    assertNull(ftpInfo.getName());
}
Also used : FtpInfo(org.codelibs.fess.crawler.client.ftp.FtpClient.FtpInfo) FtpInfo(org.codelibs.fess.crawler.client.ftp.FtpClient.FtpInfo) CrawlingAccessException(org.codelibs.fess.crawler.exception.CrawlingAccessException)

Aggregations

FtpInfo (org.codelibs.fess.crawler.client.ftp.FtpClient.FtpInfo)1 CrawlingAccessException (org.codelibs.fess.crawler.exception.CrawlingAccessException)1