use of org.apache.tinkerpop.gremlin.driver.Cluster in project cypher-for-gremlin by opencypher.
the class CypherGremlinServerClient method gremlinStyle.
@Test
public void gremlinStyle() throws Exception {
BaseConfiguration configuration = new BaseConfiguration();
configuration.setProperty("port", gremlinServer.getPort());
configuration.setProperty("hosts", Arrays.asList("localhost"));
// freshReadmeSnippet: gremlinStyle
Cluster cluster = Cluster.open(configuration);
Client gremlinClient = cluster.connect();
CypherGremlinClient cypherGremlinClient = CypherGremlinClient.plugin(gremlinClient);
String cypher = "MATCH (p:person) WHERE p.age > 25 RETURN p.name";
CypherResultSet resultSet = cypherGremlinClient.submit(cypher);
List<Map<String, Object>> results = resultSet.all();
// freshReadmeSnippet: gremlinStyle
assertThat(results).extracting("p.name").containsExactly("marko", "vadas", "josh", "peter");
}
use of org.apache.tinkerpop.gremlin.driver.Cluster in project cypher-for-gremlin by opencypher.
the class CypherGremlinNeo4jDriver method createDriver.
@Test
public void createDriver() throws Exception {
String pathToGremlinConfiguration = "../../tinkerpop/cypher-gremlin-server-plugin/src/main/resources/local-gremlin-server.yaml";
// freshReadmeSnippet: createDriver
Cluster cluster1 = Cluster.build().enableSsl(true).addContactPoints("192.168.0.145").create();
Driver driver1 = GremlinDatabase.driver(cluster1);
// Or:
Cluster cluster2 = Cluster.open(pathToGremlinConfiguration);
Driver driver2 = GremlinDatabase.driver(cluster2);
// freshReadmeSnippet: createDriver
}
use of org.apache.tinkerpop.gremlin.driver.Cluster in project janusgraph by JanusGraph.
the class ConfigurationManagementGraphServerTest method bindingShouldExistAfterGraphIsCreated.
@Test
public void bindingShouldExistAfterGraphIsCreated() throws Exception {
final Cluster cluster = TestClientFactory.open();
final Client client = cluster.connect();
// create newGraph
client.submit("Map<String, Object> map = new HashMap<String, Object>(); map.put(\"storage.backend\", \"inmemory\"); " + "org.janusgraph.core.ConfiguredGraphFactory.createTemplateConfiguration(" + "org.janusgraph.util.system.ConfigurationUtil.loadMapConfiguration(map));" + "org.janusgraph.core.ConfiguredGraphFactory.create(\"newGraph\")");
Thread.sleep(1000, 0);
// assert newGraph is indeed bound
assertEquals(0, client.submit("newGraph.vertices().size()").all().get().get(0).getInt());
// assert newGraph_traversal is bound and the graphs are equivalent
assertEquals("newGraph", client.submit("newGraph_traversal.getGraph().getGraphName()").all().get().get(0).getString());
// Ensure that we can open a remote graph traversal source against the created graph, and execute traversals
GraphTraversalSource newGraphTraversal = traversal().withRemote(DriverRemoteConnection.using(cluster, "newGraph_traversal"));
assertEquals(0, newGraphTraversal.V().count().next().longValue());
cluster.close();
}
use of org.apache.tinkerpop.gremlin.driver.Cluster in project janusgraph by JanusGraph.
the class ConfigurationManagementGraphServerTest method bindingForConfigurationManagementGraphShouldExists.
@Test
public void bindingForConfigurationManagementGraphShouldExists() throws Exception {
final Cluster cluster = TestClientFactory.open();
final Client client = cluster.connect();
assertEquals(0, client.submit("ConfigurationManagementGraph.vertices().size()").all().get().get(0).getInt());
}
use of org.apache.tinkerpop.gremlin.driver.Cluster in project janusgraph by JanusGraph.
the class ConfigurationManagementGraphServerTest method newGraphDoesntExistsBeforeCreation.
@Test
public void newGraphDoesntExistsBeforeCreation() throws Exception {
final Cluster cluster = TestClientFactory.open();
final Client client = cluster.connect();
// assert ConfigurationManagementGraph is bound
assertEquals(0, client.submit("ConfigurationManagementGraph.vertices().size()").all().get().get(0).getInt());
// assert new graph is not bound
ExecutionException executionException = assertThrows(ExecutionException.class, () -> {
client.submit("newGraph").all().get();
});
assertEquals("org.apache.tinkerpop.gremlin.driver.exception.ResponseException: No such property: newGraph for class: Script3", executionException.getMessage());
}
Aggregations