### Question:
LuceneDataSource extends LifecycleAdapter { void deleteIndex( IndexIdentifier identifier, boolean recovery ) throws IOException { if ( readOnly ) { throw new IllegalStateException( "Index deletion in read only mode is not supported." ); } closeIndex( identifier ); FileUtils.deleteRecursively( getFileDirectory( baseStorePath, identifier ) ); indexTypeMap.remove( identifier ); boolean removeFromIndexStore = !recovery || (indexStore.has( identifier.entityType.entityClass(), identifier.indexName )); if ( removeFromIndexStore ) { indexStore.remove( identifier.entityType.entityClass(), identifier.indexName ); } typeCache.invalidate( identifier ); } LuceneDataSource( DatabaseLayout directoryStructure, Config config, IndexConfigStore indexStore,
            FileSystemAbstraction fileSystemAbstraction, OperationalMode operationalMode ); @Override void init(); static File getLuceneIndexStoreDirectory( DatabaseLayout directoryStructure ); @Override void shutdown(); static final Analyzer WHITESPACE_ANALYZER; static final Analyzer KEYWORD_ANALYZER; }### Answer:
@Test public void notAllowIndexDeletionInReadOnlyMode() throws Exception { IndexIdentifier indexIdentifier = identifier( "foo" ); prepareIndexesByIdentifiers( indexIdentifier ); stopDataSource(); Config readOnlyConfig = Config.defaults( readOnlyConfig() ); dataSource = life.add( getLuceneDataSource( readOnlyConfig, OperationalMode.single ) ); expectedException.expect( IllegalStateException.class ); expectedException.expectMessage("Index deletion in read only mode is not supported."); dataSource.deleteIndex( indexIdentifier, false ); }