MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
MockControl documentHandlerManagerControl = MockControl.createStrictControl(DocumentHandlerManager.class);
DocumentHandlerManager documentHandlerManager = (DocumentHandlerManager)documentHandlerManagerControl.getMock();
MockControl documentHandlerControl = MockControl.createStrictControl(DocumentHandler.class);
DocumentHandler documentHandler = (DocumentHandler)documentHandlerControl.getMock();
MockControl inputStreamControl = MockClassControl.createStrictControl(InputStream.class);
final InputStream inputStream = (InputStream)inputStreamControl.getMock();
//file
final File file = getFileFromClasspath("test.txt");
final Map description = new HashMap();
description.put(AbstractInputStreamDocumentHandler.FILENAME, file.getPath());
//final FileInputStream inputStream = new FileInputStream(file);
//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));
indexFactory.getIndexWriter();
indexFactoryControl.setReturnValue(indexWriter, 1);
//DocumentHandler documentHandler = documentHandlerManager.getDocumentHandler(getResourceName());
documentHandlerManager.getDocumentHandler(file.getPath());
documentHandlerManagerControl.setReturnValue(documentHandler, 1);
//Document document = documentHandler.getDocument(getResourceDescription(),inputStream);
documentHandler.getDocument(description, inputStream);
documentHandlerControl.setReturnValue(document, 1);