Search in sources :

Example 1 with Flyway

use of org.flywaydb.core.Flyway in project spring-boot by spring-projects.

the class FlywayAutoConfigurationTests method overrideLocationsList.

@Test
public void overrideLocationsList() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "flyway.locations[0]:classpath:db/changelog", "flyway.locations[1]:classpath:db/migration");
    registerAndRefresh(EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    Flyway flyway = this.context.getBean(Flyway.class);
    assertThat(flyway.getLocations()).containsExactly("classpath:db/changelog", "classpath:db/migration");
}
Also used : Flyway(org.flywaydb.core.Flyway) Test(org.junit.Test)

Example 2 with Flyway

use of org.flywaydb.core.Flyway in project spring-boot by spring-projects.

the class FlywayAutoConfigurationTests method overrideLocations.

@Test
public void overrideLocations() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "flyway.locations:classpath:db/changelog,classpath:db/migration");
    registerAndRefresh(EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    Flyway flyway = this.context.getBean(Flyway.class);
    assertThat(flyway.getLocations()).containsExactly("classpath:db/changelog", "classpath:db/migration");
}
Also used : Flyway(org.flywaydb.core.Flyway) Test(org.junit.Test)

Example 3 with Flyway

use of org.flywaydb.core.Flyway in project spring-boot by spring-projects.

the class FlywayAutoConfigurationTests method defaultFlyway.

@Test
public void defaultFlyway() throws Exception {
    registerAndRefresh(EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    Flyway flyway = this.context.getBean(Flyway.class);
    assertThat(flyway.getLocations()).containsExactly("classpath:db/migration");
}
Also used : Flyway(org.flywaydb.core.Flyway) Test(org.junit.Test)

Example 4 with Flyway

use of org.flywaydb.core.Flyway in project spring-boot by spring-projects.

the class FlywayAutoConfigurationTests method createDataSource.

@Test
public void createDataSource() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "flyway.url:jdbc:hsqldb:mem:flywaytest", "flyway.user:sa");
    registerAndRefresh(EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
    Flyway flyway = this.context.getBean(Flyway.class);
    assertThat(flyway.getDataSource()).isNotNull();
}
Also used : Flyway(org.flywaydb.core.Flyway) Test(org.junit.Test)

Example 5 with Flyway

use of org.flywaydb.core.Flyway in project spring-boot by spring-projects.

the class FlywayEndpoint method invoke.

@Override
public List<FlywayReport> invoke() {
    List<FlywayReport> reports = new ArrayList<>();
    for (Map.Entry<String, Flyway> entry : this.flyways.entrySet()) {
        List<FlywayMigration> migrations = new ArrayList<>();
        for (MigrationInfo info : entry.getValue().info().all()) {
            migrations.add(new FlywayMigration(info));
        }
        reports.add(new FlywayReport(entry.getKey(), migrations));
    }
    return reports;
}
Also used : Flyway(org.flywaydb.core.Flyway) MigrationInfo(org.flywaydb.core.api.MigrationInfo) ArrayList(java.util.ArrayList) FlywayReport(org.springframework.boot.actuate.endpoint.FlywayEndpoint.FlywayReport) Map(java.util.Map)

Aggregations

Flyway (org.flywaydb.core.Flyway)44 Test (org.junit.Test)26 Connection (java.sql.Connection)7 DriverDataSource (org.flywaydb.core.internal.util.jdbc.DriverDataSource)6 File (java.io.File)5 SQLException (java.sql.SQLException)5 Properties (java.util.Properties)5 DataSource (javax.sql.DataSource)5 MetricRegistry (com.codahale.metrics.MetricRegistry)4 Statement (java.sql.Statement)4 FlywayException (org.flywaydb.core.api.FlywayException)4 FileInputStream (java.io.FileInputStream)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 MavenProject (org.apache.maven.project.MavenProject)2 MigrationInfo (org.flywaydb.core.api.MigrationInfo)2 DbSupport (org.flywaydb.core.internal.dbsupport.DbSupport)2 Before (org.junit.Before)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1