use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywayMediumTest method outOfOrderInOrder.
@Test
public void outOfOrderInOrder() {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_out_of_order_in_order;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setLocations("migration/sql");
flyway.migrate();
MigrationVersion highest = null;
for (MigrationInfo migrationInfo : flyway.info().applied()) {
assertEquals(MigrationState.SUCCESS, migrationInfo.getState());
if (highest == null) {
highest = migrationInfo.getVersion();
} else {
assertTrue(migrationInfo.getVersion().compareTo(highest) > 0);
highest = migrationInfo.getVersion();
}
}
assertEquals(MigrationVersion.fromVersion("2.0"), highest);
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywaySmallTest method configureWithExistingDataSource.
@Test
public void configureWithExistingDataSource() {
DataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_test;DB_CLOSE_DELAY=-1", "sa", "", null);
Properties properties = new Properties();
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.configure(properties);
assertEquals(dataSource, flyway.getDataSource());
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywayMediumTest method infoBaseline.
@Test
public void infoBaseline() throws Exception {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_info_init;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.baseline();
flyway.setLocations();
assertEquals(1, flyway.info().all().length);
assertEquals("1", flyway.info().current().getVersion().toString());
assertEquals(MigrationState.BASELINE, flyway.info().current().getState());
}
use of org.flywaydb.core.internal.util.jdbc.DriverDataSource in project flyway by flyway.
the class FlywayMediumTest method baselineOnMigrateSkipFailed.
@Test
public void baselineOnMigrateSkipFailed() throws Exception {
DriverDataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, "jdbc:h2:mem:flyway_db_baseline_migrate_failed;DB_CLOSE_DELAY=-1", "sa", "", null);
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
flyway.setSchemas("new1");
flyway.setLocations("migration/sql");
flyway.setBaselineVersionAsString("3");
flyway.migrate();
assertEquals("2.0", flyway.info().current().getVersion().toString());
assertEquals(MigrationType.SQL, flyway.info().current().getType());
flyway.setTable("other_metadata");
flyway.setLocations("migration/failed");
flyway.setBaselineOnMigrate(true);
flyway.migrate();
assertEquals("3", 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 EnvInfoServlet method doGet.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String appserver;
if (Environment.runningOnGoogleAppEngine()) {
appserver = "Google AppEngine";
} else {
FeatureDetector featureDetector = new FeatureDetector(Thread.currentThread().getContextClassLoader());
if (featureDetector.isJBossVFSv2Available()) {
appserver = "JBoss 5";
} else if (featureDetector.isJBossVFSv3Available()) {
appserver = "JBoss 6+";
} else {
appserver = "Other";
}
}
String database = ((DriverDataSource) flyway.getDataSource()).getUrl();
PrintWriter writer = response.getWriter();
writer.print("{\"status\":\"OK\"," + " \"appserver\":\"" + appserver + "\"," + " \"database\":\"" + database + "\"}");
}
Aggregations