Search in sources :

Example 1 with Driver

use of org.neo4j.driver.v1.Driver in project sonarqube by SonarSource.

the class DdlUtilsTest method shouldCreateSchema_without_schema_migrations.

@Test
public void shouldCreateSchema_without_schema_migrations() throws SQLException {
    DriverManager.registerDriver(new Driver());
    try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:sonar_test2")) {
        try (Statement statement = connection.createStatement()) {
            statement.execute("create table schema_migrations (version varchar(255) not null)");
        }
        DdlUtils.createSchema(connection, "h2", false);
        verifySchemaMigrations(connection);
    }
}
Also used : Statement(java.sql.Statement) Connection(java.sql.Connection) Driver(org.h2.Driver) Test(org.junit.Test)

Example 2 with Driver

use of org.neo4j.driver.v1.Driver in project sonarqube by SonarSource.

the class DdlUtilsTest method shouldCreateSchema_with_schema_migrations.

@Test
public void shouldCreateSchema_with_schema_migrations() throws SQLException {
    DriverManager.registerDriver(new Driver());
    try (Connection connection = DriverManager.getConnection("jdbc:h2:mem:sonar_test")) {
        DdlUtils.createSchema(connection, "h2", true);
        int tableCount = countTables(connection);
        assertThat(tableCount).isGreaterThan(30);
        verifySchemaMigrations(connection);
    }
}
Also used : Connection(java.sql.Connection) Driver(org.h2.Driver) Test(org.junit.Test)

Example 3 with Driver

use of org.neo4j.driver.v1.Driver in project sonarqube by SonarSource.

the class EmbeddedDatabase method createDatabase.

private static void createDatabase(File dbHome, String user, String password) throws SQLException {
    String url = format("jdbc:h2:%s/sonar;USER=%s;PASSWORD=%s", dbHome.getAbsolutePath(), user, password);
    DriverManager.registerDriver(new Driver());
    DriverManager.getConnection(url).close();
}
Also used : Driver(org.h2.Driver)

Example 4 with Driver

use of org.neo4j.driver.v1.Driver in project sonarqube by SonarSource.

the class EmbeddedDatabaseTest method checkDbIsUp.

private void checkDbIsUp(int port, String user, String password) {
    try {
        String driverUrl = String.format("jdbc:h2:tcp://localhost:%d/sonar;USER=%s;PASSWORD=%s", port, user, password);
        DriverManager.registerDriver(new Driver());
        DriverManager.getConnection(driverUrl).close();
    } catch (Exception ex) {
        fail("Unable to connect after start");
    }
}
Also used : Driver(org.h2.Driver) IOException(java.io.IOException) ExpectedException(org.junit.rules.ExpectedException)

Example 5 with Driver

use of org.neo4j.driver.v1.Driver in project neo4j by neo4j.

the class ProcedureTest method calls_simplistic_procedure.

@Test
public void calls_simplistic_procedure() {
    try (Driver driver = GraphDatabase.driver(graphDb.boltURI(), configuration());
        Session session = driver.session()) {
        StatementResult result = session.run("CALL " + procedureNamespace + ".theAnswer()");
        assertThat(result.single().get("value").asLong()).isEqualTo(42L);
    }
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) Driver(org.neo4j.driver.v1.Driver) Session(org.neo4j.driver.v1.Session) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)19 Driver (org.neo4j.driver.v1.Driver)16 Session (org.neo4j.driver.v1.Session)16 CoreClusterMember (org.neo4j.causalclustering.discovery.CoreClusterMember)10 RoutingNetworkSession (org.neo4j.driver.internal.RoutingNetworkSession)9 Record (org.neo4j.driver.v1.Record)6 Driver (org.h2.Driver)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 Transaction (org.neo4j.driver.v1.Transaction)5 SessionExpiredException (org.neo4j.driver.v1.exceptions.SessionExpiredException)5 IOException (java.io.IOException)4 ConnectionFailureException (org.neo4j.driver.v1.exceptions.ConnectionFailureException)4 Connection (java.sql.Connection)3 Monitors (org.neo4j.kernel.monitoring.Monitors)3 RemoteException (java.rmi.RemoteException)2 Statement (java.sql.Statement)2 HashSet (java.util.HashSet)2 ReadReplica (org.neo4j.causalclustering.discovery.ReadReplica)2 BoltServerAddress (org.neo4j.driver.internal.net.BoltServerAddress)2 ClientException (org.neo4j.driver.v1.exceptions.ClientException)2