use of org.h2.Driver in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method simple.
@Test
public void simple() {
Driver adam = GremlinDatabase.driver("//localhost:" + server.getPort());
try (Session session = adam.session()) {
StatementResult result = session.run("MATCH (n:person) RETURN count(n) as count");
int count = result.single().get("count").asInt();
assertThat(count).isEqualTo(4);
}
}
use of org.h2.Driver in project cypher-for-gremlin by opencypher.
the class GremlinNeo4jDriverTest method multipleRows.
@Test
public void multipleRows() {
Cluster cluster = Cluster.build().addContactPoints("localhost").port(server.getPort()).create();
Driver driver = GremlinDatabase.driver(cluster);
try (Session session = driver.session()) {
StatementResult result = session.run("MATCH (p:person) RETURN p.name, p.age");
List<String> rows = result.list(r -> r.get("p.name").asString() + r.get("p.age").asInt());
assertThat(rows).containsExactly("marko29", "vadas27", "josh32", "peter35");
}
}
use of org.h2.Driver in project cypher-for-gremlin by opencypher.
the class CypherGremlinNeo4jDriver method createUseDriver.
@Test
public void createUseDriver() throws Exception {
int port = gremlinServer.getPort();
// freshReadmeSnippet: createConfiguration
Config config = Config.build().withTranslation().toConfig();
String uri = "//localhost:" + port;
Driver driver = GremlinDatabase.driver(uri, config);
// freshReadmeSnippet: useDriver
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");
}
// freshReadmeSnippet: useDriver
}
use of org.h2.Driver in project open-kilda by telstra.
the class PathComputerTest method testGetFlowInfo.
@Test
public void testGetFlowInfo() {
try (Transaction tx = graphDb.beginTx()) {
Node node1, node2;
node1 = graphDb.createNode(Label.label("switch"));
node1.setProperty("name", "00:03");
node2 = graphDb.createNode(Label.label("switch"));
node2.setProperty("name", "00:04");
Relationship rel1 = node1.createRelationshipTo(node2, RelationshipType.withName("flow"));
rel1.setProperty("flowid", "f1");
rel1.setProperty("cookie", 3);
rel1.setProperty("meter_id", 2);
rel1.setProperty("transit_vlan", 1);
rel1.setProperty("src_switch", "00:03");
tx.success();
}
Driver driver = GraphDatabase.driver("bolt://localhost:7878", AuthTokens.basic("neo4j", "password"));
NeoDriver nd = new NeoDriver(driver);
List<FlowInfo> fi = nd.getFlowInfo();
Assert.assertEquals(fi.get(0).getFlowId(), "f1");
Assert.assertEquals(fi.get(0).getCookie(), 3);
Assert.assertEquals(fi.get(0).getMeterId(), 2);
Assert.assertEquals(fi.get(0).getTransitVlanId(), 1);
Assert.assertEquals(fi.get(0).getSrcSwitchId(), "00:03");
}
use of org.h2.Driver in project sql2o by aaberg.
the class H2Tests method setUp.
@Before
public void setUp() throws Exception {
driverClassName = "org.h2.Driver";
url = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1";
user = "sa";
pass = "";
org.h2.jdbcx.JdbcDataSource datasource = new org.h2.jdbcx.JdbcDataSource();
datasource.setURL(url);
datasource.setUser(user);
datasource.setPassword(pass);
ds = datasource;
}
Aggregations