MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
DefaultDocumentHandlerManager manager = new DefaultDocumentHandlerManager();
//Object to index
final String text = "a text";
//document
final Document document = new Document();
document.add(new Field("text", text, Field.Store.YES, Field.Index.TOKENIZED));
final boolean[] called = {false, false};
manager.registerDocumentHandler(new IdentityDocumentMatching("java.lang.String"), new AbstractDocumentHandler() {
public boolean supports(Class clazz) {
called[0]=true;
return true;
}