Search in sources :

Example 31 with DriverDataSource

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);
}
Also used : MigrationInfo(org.flywaydb.core.api.MigrationInfo) DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) MigrationVersion(org.flywaydb.core.api.MigrationVersion) Test(org.junit.Test)

Example 32 with DriverDataSource

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());
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Properties(java.util.Properties) DataSource(javax.sql.DataSource) DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Test(org.junit.Test)

Example 33 with DriverDataSource

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());
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Test(org.junit.Test)

Example 34 with DriverDataSource

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());
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) Test(org.junit.Test)

Example 35 with DriverDataSource

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 + "\"}");
}
Also used : DriverDataSource(org.flywaydb.core.internal.util.jdbc.DriverDataSource) FeatureDetector(org.flywaydb.core.internal.util.FeatureDetector) PrintWriter(java.io.PrintWriter)

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