use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method shouldFailToOpenGraphAfterRemoveConfiguration.
@Test
public void shouldFailToOpenGraphAfterRemoveConfiguration() {
final MapConfiguration graphConfig = getGraphConfig();
final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
ConfiguredGraphFactory.createConfiguration(graphConfig);
ConfiguredGraphFactory.removeConfiguration(graphName);
RuntimeException graph1 = assertThrows(RuntimeException.class, () -> ConfiguredGraphFactory.create(graphName));
assertEquals("Please create a template Configuration using the " + "ConfigurationManagementGraph#createTemplateConfiguration API.", graph1.getMessage());
}
use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method graphConfigurationShouldBeWhatWeExpect.
@Test
public void graphConfigurationShouldBeWhatWeExpect() throws Exception {
final MapConfiguration graphConfig = getGraphConfig();
final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
try {
ConfiguredGraphFactory.createConfiguration(getGraphConfig());
final String backend = graphConfig.getString(STORAGE_BACKEND.toStringWithoutRoot());
final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open(graphName);
assertNotNull(graph);
assertEquals(graphName, graph.getConfiguration().getConfiguration().get(GRAPH_NAME));
assertEquals(backend, graph.getConfiguration().getConfiguration().get(STORAGE_BACKEND));
} finally {
ConfiguredGraphFactory.removeConfiguration(graphName);
ConfiguredGraphFactory.close(graphName);
}
}
use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method shouldFailToOpenNewGraphAfterRemoveConfiguration.
@Test
public void shouldFailToOpenNewGraphAfterRemoveConfiguration() {
final MapConfiguration graphConfig = getGraphConfig();
final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
ConfiguredGraphFactory.createConfiguration(graphConfig);
ConfiguredGraphFactory.removeConfiguration(graphName);
RuntimeException graph1 = assertThrows(RuntimeException.class, () -> ConfiguredGraphFactory.open(graphName));
assertEquals("Please create configuration for this graph using the " + "ConfigurationManagementGraph#createConfiguration API.", graph1.getMessage());
}
use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method updateConfigurationShouldRemoveGraphFromCache.
@Test
public void updateConfigurationShouldRemoveGraphFromCache() throws Exception {
final MapConfiguration graphConfig = getGraphConfig();
final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
try {
ConfiguredGraphFactory.createConfiguration(graphConfig);
final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open(graphName);
assertNotNull(graph);
final Map<String, Object> map = graphConfig.getMap();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "bogusBackend");
ConfiguredGraphFactory.updateConfiguration(graphName, ConfigurationUtil.loadMapConfiguration(map));
assertNull(gm.getGraph(graphName));
// we should throw an error since the config has been updated and we are attempting
// to open a bogus backend
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> ConfiguredGraphFactory.open(graphName));
assertEquals("Could not find implementation class: bogusBackend", exception.getMessage());
} finally {
ConfiguredGraphFactory.removeConfiguration(graphName);
ConfiguredGraphFactory.close(graphName);
}
}
use of org.apache.commons.configuration2.MapConfiguration in project janusgraph by JanusGraph.
the class GraphDatabaseConfigurationInstanceIdTest method instanceIdShouldEqualHostnamePlusSuffix.
@Test
public void instanceIdShouldEqualHostnamePlusSuffix() throws UnknownHostException {
final Map<String, Object> map = getStorageConfiguration();
map.put(UNIQUE_INSTANCE_ID_HOSTNAME.toStringWithoutRoot(), true);
map.put(UNIQUE_INSTANCE_ID_SUFFIX.toStringWithoutRoot(), 1);
final MapConfiguration config = ConfigurationUtil.loadMapConfiguration(map);
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
assertEquals(1, graph.openManagement().getOpenInstances().size());
assertEquals(toCurrentInstance(Inet4Address.getLocalHost().getHostName() + "1"), graph.openManagement().getOpenInstances().iterator().next());
graph.close();
}
Aggregations