Search in sources :

Example 1 with H2DbSupport

use of org.flywaydb.core.internal.dbsupport.h2.H2DbSupport in project flyway by flyway.

the class FlywayMediumTest method multipleSetDataSourceCalls.

@Test
public void multipleSetDataSourceCalls() throws Exception {
    DriverDataSource dataSource1 = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_1;DB_CLOSE_DELAY=-1", "sa", "", null);
    DriverDataSource dataSource2 = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_2;DB_CLOSE_DELAY=-1", "sa", "", null);
    Connection connection1 = dataSource1.getConnection();
    Connection connection2 = dataSource2.getConnection();
    Schema schema1 = new H2DbSupport(connection1).getSchema("PUBLIC");
    Schema schema2 = new H2DbSupport(connection2).getSchema("PUBLIC");
    assertTrue(schema1.empty());
    assertTrue(schema2.empty());
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource1);
    flyway.setDataSource(dataSource2);
    flyway.setLocations("migration/sql");
    flyway.migrate();
    assertTrue(schema1.empty());
    assertFalse(schema2.empty());
    connection1.close();
    connection2.close();
}
Also used : H2DbSupport(org.flywaydb.core.internal.dbsupport.h2.H2DbSupport) DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Schema(org.flywaydb.core.internal.dbsupport.Schema) Connection(java.sql.Connection) Test(org.junit.Test)

Aggregations

Connection (java.sql.Connection)1 Schema (org.flywaydb.core.internal.dbsupport.Schema)1 H2DbSupport (org.flywaydb.core.internal.dbsupport.h2.H2DbSupport)1 DriverDataSource (org.flywaydb.core.internal.util.jdbc.DriverDataSource)1 Test (org.junit.Test)1