}
}
final public void testAddDocuments() throws Exception {
SimpleAnalyzer analyzer = new SimpleAnalyzer();
MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
MockControl documentsCreatorControl = MockControl.createStrictControl(DocumentsCreator.class);
DocumentsCreator documentsCreator = (DocumentsCreator)documentsCreatorControl.getMock();
//documents
List documents = new ArrayList();
Document document1 = new Document();
document1.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
document1.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
document1.add(new Field("sort", "2", Field.Store.YES, Field.Index.UN_TOKENIZED));
documents.add(document1);
indexFactory.getIndexWriter();
indexFactoryControl.setReturnValue(indexWriter, 1);
documentsCreator.createDocuments();
documentsCreatorControl.setReturnValue(documents, 1);
indexWriter.addDocument(document1);
indexWriterControl.setVoidCallable();
indexWriter.close();
indexWriterControl.setVoidCallable(1);
indexFactoryControl.replay();
indexWriterControl.replay();
documentsCreatorControl.replay();
//Lucene template
LuceneIndexTemplate template = new DefaultLuceneIndexTemplate(indexFactory,analyzer);
template.addDocuments(documentsCreator);
indexFactoryControl.verify();
indexWriterControl.verify();
documentsCreatorControl.verify();
}