testOnce();
}
private void testOnce() {
FullTextSessionBuilder builder = new FullTextSessionBuilder()
.setProperty(
"hibernate.search.default.directory_provider",
org.hibernate.search.test.directoryProvider.CloseCheckingDirectoryProvider.class.getName() )
.addAnnotatedClass( SnowStorm.class )
.build();
CloseCheckingDirectoryProvider directoryProvider;
try {
SearchFactoryIntegrator searchFactory = (SearchFactoryIntegrator) builder.getSearchFactory();
EntityIndexBinding snowIndexBinder = searchFactory.getIndexBinding( SnowStorm.class );
IndexManager[] indexManagers = snowIndexBinder.getIndexManagers();
assertThat( indexManagers.length ).isEqualTo( 1 );
assertThat( indexManagers[0] ).isInstanceOf( DirectoryBasedIndexManager.class );
DirectoryBasedIndexManager dbBasedManager = (DirectoryBasedIndexManager)indexManagers[0];
assertThat( dbBasedManager.getDirectoryProvider() ).isInstanceOf( CloseCheckingDirectoryProvider.class );
directoryProvider = (CloseCheckingDirectoryProvider) dbBasedManager.getDirectoryProvider();
assertThat( directoryProvider.isInitialized() ).isTrue();
assertThat( directoryProvider.isStarted() ).isTrue();
assertThat( directoryProvider.isStopped() ).isFalse();
}
finally {
builder.close();
}
assertThat( directoryProvider.isStopped() ).isTrue();
}