}
final public void testUpdateDocuments() 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 indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();
MockControl searcherControl = MockControl.createStrictControl(LuceneSearcher.class);
LuceneSearcher searcher = (LuceneSearcher)searcherControl.getMock();
MockControl documentsModifierControl = MockControl.createStrictControl(DocumentsModifier.class);
DocumentsModifier documentsModifier = (DocumentsModifier)documentsModifierControl.getMock();
MockControl hitsControl = MockControl.createStrictControl(LuceneHits.class);
LuceneHits hits = (LuceneHits)hitsControl.getMock();
//document
Document document = new Document();
document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
document.add(new Field("sort", "2", Field.Store.YES, Field.Index.UN_TOKENIZED));
Term term = new Term("id","2");
List documents = new ArrayList();
indexFactory.getIndexReader();
indexFactoryControl.setReturnValue(indexReader, 1);
indexReader.createSearcher();
indexReaderControl.setReturnValue(searcher);
searcher.search(new TermQuery(term));
searcherControl.setReturnValue(hits);
documentsModifier.updateDocuments(hits);
documentsModifierControl.setReturnValue(documents, 1);
searcher.close();
searcherControl.setVoidCallable(1);
indexReader.close();
indexReaderControl.setVoidCallable(1);
indexFactory.getIndexReader();
indexFactoryControl.setReturnValue(indexReader, 1);
indexReader.deleteDocuments(term);
indexReaderControl.setReturnValue(1, 1);
indexReader.close();
indexReaderControl.setVoidCallable(1);
indexFactory.getIndexWriter();
indexFactoryControl.setReturnValue(indexWriter, 1);
indexWriter.addDocument(document);
indexWriterControl.setVoidCallable();