Search in sources :

Example 11 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class FlywayMediumTest method outOfOrder.

@Test
public void outOfOrder() {
    DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_out_of_order;DB_CLOSE_DELAY=-1", "sa", "", null);
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setLocations("migration/sql");
    flyway.setTarget(MigrationVersion.fromVersion("1.2"));
    assertEquals(4, flyway.info().all().length);
    assertEquals(3, flyway.info().pending().length);
    flyway.clean();
    assertEquals(3, flyway.migrate());
    assertEquals("1.2", flyway.info().current().getVersion().getVersion());
    assertEquals(0, flyway.info().pending().length);
    flyway.setTarget(MigrationVersion.LATEST);
    assertEquals(1, flyway.migrate());
    assertEquals("2.0", flyway.info().current().getVersion().getVersion());
    flyway.setLocations("migration/sql", "migration/outoforder");
    assertEquals(5, flyway.info().all().length);
    assertEquals(MigrationState.IGNORED, flyway.info().all()[2].getState());
    flyway.setValidateOnMigrate(false);
    assertEquals(0, flyway.migrate());
    flyway.setValidateOnMigrate(true);
    flyway.setOutOfOrder(true);
    assertEquals(MigrationState.PENDING, flyway.info().all()[4].getState());
    assertEquals(1, flyway.migrate());
    assertEquals("2.0", flyway.info().current().getVersion().getVersion());
    MigrationInfo[] all = flyway.info().all();
    assertEquals(MigrationState.SUCCESS, all[3].getState());
    assertEquals(MigrationState.OUT_OF_ORDER, all[4].getState());
}
Also used : MigrationInfo(org.flywaydb.core.api.MigrationInfo) DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Test(org.junit.Test)

Example 12 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class FlywayMediumTest method infoPending.

@Test
public void infoPending() throws Exception {
    DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_info_pending;DB_CLOSE_DELAY=-1", "sa", null, null);
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    assertEquals(2, flyway.info().pending().length);
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Test(org.junit.Test)

Example 13 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class FlywayMediumTest method noDescription.

@Test
public void noDescription() throws Exception {
    DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_no_description;DB_CLOSE_DELAY=-1", "sa", "", null, "SET AUTOCOMMIT OFF");
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setSqlMigrationSeparator(".sql");
    flyway.setSqlMigrationSuffix("");
    flyway.setLocations("migration/no_description");
    flyway.migrate();
    MigrationInfo current = flyway.info().current();
    assertEquals("1.1", current.getVersion().toString());
    assertEquals(MigrationState.SUCCESS, current.getState());
}
Also used : MigrationInfo(org.flywaydb.core.api.MigrationInfo) DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Test(org.junit.Test)

Example 14 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class FlywayMediumTest method baselineAgainWithDifferentVersion.

@Test(expected = FlywayException.class)
public void baselineAgainWithDifferentVersion() throws Exception {
    DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_init_different;DB_CLOSE_DELAY=-1", "sa", "", null);
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.baseline();
    flyway.setBaselineVersionAsString("2");
    flyway.baseline();
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Test(org.junit.Test)

Example 15 with DriverDataSource

use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.

the class FlywayMediumTest method cleanUnknownSchema.

@Test
public void cleanUnknownSchema() throws Exception {
    DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_clean_unknown;DB_CLOSE_DELAY=-1", "sa", "", null);
    Flyway flyway = new Flyway();
    flyway.setDataSource(dataSource);
    flyway.setSchemas("new1");
    flyway.clean();
    flyway.clean();
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Test(org.junit.Test)

Aggregations

DriverDataSource (org.flywaydb.core.internal.util.jdbc.DriverDataSource)45 Test (org.junit.Test)29 Properties (java.util.Properties)11 File (java.io.File)6 FileInputStream (java.io.FileInputStream)6 Connection (java.sql.Connection)6 Flyway (org.flywaydb.core.Flyway)6 MigrationInfo (org.flywaydb.core.api.MigrationInfo)5 SQLException (java.sql.SQLException)4 Statement (java.sql.Statement)4 FlywayException (org.flywaydb.core.api.FlywayException)4 DataSource (javax.sql.DataSource)3 HashMap (java.util.HashMap)2 JdbcTemplate (org.flywaydb.core.internal.dbsupport.JdbcTemplate)2 Before (org.junit.Before)2 LocalRdbmsServiceTestConfig (com.google.appengine.tools.development.testing.LocalRdbmsServiceTestConfig)1 LocalServiceTestHelper (com.google.appengine.tools.development.testing.LocalServiceTestHelper)1 PrintWriter (java.io.PrintWriter)1 Map (java.util.Map)1 HBaseTestingUtility (org.apache.hadoop.hbase.HBaseTestingUtility)1