Search in sources :

Example 11 with Client

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

the class CypherRemoteAcceptor method connect.

@Override
public Object connect(List<String> args) throws RemoteException {
    Object result = delegate.connect(args);
    Client gremlinClient = getField(delegate, "currentClient");
    Map<String, String> aliases = getField(delegate, "aliases");
    if (aliases != null) {
        gremlinClient = gremlinClient.alias(aliases);
    }
    client = configureClient(gremlinClient, args);
    return result;
}
Also used : CypherGremlinClient(org.opencypher.gremlin.client.CypherGremlinClient) Client(org.apache.tinkerpop.gremlin.driver.Client)

Example 12 with Client

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

the class CypherGremlinServerClient method translating.

@Test
public void translating() {
    BaseConfiguration configuration = new BaseConfiguration();
    configuration.setProperty("port", gremlinServer.getPort());
    configuration.setProperty("hosts", Arrays.asList("localhost"));
    Cluster cluster = Cluster.open(configuration);
    Client gremlinClient = cluster.connect();
    // freshReadmeSnippet: translating
    CypherGremlinClient cypherGremlinClient = CypherGremlinClient.translating(gremlinClient);
    // freshReadmeSnippet: translating
    List<Map<String, Object>> results = cypherGremlinClient.submit("MATCH (p:person) WHERE p.age > 25 RETURN p.name").all();
    assertThat(results).extracting("p.name").containsExactly("marko", "vadas", "josh", "peter");
}
Also used : BaseConfiguration(org.apache.commons.configuration.BaseConfiguration) Cluster(org.apache.tinkerpop.gremlin.driver.Cluster) CypherGremlinClient(org.opencypher.gremlin.client.CypherGremlinClient) CypherGremlinClient(org.opencypher.gremlin.client.CypherGremlinClient) Client(org.apache.tinkerpop.gremlin.driver.Client) Map(java.util.Map) Test(org.junit.Test)

Example 13 with Client

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

the class GremlinServerExternalResource method configuredGremlinClient.

private Client configuredGremlinClient() throws Exception {
    Client gremlinClient;
    String configPath = System.getProperty(GremlinClientFactory.TOKEN_CONFIG);
    if (!Strings.isNullOrEmpty(configPath)) {
        logger.info("Running tests using configuration " + configPath);
        gremlinClient = Cluster.open(configPath).connect();
        gremlinClient.submit(DROP_ALL).all().get();
        gremlinClient.submit(CREATE_MODERN).all().get();
    } else {
        logger.info("Running tests using embeded TinkerGraph");
        gremlinServer = tinkerGraph();
        gremlinServer.start();
        int port = gremlinServer.getPort();
        gremlinClient = GremlinClientFactory.create(port);
    }
    return gremlinClient;
}
Also used : CypherGremlinClient(org.opencypher.gremlin.client.CypherGremlinClient) Client(org.apache.tinkerpop.gremlin.driver.Client)

Example 14 with Client

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

the class ConfigurationManagementGraphServerTest method ensureServerIsRunningCorrectly.

@Test
public void ensureServerIsRunningCorrectly() throws Exception {
    final Cluster cluster = TestClientFactory.open();
    final Client client = cluster.connect();
    assertEquals(2, client.submit("1+1").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)

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