IndexableStub stub = new IndexableStub();
stub.setReturnNull(true);
try {
this.strategy.processIndexable(stub);
fail("retun value is null must fail");
} catch (NotIndexableException e) {
}
assertNull(this.strategy.content);
try {
this.strategy.createLuceneField();
fail("content is not set");
} catch (GdataIndexerException e) {
}
String content = "fooBar";
stub.setReturnNull(false);
stub.setReturnValueTextContent(content);
this.strategy.processIndexable(stub);
assertNotNull(this.strategy.content);
assertEquals(content, this.strategy.content);
Field[] fields = this.strategy.createLuceneField();
assertEquals(1, fields.length);
assertEquals(this.field.getName(), fields[0].name());
assertEquals(content, fields[0].stringValue());
// this is also stored an untok.
assertTrue(fields[0].isStored());
assertFalse(fields[0].isTokenized());
// test for xpath exc.
this.field.setPath(null);
this.strategy = new KeywordStrategy(field);
try {
this.strategy.processIndexable(stub);
fail("path is null must fail");
} catch (NotIndexableException e) {
}
try {
this.strategy.createLuceneField();
fail("content is not set");
} catch (GdataIndexerException e) {
}