use of org.flywaydb.core.api.callback.FlywayCallback in project flyway by flyway.
the class FlywayCallbackSmallTest method failingCallbackTest.
@Test(expected = IllegalStateException.class)
public void failingCallbackTest() {
FlywayCallback failingCallback = new BaseFlywayCallback() {
@Override
public void beforeMigrate(Connection connection) {
throw new IllegalStateException("Failing");
}
};
final Flyway flyway = new Flyway();
flyway.configure(createProperties("failing"));
flyway.setCallbacks(failingCallback);
assertNotNull(flyway.getDataSource());
flyway.migrate();
}
use of org.flywaydb.core.api.callback.FlywayCallback in project flyway by flyway.
the class FlywayCallbackSmallTest method baselineTest.
@Test
public void baselineTest() {
Properties properties = createProperties("baseline");
FlywayCallbackImpl callbackImpl = new FlywayCallbackImpl();
FlywayCallback[] callbacks = new FlywayCallback[] { callbackImpl };
final Flyway flyway = new Flyway();
flyway.configure(properties);
flyway.setCallbacks(callbacks);
assertNotNull(flyway.getDataSource());
assertFalse(callbackImpl.isBeforeBaseline());
assertFalse(callbackImpl.isAfterBaseline());
flyway.baseline();
assertFalse(callbackImpl.isBeforeClean());
assertFalse(callbackImpl.isAfterClean());
assertFalse(callbackImpl.isAfterEachMigrate());
assertFalse(callbackImpl.isAfterInfo());
assertTrue(callbackImpl.isAfterBaseline());
assertFalse(callbackImpl.isAfterMigrate());
assertFalse(callbackImpl.isAfterRepair());
assertFalse(callbackImpl.isAfterValidate());
assertFalse(callbackImpl.isBeforeEachMigrate());
assertFalse(callbackImpl.isBeforeInfo());
assertTrue(callbackImpl.isBeforeBaseline());
assertFalse(callbackImpl.isBeforeMigrate());
assertFalse(callbackImpl.isBeforeRepair());
assertFalse(callbackImpl.isBeforeValidate());
}
use of org.flywaydb.core.api.callback.FlywayCallback in project flyway by flyway.
the class FlywayCallbackSmallTest method repairTest.
@Test
public void repairTest() {
Properties properties = createProperties("repair");
FlywayCallbackImpl callbackImpl = new FlywayCallbackImpl();
FlywayCallback[] callbacks = new FlywayCallback[] { callbackImpl };
final Flyway flyway = new Flyway();
flyway.configure(properties);
flyway.setCallbacks(callbacks);
assertNotNull(flyway.getDataSource());
assertFalse(callbackImpl.isBeforeRepair());
assertFalse(callbackImpl.isAfterRepair());
flyway.repair();
assertFalse(callbackImpl.isBeforeClean());
assertFalse(callbackImpl.isAfterClean());
assertFalse(callbackImpl.isAfterEachMigrate());
assertFalse(callbackImpl.isAfterInfo());
assertFalse(callbackImpl.isAfterBaseline());
assertFalse(callbackImpl.isAfterMigrate());
assertTrue(callbackImpl.isAfterRepair());
assertFalse(callbackImpl.isAfterValidate());
assertFalse(callbackImpl.isBeforeEachMigrate());
assertFalse(callbackImpl.isBeforeInfo());
assertFalse(callbackImpl.isBeforeBaseline());
assertFalse(callbackImpl.isBeforeMigrate());
assertTrue(callbackImpl.isBeforeRepair());
assertFalse(callbackImpl.isBeforeValidate());
}
use of org.flywaydb.core.api.callback.FlywayCallback in project flyway by flyway.
the class FlywayCallbackSmallTest method infoTest.
@Test
public void infoTest() {
Properties properties = createProperties("info");
FlywayCallbackImpl callbackImpl = new FlywayCallbackImpl();
FlywayCallback[] callbacks = new FlywayCallback[] { callbackImpl };
final Flyway flyway = new Flyway();
flyway.configure(properties);
flyway.setCallbacks(callbacks);
assertNotNull(flyway.getDataSource());
assertFalse(callbackImpl.isBeforeInfo());
assertFalse(callbackImpl.isAfterInfo());
flyway.info();
assertFalse(callbackImpl.isBeforeClean());
assertFalse(callbackImpl.isAfterClean());
assertFalse(callbackImpl.isAfterEachMigrate());
assertTrue(callbackImpl.isAfterInfo());
assertFalse(callbackImpl.isAfterBaseline());
assertFalse(callbackImpl.isAfterMigrate());
assertFalse(callbackImpl.isAfterRepair());
assertFalse(callbackImpl.isAfterValidate());
assertFalse(callbackImpl.isBeforeEachMigrate());
assertTrue(callbackImpl.isBeforeInfo());
assertFalse(callbackImpl.isBeforeBaseline());
assertFalse(callbackImpl.isBeforeMigrate());
assertFalse(callbackImpl.isBeforeRepair());
assertFalse(callbackImpl.isBeforeValidate());
}
use of org.flywaydb.core.api.callback.FlywayCallback in project flyway by flyway.
the class FlywayCallbackSmallTest method migrateEachTest.
@Test
public void migrateEachTest() {
cleanTest();
Properties properties = createProperties("migrate_each");
FlywayCallbackImpl callbackImpl = new FlywayCallbackImpl();
FlywayCallback[] callbacks = new FlywayCallback[] { callbackImpl };
final Flyway flyway = new Flyway();
flyway.configure(properties);
flyway.setCallbacks(callbacks);
assertNotNull(flyway.getDataSource());
assertFalse(callbackImpl.isBeforeRepair());
assertFalse(callbackImpl.isAfterRepair());
flyway.migrate();
assertFalse(callbackImpl.isBeforeClean());
assertFalse(callbackImpl.isAfterClean());
assertTrue(callbackImpl.isAfterEachMigrate());
assertFalse(callbackImpl.isAfterInfo());
assertFalse(callbackImpl.isAfterBaseline());
assertTrue(callbackImpl.isAfterMigrate());
assertFalse(callbackImpl.isAfterRepair());
assertFalse(callbackImpl.isAfterValidate());
assertTrue(callbackImpl.isBeforeEachMigrate());
assertFalse(callbackImpl.isBeforeInfo());
assertFalse(callbackImpl.isBeforeBaseline());
assertTrue(callbackImpl.isBeforeMigrate());
assertFalse(callbackImpl.isBeforeRepair());
assertFalse(callbackImpl.isBeforeValidate());
}
Aggregations