Search in sources :

Example 11 with CrawlerWebServer

use of org.codelibs.fess.crawler.util.CrawlerWebServer in project fess-crawler by codelibs.

the class CrawlerTest method test_execute_xmlSitemaps.

public void test_execute_xmlSitemaps() throws Exception {
    final CrawlerWebServer server = new CrawlerWebServer(7070);
    server.start();
    final String url = "http://localhost:7070/";
    try {
        final int maxCount = 50;
        final int numOfThread = 10;
        final File file = File.createTempFile("crawler-", "");
        file.delete();
        file.mkdirs();
        file.deleteOnExit();
        fileTransformer.setPath(file.getAbsolutePath());
        crawler.addUrl(url + "sitemaps.xml");
        crawler.crawlerContext.setMaxAccessCount(maxCount);
        crawler.crawlerContext.setNumOfThread(numOfThread);
        crawler.urlFilter.addInclude(url + ".*");
        final String sessionId = crawler.execute();
        assertEquals(maxCount, dataService.getCount(sessionId));
        dataService.delete(sessionId);
    } finally {
        server.stop();
    }
}
Also used : CrawlerWebServer(org.codelibs.fess.crawler.util.CrawlerWebServer) File(java.io.File)

Example 12 with CrawlerWebServer

use of org.codelibs.fess.crawler.util.CrawlerWebServer in project fess-crawler by codelibs.

the class CrawlerTest method test_execute_web.

public void test_execute_web() throws Exception {
    final CrawlerWebServer server = new CrawlerWebServer(7070);
    server.start();
    final String url = "http://localhost:7070/";
    try {
        final int maxCount = 50;
        final int numOfThread = 10;
        final File file = File.createTempFile("crawler-", "");
        file.delete();
        file.mkdirs();
        file.deleteOnExit();
        fileTransformer.setPath(file.getAbsolutePath());
        crawler.addUrl(url);
        crawler.crawlerContext.setMaxAccessCount(maxCount);
        crawler.crawlerContext.setNumOfThread(numOfThread);
        crawler.urlFilter.addInclude(url + ".*");
        final String sessionId = crawler.execute();
        assertEquals(maxCount, dataService.getCount(sessionId));
        dataService.delete(sessionId);
    } finally {
        server.stop();
    }
}
Also used : CrawlerWebServer(org.codelibs.fess.crawler.util.CrawlerWebServer) File(java.io.File)

Aggregations

CrawlerWebServer (org.codelibs.fess.crawler.util.CrawlerWebServer)12 File (java.io.File)9 ResponseData (org.codelibs.fess.crawler.entity.ResponseData)4 UrlFilterImpl (org.codelibs.fess.crawler.filter.impl.UrlFilterImpl)3 UrlQueue (org.codelibs.fess.crawler.entity.UrlQueue)2 Date (java.util.Date)1 Crawler (org.codelibs.fess.crawler.Crawler)1 CrawlerContext (org.codelibs.fess.crawler.CrawlerContext)1 RequestData (org.codelibs.fess.crawler.entity.RequestData)1