use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywayMediumTest method baselineRepair.
@Test
public void baselineRepair() throws Exception {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_baseline_repair;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setSchemas("new1");
flyway.setLocations("migration/sql");
flyway.setBaselineVersionAsString("2");
flyway.baseline();
assertEquals("2", flyway.info().current().getVersion().toString());
assertEquals(MigrationType.BASELINE, flyway.info().current().getType());
flyway.repair();
assertEquals("2", flyway.info().current().getVersion().toString());
assertEquals(MigrationType.BASELINE, flyway.info().current().getType());
flyway.migrate();
assertEquals("2", flyway.info().current().getVersion().toString());
assertEquals(MigrationType.BASELINE, flyway.info().current().getType());
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywayMediumTest method baselineAgainWithSameVersion.
@Test
public void baselineAgainWithSameVersion() throws Exception {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_init_same;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations("migration/sql");
flyway.setBaselineVersionAsString("0.5");
flyway.baseline();
flyway.baseline();
assertEquals(1, flyway.info().applied().length);
MigrationInfo current = flyway.info().current();
assertEquals("0.5", current.getVersion().toString());
assertEquals(MigrationType.BASELINE, current.getType());
assertEquals(MigrationState.BASELINE, current.getState());
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywayMediumTest method baselineAfterInit.
@Test
public void baselineAfterInit() throws Exception {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_baseline_init;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setSchemas("new1");
flyway.setLocations("migration/validate");
flyway.baseline();
new JdbcTemplate(dataSource.getConnection(), 0).executeStatement("UPDATE \"new1\".\"schema_version\" SET \"type\"='BASELINE' WHERE \"type\"='BASELINE'");
assertEquals("1", flyway.info().current().getVersion().toString());
assertEquals(MigrationType.BASELINE, flyway.info().current().getType());
flyway.baseline();
assertEquals("1", flyway.info().current().getVersion().toString());
assertEquals(MigrationType.BASELINE, flyway.info().current().getType());
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywayMediumTest method repeatableFailed.
@Test
public void repeatableFailed() {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_repeatable_failed;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations("migration/repeatable_failed");
try {
flyway.migrate();
fail();
} catch (FlywayException e) {
assertEquals(e.getMessage(), MigrationState.FAILED, flyway.info().current().getState());
}
try {
flyway.validate();
fail();
} catch (FlywayException e) {
assertTrue(e.getMessage(), e.getMessage().contains("failed repeatable migration"));
}
flyway.setLocations("migration/repeatable");
try {
flyway.migrate();
fail();
} catch (FlywayException e) {
assertTrue(e.getMessage(), e.getMessage().contains("failed repeatable migration"));
}
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywayMediumTest method cleanDisabled.
@Test(expected = FlywayException.class)
public void cleanDisabled() throws Exception {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_clean_disabled;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
try {
flyway.clean();
} catch (FlywayException e) {
fail("clean should succeed when cleanDisabled is false");
}
flyway.setCleanDisabled(true);
flyway.clean();
}
Aggregations