use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method dropShouldCleanUpTraversalSourceAndBindings.
@Test
public void dropShouldCleanUpTraversalSourceAndBindings() throws Exception {
final MapConfiguration graphConfig = getGraphConfig();
final String graphName = graphConfig.getString(GRAPH_NAME.toStringWithoutRoot());
final String graphNameTraversal = graphName + "_traversal";
try {
ConfiguredGraphFactory.createConfiguration(graphConfig);
final JanusGraphManager jgm = JanusGraphManager.getInstance();
final Bindings bindings = new SimpleBindings();
jgm.configureGremlinExecutor(mockGremlinExecutor(bindings));
final StandardJanusGraph graph = (StandardJanusGraph) ConfiguredGraphFactory.open(graphName);
jgm.putTraversalSource(ConfiguredGraphFactory.toTraversalSourceName(graphName), graph.traversal());
assertNotNull(jgm.getGraph(graphName));
assertEquals(ConfiguredGraphFactory.toTraversalSourceName(graphName), jgm.getTraversalSourceNames().iterator().next());
// Confirm the graph and traversal source were added to the Gremlin Script Engine bindings
assertTrue(bindings.containsKey(graphName));
assertTrue(bindings.containsKey(graphNameTraversal));
// Drop the graph and confirm that the graph and traversal source
ConfiguredGraphFactory.drop(graphName);
assertNull(jgm.getGraph(graphName));
assertTrue(jgm.getTraversalSourceNames().isEmpty());
// Confirm the graph and traversal source were removed from the Gremlin Script Engine bindings
assertFalse(bindings.containsKey(graphName));
assertFalse(bindings.containsKey(graphNameTraversal));
} finally {
ConfiguredGraphFactory.removeConfiguration(graphName);
ConfiguredGraphFactory.close(graphName);
}
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method shouldCreateTwoGraphsUsingSameTemplateConfiguration.
@Test
public void shouldCreateTwoGraphsUsingSameTemplateConfiguration() throws Exception {
try {
ConfiguredGraphFactory.createTemplateConfiguration(getTemplateConfig());
final StandardJanusGraph graph1 = (StandardJanusGraph) ConfiguredGraphFactory.create("graph1");
final StandardJanusGraph graph2 = (StandardJanusGraph) ConfiguredGraphFactory.create("graph2");
assertNotNull(graph1);
assertNotNull(graph2);
assertEquals("graph1", graph1.getConfiguration().getConfiguration().get(GRAPH_NAME));
assertEquals("graph2", graph2.getConfiguration().getConfiguration().get(GRAPH_NAME));
} finally {
ConfiguredGraphFactory.removeConfiguration("graph1");
ConfiguredGraphFactory.removeConfiguration("graph2");
ConfiguredGraphFactory.close("graph1");
ConfiguredGraphFactory.close("graph2");
}
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method removeConfigurationShouldRemoveGraphFromCache.
@Test
public void removeConfigurationShouldRemoveGraphFromCache() 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);
ConfiguredGraphFactory.removeConfiguration(graphName);
assertNull(gm.getGraph(graphName));
} finally {
ConfiguredGraphFactory.removeConfiguration(graphName);
ConfiguredGraphFactory.close(graphName);
}
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method setup.
@BeforeEach
public void setup() {
if (gm != null)
return;
gm = new JanusGraphManager(new Settings());
final MapConfiguration config = getManagementConfig();
final StandardJanusGraph graph = new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(new CommonsConfiguration(config)));
// Instantiate the ConfigurationManagementGraph Singleton
new ConfigurationManagementGraph(graph);
}
use of org.janusgraph.graphdb.database.StandardJanusGraph in project janusgraph by JanusGraph.
the class AbstractConfiguredGraphFactoryTest method dropGraphShouldRemoveGraphFromCache.
@Test
public void dropGraphShouldRemoveGraphFromCache() 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);
ConfiguredGraphFactory.drop(graphName);
assertNull(gm.getGraph(graphName));
assertTrue(graph.isClosed());
} finally {
ConfiguredGraphFactory.removeConfiguration(graphName);
ConfiguredGraphFactory.close(graphName);
}
}
Aggregations