use of com.thinkaurelius.titan.diskstorage.indexing.IndexProvider in project titan by thinkaurelius.
the class ElasticSearchIndexTest method testConfiguration.
@Test
public void testConfiguration() throws BackendException {
// Test that local-mode has precedence over hostname
final String index = "es";
ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration();
config.set(LOCAL_MODE, true, index);
config.set(CLIENT_ONLY, true, index);
config.set(INDEX_HOSTS, new String[] { "10.0.0.1" }, index);
config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index);
Configuration indexConfig = config.restrictTo(index);
// Shouldn't throw exception
IndexProvider idx = new ElasticSearchIndex(indexConfig);
idx.close();
config = GraphDatabaseConfiguration.buildGraphConfiguration();
config.set(LOCAL_MODE, false, index);
config.set(CLIENT_ONLY, true, index);
config.set(INDEX_HOSTS, new String[] { "10.0.0.1" }, index);
config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index);
indexConfig = config.restrictTo(index);
RuntimeException expectedException = null;
try {
// Should try 10.0.0.1 and throw exception
idx = new ElasticSearchIndex(indexConfig);
idx.close();
} catch (RuntimeException re) {
expectedException = re;
}
assertNotNull(expectedException);
}
Aggregations