Skip to content

Commit

Permalink
Add multipage crawl
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuel-keller committed Feb 24, 2017
1 parent 5974e7c commit dfe65e7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/test/java/com/qwazr/crawler/web/test/WebCrawlerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ private WebCrawlDefinition getNewWebCrawl() {
webCrawl.setJavascriptEnabled(false);
webCrawl.setImplicitlyWait(0);
webCrawl.setDownloadImages(false);
webCrawl.setMaxUrlNumber(10);
webCrawl.setMaxDepth(2);
webCrawl.entry_url = WebAppTestServer.URL;
return webCrawl;
}
Expand All @@ -90,7 +92,7 @@ private void crawlWait(final String sessionName, final int crawlCount) throws In
public void test300SimpleCrawl() throws InterruptedException {
final String sessionName = RandomStringUtils.randomAlphanumeric(10);
remote.runSession(sessionName, getNewWebCrawl());
crawlWait(sessionName, 1);
crawlWait(sessionName, 3);
}

@Test
Expand All @@ -101,8 +103,8 @@ public void test400CrawlEvent() throws InterruptedException {
webCrawl.scripts.put(WebCrawlDefinition.EventEnum.before_crawl,
new WebCrawlDefinition.Script(BeforeCrawl.class.getName()));
remote.runSession(sessionName, webCrawl);
crawlWait(sessionName, 1);
Assert.assertEquals(2, BeforeCrawl.count.get());
crawlWait(sessionName, 3);
Assert.assertEquals(4, BeforeCrawl.count.get());
}

@Test
Expand Down
8 changes: 8 additions & 0 deletions src/test/statics/html/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<html>
<body>
<h1>Hello World</h1>
<ul>
<li>
<a href="page1.html">page1</a>
</li>
<li>
<a href="page2.html">page2</a>
</li>
</ul>
</body>
</html>
5 changes: 5 additions & 0 deletions src/test/statics/html/page1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<h1>Page 1</h1>
</body>
</html>
5 changes: 5 additions & 0 deletions src/test/statics/html/page2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
<h1>Page 1</h1>
</body>
</html>

0 comments on commit dfe65e7

Please sign in to comment.