Search in sources :

Example 1 with IndexProvider

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);
}
Also used : IndexProvider(com.thinkaurelius.titan.diskstorage.indexing.IndexProvider) Configuration(com.thinkaurelius.titan.diskstorage.configuration.Configuration) GraphDatabaseConfiguration(com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration) ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) ModifiableConfiguration(com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration) ElasticSearchIndex(com.thinkaurelius.titan.diskstorage.es.ElasticSearchIndex) IndexProviderTest(com.thinkaurelius.titan.diskstorage.indexing.IndexProviderTest) Test(org.junit.Test)

Aggregations

Configuration (com.thinkaurelius.titan.diskstorage.configuration.Configuration)1 ModifiableConfiguration (com.thinkaurelius.titan.diskstorage.configuration.ModifiableConfiguration)1 ElasticSearchIndex (com.thinkaurelius.titan.diskstorage.es.ElasticSearchIndex)1 IndexProvider (com.thinkaurelius.titan.diskstorage.indexing.IndexProvider)1 IndexProviderTest (com.thinkaurelius.titan.diskstorage.indexing.IndexProviderTest)1 GraphDatabaseConfiguration (com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration)1 Test (org.junit.Test)1