@Test
public void testFilter() throws IndexingException {
// Prepare data
NutchDocument nutchDocumentIn = new NutchDocument();
Parse parse = mock(Parse.class);
ParseData parseData = new ParseData();
parseData.setParseMeta(metadata);
Configuration configuration = mock(Configuration.class);
// Mock data
when(parse.getData()).thenReturn(parseData);
when(configuration.get(anyString())).thenReturn("");
when(configuration.getConfResourceAsReader(anyString())).thenReturn(new InputStreamReader(XPathIndexingFilterTest.class.getResourceAsStream("example-xpathfilter-conf.xml")));
xmlHtmlIndexingFilter.setConf(configuration);
NutchDocument nutchDocumentOut = xmlHtmlIndexingFilter.filter(nutchDocumentIn, parse, new Text("www.test.com"), null, null);
int stringValueIndexCount = 0;
int floatValueIndexCount = 0;
int dateValueIndexCount = 0;
for(String fieldName : nutchDocumentOut.getFieldNames()) {
for(Object value : nutchDocumentOut.getField(fieldName).getValues()) {
if(fieldName.equals("testString")) {
int index = Arrays.binarySearch(testStringArray, value);
stringValueIndexCount += index;