Search in sources :

Example 6 with Client

use of org.apache.tinkerpop.gremlin.driver.Client 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();
}
Also used : GraphTraversalSource(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource) Cluster(org.apache.tinkerpop.gremlin.driver.Cluster) Client(org.apache.tinkerpop.gremlin.driver.Client) Test(org.junit.jupiter.api.Test)

Example 7 with Client

use of org.apache.tinkerpop.gremlin.driver.Client 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());
}
Also used : Cluster(org.apache.tinkerpop.gremlin.driver.Cluster) Client(org.apache.tinkerpop.gremlin.driver.Client) Test(org.junit.jupiter.api.Test)

Example 8 with Client

use of org.apache.tinkerpop.gremlin.driver.Client 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());
}
Also used : Cluster(org.apache.tinkerpop.gremlin.driver.Cluster) Client(org.apache.tinkerpop.gremlin.driver.Client) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.jupiter.api.Test)

Example 9 with Client

use of org.apache.tinkerpop.gremlin.driver.Client in project janusgraph by JanusGraph.

the class JanusGraphChannelizerTest method bindingShouldExistAfterGraphIsCreated.

@Test
public void bindingShouldExistAfterGraphIsCreated() throws Exception {
    final Cluster cluster = TestClientFactory.open();
    final Client client = cluster.connect();
    try {
        // assert server is running correctly
        assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
        // assert ConfigurationManagementGraph is bound
        assertEquals(0, client.submit("ConfigurationManagementGraph.vertices().size()").all().get().get(0).getInt());
        // assert new graph is not bound
        thrown.expect(ExecutionException.class);
        thrown.expectMessage(equalTo("org.apache.tinkerpop.gremlin.driver.exception.ResponseException: No such property: " + "newGraph for class: Script3"));
        client.submit("newGraph").all().get();
        // create newGraph
        client.submit("Map<String, Object> map = new HashMap<String, Object>(); map.put(\"storage.backend\", \"inmemory\"); " + "org.janusgraph.core.ConfiguredGraphFactory.createTemplateConfiguration(new MapConfiguration(map));" + "org.janusgraph.core.ConfiguredGraphFactory.create(\"newGraph\")");
        // 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());
    } finally {
        cluster.close();
    }
}
Also used : Cluster(org.apache.tinkerpop.gremlin.driver.Cluster) Client(org.apache.tinkerpop.gremlin.driver.Client) Test(org.junit.Test)

Example 10 with Client

use of org.apache.tinkerpop.gremlin.driver.Client in project cypher-for-gremlin by opencypher.

the class BytecodeCypherGremlinClientTest method setUp.

@Before
public void setUp() {
    Client aliasedClient = gremlinServer.gremlinClient().alias("g");
    client = new BytecodeCypherGremlinClient(aliasedClient, TranslatorFlavor.gremlinServer());
}
Also used : Client(org.apache.tinkerpop.gremlin.driver.Client) Before(org.junit.Before)

Aggregations

Client (org.apache.tinkerpop.gremlin.driver.Client)14 Cluster (org.apache.tinkerpop.gremlin.driver.Cluster)7 Test (org.junit.Test)5 CypherGremlinClient (org.opencypher.gremlin.client.CypherGremlinClient)5 Test (org.junit.jupiter.api.Test)4 Map (java.util.Map)3 BaseConfiguration (org.apache.commons.configuration.BaseConfiguration)2 ExecutionException (java.util.concurrent.ExecutionException)1 GraphTraversalSource (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource)1 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1 Before (org.junit.Before)1 CypherResultSet (org.opencypher.gremlin.client.CypherResultSet)1