use of org.codelibs.fess.crawler.entity.ResponseData in project fess by codelibs.
the class DocumentHelperTest method test_getDigest.
public void test_getDigest() {
DocumentHelper documentHelper = new DocumentHelper();
ResponseData responseData = new ResponseData();
Map<String, Object> dataMap = new HashMap<>();
assertEquals("1234567...", documentHelper.getDigest(responseData, " 1234567890 1234567890 1234567890 ", dataMap, 10));
assertEquals("1234567...", documentHelper.getDigest(responseData, "123456789012345678901234567890", dataMap, 10));
assertEquals("1234567...", documentHelper.getDigest(responseData, "123456789012345678901", dataMap, 10));
assertEquals("1234567...", documentHelper.getDigest(responseData, "12345678901234567890", dataMap, 10));
assertEquals("1234567...", documentHelper.getDigest(responseData, "1234567890123456789", dataMap, 10));
assertEquals("1234567...", documentHelper.getDigest(responseData, "12345678901", dataMap, 10));
assertEquals("1234567890", documentHelper.getDigest(responseData, "1234567890", dataMap, 10));
assertEquals("123456789", documentHelper.getDigest(responseData, "123456789", dataMap, 10));
assertEquals("1234567", documentHelper.getDigest(responseData, "1234567", dataMap, 10));
assertEquals("1", documentHelper.getDigest(responseData, "1", dataMap, 10));
assertEquals("", documentHelper.getDigest(responseData, "", dataMap, 10));
assertEquals("", documentHelper.getDigest(responseData, " ", dataMap, 10));
assertEquals("", documentHelper.getDigest(responseData, null, dataMap, 10));
assertEquals("1234567...", documentHelper.getDigest(responseData, " 1234567890 1234567890 1234567890 ", dataMap, 10));
assertEquals("1234567...", documentHelper.getDigest(responseData, "12345678901234567890", dataMap, 10));
}
use of org.codelibs.fess.crawler.entity.ResponseData in project fess by codelibs.
the class DocumentHelperTest method test_getContent_maxAlphanum.
public void test_getContent_maxAlphanum() {
DocumentHelper documentHelper = new DocumentHelper() {
protected int getMaxAlphanumTermSize() {
return 2;
}
};
ResponseData responseData = new ResponseData();
Map<String, Object> dataMap = new HashMap<>();
assertEquals("", documentHelper.getContent(responseData, null, dataMap));
assertEquals("", documentHelper.getContent(responseData, "", dataMap));
assertEquals("", documentHelper.getContent(responseData, " ", dataMap));
assertEquals("", documentHelper.getContent(responseData, " ", dataMap));
assertEquals("", documentHelper.getContent(responseData, "\t", dataMap));
assertEquals("", documentHelper.getContent(responseData, "\t\t", dataMap));
assertEquals("", documentHelper.getContent(responseData, "\t \t", dataMap));
assertEquals("12 ab", documentHelper.getContent(responseData, " 123 abc ", dataMap));
assertEquals("123 あいう", documentHelper.getContent(responseData, " 123 あいう ", dataMap));
assertEquals("12 ab", documentHelper.getContent(responseData, " 123\nabc ", dataMap));
assertEquals("12", documentHelper.getContent(responseData, " 123abc ", dataMap));
}
use of org.codelibs.fess.crawler.entity.ResponseData in project fess by codelibs.
the class FessXpathTransformerTest method test_processMetaRobots_none.
public void test_processMetaRobots_none() throws Exception {
final String data = "<meta name=\"robots\" content=\"none\" />";
final Document document = getDocument(data);
final FessXpathTransformer transformer = new FessXpathTransformer();
final ResponseData responseData = new ResponseData();
responseData.setUrl("http://example.com/");
try {
transformer.processMetaRobots(responseData, new ResultData(), document);
fail();
} catch (ChildUrlsException e) {
assertTrue(e.getChildUrlList().isEmpty());
} catch (Exception e) {
fail();
}
}
use of org.codelibs.fess.crawler.entity.ResponseData in project fess by codelibs.
the class FessXpathTransformerTest method test_getThumbnailUrl_no.
public void test_getThumbnailUrl_no() throws Exception {
final FessXpathTransformer transformer = new FessXpathTransformer();
final ResponseData responseData = new ResponseData();
responseData.setUrl("http://example.com/");
String data = "<html><body>foo</body></html>";
assertNull(transformer.getThumbnailUrl(responseData, getDocument(data)));
data = "<img src=\"http://example/foo.jpg\" width=\"x\" height=\"x\">";
assertNull(transformer.getThumbnailUrl(responseData, getDocument(data)));
data = "<img src=\"http://example/foo.jpg\" width=\"10\" height=\"100\">";
assertNull(transformer.getThumbnailUrl(responseData, getDocument(data)));
data = "<img src=\"http://example/foo.jpg\" width=\"100\" height=\"10\">";
assertNull(transformer.getThumbnailUrl(responseData, getDocument(data)));
data = "<img src=\"http://example/foo.jpg\" width=\"400\" height=\"100\">";
assertNull(transformer.getThumbnailUrl(responseData, getDocument(data)));
data = "<img src=\"http://example/foo.jpg\" width=\"100\" height=\"400\">";
assertNull(transformer.getThumbnailUrl(responseData, getDocument(data)));
}
Aggregations