public void testTemplateExecutionWithIndexWriterReaderWithError() throws Exception {
IndexFactory indexFactory = createIndexFactory();
ResourceManager resourceManager = createResourceManager(indexFactory);
DefaultLuceneIndexTemplate template = new DefaultLuceneIndexTemplate();
template.setIndexFactory(indexFactory);
template.setAnalyzer(new SimpleAnalyzer());
template.afterPropertiesSet();
DefaultResourceManagementDefinition definition = new DefaultResourceManagementDefinition();
definition.setIndexWriterOpen(true);
definition.setWriteOperationsForIndexWriterAuthorized(true);
//definition.setIndexReaderOpen(true);
definition.setWriteOperationsForIndexReaderAuthorized(false);
try {
resourceManager.initializeResources(definition);
Document document = new Document();
document.add(new Field("id", "3", Field.Store.YES, Field.Index.UN_TOKENIZED));
template.addDocument(document);
template.addDocument(document);
template.addDocument(document);
try {
template.deleteDocuments(new Term("id", "1"));
fail();
} catch(LuceneIndexingException ex) {}
template.optimize();
} finally {
resourceManager.releaseResources();
}
}