Search in sources :

Example 96 with Session

use of iaik.pkcs.pkcs11.Session in project cypher-for-gremlin by opencypher.

the class GremlinNeo4jDriverTest method translating.

@Test
public void translating() {
    Config config = Config.build().withTranslation(TranslatorFlavor.gremlinServer()).toConfig();
    Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort(), config);
    try (Session session = driver.session()) {
        StatementResult result = session.run("MATCH (n:person) RETURN count(n) as count");
        int count = result.single().get("count").asInt();
        assertThat(count).isEqualTo(4);
    }
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) Config(org.opencypher.Config) Driver(org.neo4j.driver.v1.Driver) Session(org.neo4j.driver.v1.Session) Test(org.junit.Test)

Example 97 with Session

use of iaik.pkcs.pkcs11.Session in project cypher-for-gremlin by opencypher.

the class GremlinNeo4jDriverTest method withParameter.

@Test
public void withParameter() {
    Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort());
    try (Session session = driver.session()) {
        StatementResult result = session.run("CREATE (a:Greeting) " + "SET a.message = $message " + "RETURN a.message", parameters("message", "Hello"));
        String message = result.single().get(0).asString();
        assertThat(message).isEqualTo("Hello");
    }
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) Driver(org.neo4j.driver.v1.Driver) Session(org.neo4j.driver.v1.Session) Test(org.junit.Test)

Example 98 with Session

use of iaik.pkcs.pkcs11.Session in project cypher-for-gremlin by opencypher.

the class GremlinNeo4jDriverTest method returnNodeAndRelationship.

@Test
public void returnNodeAndRelationship() {
    Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort());
    try (Session session = driver.session()) {
        StatementResult result = session.run("CREATE (n1:Person {name: 'Marko'})-[r:knows {since:1999}]->(n2:Person)" + "RETURN n1,r,n2", parameters("message", "Hello"));
        Record record = result.single();
        Node n1 = record.get("n1").asNode();
        Relationship r = record.get("r").asRelationship();
        Node n2 = record.get("n2").asNode();
        assertThat(n1.hasLabel("Person")).isTrue();
        assertThat(n1.get("name").asString()).isEqualTo("Marko");
        assertThat(r.hasType("knows")).isTrue();
        assertThat(r.startNodeId()).isEqualTo(n1.id());
        assertThat(r.endNodeId()).isEqualTo(n2.id());
        assertThat(r.get("since").asLong()).isEqualTo(1999L);
        assertThat(n2.hasLabel("Person")).isTrue();
    }
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) Node(org.neo4j.driver.v1.types.Node) Relationship(org.neo4j.driver.v1.types.Relationship) Driver(org.neo4j.driver.v1.Driver) Record(org.neo4j.driver.v1.Record) Session(org.neo4j.driver.v1.Session) Test(org.junit.Test)

Example 99 with Session

use of iaik.pkcs.pkcs11.Session in project cypher-for-gremlin by opencypher.

the class GremlinNeo4jDriverTest method withMultipleParameters.

@Test
public void withMultipleParameters() {
    Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort());
    Map<String, Object> properties = new HashMap<>();
    properties.put("p1", 1L);
    properties.put("p2", 2L);
    try (Session session = driver.session()) {
        StatementResult result = session.run("CREATE (a:Greeting) " + "SET a.p1 = $p1, " + "a.p2 = $p2 " + "RETURN a.p1, a.p2", properties);
        Record record = result.single();
        assertThat(record.get("a.p1").asLong()).isEqualTo(1L);
        assertThat(record.get("a.p2").asLong()).isEqualTo(2L);
    }
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) HashMap(java.util.HashMap) Driver(org.neo4j.driver.v1.Driver) Record(org.neo4j.driver.v1.Record) Session(org.neo4j.driver.v1.Session) Test(org.junit.Test)

Example 100 with Session

use of iaik.pkcs.pkcs11.Session in project cypher-for-gremlin by opencypher.

the class GremlinNeo4jDriverTest method invalidSyntax.

@Test
public void invalidSyntax() {
    Driver driver = GremlinDatabase.driver("//localhost:" + server.getPort());
    try (Session session = driver.session()) {
        StatementResult result = session.run("INVALID");
        Throwable throwable = catchThrowable(result::list);
        assertThat(throwable).hasMessageContaining("Invalid input");
    }
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) Driver(org.neo4j.driver.v1.Driver) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) Session(org.neo4j.driver.v1.Session) Test(org.junit.Test)

Aggregations

Session (com.trilead.ssh2.Session)42 Session (org.neo4j.driver.v1.Session)38 Connection (com.trilead.ssh2.Connection)32 IOException (java.io.IOException)29 Test (org.junit.Test)29 InputStream (java.io.InputStream)27 Driver (org.neo4j.driver.v1.Driver)27 StatementResult (org.neo4j.driver.v1.StatementResult)20 TokenException (iaik.pkcs.pkcs11.TokenException)15 P11TokenException (org.xipki.security.exception.P11TokenException)15 Record (org.neo4j.driver.v1.Record)12 Session (iaik.pkcs.pkcs11.Session)10 SecretKey (iaik.pkcs.pkcs11.objects.SecretKey)10 ValuedSecretKey (iaik.pkcs.pkcs11.objects.ValuedSecretKey)10 DSAPrivateKey (iaik.pkcs.pkcs11.objects.DSAPrivateKey)9 ECPrivateKey (iaik.pkcs.pkcs11.objects.ECPrivateKey)9 PrivateKey (iaik.pkcs.pkcs11.objects.PrivateKey)9 RSAPrivateKey (iaik.pkcs.pkcs11.objects.RSAPrivateKey)9 SM2PrivateKey (iaik.pkcs.pkcs11.objects.SM2PrivateKey)9 CoreClusterMember (org.neo4j.causalclustering.discovery.CoreClusterMember)9