mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-23 14:15:47 +00:00
* JerichoExtractorHTMLTest.java
avoid redundancy by using extractor built in setUp()
makeExtractor() - call extractor.setExtractorJS(new ExtractorJS()) since we got rid of the static ExtractorJS stuff
testConditionalComment1() - override to skip the test since it fails with JerichoExtractorHTML
This commit is contained in:
@@ -45,6 +45,7 @@ public class JerichoExtractorHTMLTest extends ExtractorHTMLTest {
|
||||
CrawlMetadata metadata = new CrawlMetadata();
|
||||
metadata.afterPropertiesSet();
|
||||
result.setMetadata(metadata);
|
||||
result.setExtractorJS(new ExtractorJS());
|
||||
result.afterPropertiesSet();
|
||||
return result;
|
||||
}
|
||||
@@ -68,8 +69,7 @@ public class JerichoExtractorHTMLTest extends ExtractorHTMLTest {
|
||||
" </select>" +
|
||||
" <input type=\"submit\" name=\"test\" value=\"Go\">" +
|
||||
"</form>";
|
||||
JerichoExtractorHTML ex = (JerichoExtractorHTML)makeExtractor();
|
||||
ex.extract(curi, cs);
|
||||
getExtractor().extract(curi, cs);
|
||||
curi.getOutLinks();
|
||||
assertTrue(CollectionUtils.exists(curi.getOutLinks(), new Predicate() {
|
||||
public boolean evaluate(Object object) {
|
||||
@@ -97,8 +97,7 @@ public class JerichoExtractorHTMLTest extends ExtractorHTMLTest {
|
||||
" </select>" +
|
||||
" <input type=\"submit\" name=\"test\" value=\"Go\">" +
|
||||
"</form>";
|
||||
JerichoExtractorHTML ex = (JerichoExtractorHTML)makeExtractor();
|
||||
ex.extract(curi, cs);
|
||||
getExtractor().extract(curi, cs);
|
||||
curi.getOutLinks();
|
||||
assertTrue(!CollectionUtils.exists(curi.getOutLinks(), new Predicate() {
|
||||
public boolean evaluate(Object object) {
|
||||
@@ -125,10 +124,9 @@ public class JerichoExtractorHTMLTest extends ExtractorHTMLTest {
|
||||
" <option value=\"nonselectedOption\">option2</option>" +
|
||||
" </select>" +
|
||||
" <input type=\"submit\" name=\"test\" value=\"Go\">" +
|
||||
"</form>";
|
||||
JerichoExtractorHTML ex = (JerichoExtractorHTML)makeExtractor();
|
||||
ex.setExtractOnlyFormGets(false);
|
||||
ex.extract(curi, cs);
|
||||
"</form>";
|
||||
getExtractor().setExtractOnlyFormGets(false);
|
||||
getExtractor().extract(curi, cs);
|
||||
curi.getOutLinks();
|
||||
assertTrue(CollectionUtils.exists(curi.getOutLinks(), new Predicate() {
|
||||
public boolean evaluate(Object object) {
|
||||
@@ -142,8 +140,20 @@ public class JerichoExtractorHTMLTest extends ExtractorHTMLTest {
|
||||
UURI uuri = UURIFactory.getInstance("http://www.example.org");
|
||||
CrawlURI curi = new CrawlURI(uuri);
|
||||
CharSequence cs = "<a src=\"http://www.example.com/\" href=\"http://www.archive.org/\"> ";
|
||||
JerichoExtractorHTML ex = (JerichoExtractorHTML)makeExtractor();
|
||||
ex.extract(curi, cs);
|
||||
getExtractor().extract(curi, cs);
|
||||
assertTrue("not all links found", curi.getOutLinks().size() == 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Override of ExtractorHTMLTest method because the test fails with
|
||||
* JerichoExtractorHTML
|
||||
*/
|
||||
@Override
|
||||
public void testConditionalComment1() throws URIException {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JerichoExtractorHTML getExtractor() {
|
||||
return (JerichoExtractorHTML) extractor;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user