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());
}
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);
}
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());
}
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();
}
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();
}
Aggregations