public void testBasicFields() throws Exception {
Configuration conf = NutchConfiguration.create();
BasicIndexingFilter filter = new BasicIndexingFilter();
filter.setConf(conf);
assertNotNull(filter);
NutchDocument doc = new NutchDocument();
WebPage page = new WebPage();
page.putToInlinks(new Utf8("http://nutch.apache.org/"), new Utf8("Welcome to Nutch"));
page.setTitle(new Utf8("Welcome to Nutch"));
page.setReprUrl(new Utf8("http://www.urldoesnotmatter.org"));
byte[] bytes = new byte[10];
ByteBuffer bbuf = ByteBuffer.wrap(bytes);
page.putToMetadata(Nutch.CACHING_FORBIDDEN_KEY_UTF8, bbuf);
page.setFetchTime(System.currentTimeMillis());
try {
filter.filter(doc, "http://www.apache.org/", page);
} catch(Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
assertNotNull(doc);
assertTrue("check for host field ", doc.getFieldNames().contains("host"));
assertTrue("check for url field", doc.getFieldNames().contains("url"));
assertTrue("check for orig field", doc.getFieldNames().contains("orig"));
assertTrue("check for content field", doc.getFieldNames().contains("content"));
assertTrue("check for title field", doc.getFieldNames().contains("title"));
assertTrue("check for cache field", doc.getFieldNames().contains("cache"));
assertTrue("check for tstamp field", doc.getFieldNames().contains("tstamp"));
}