Search in sources :

Example 1 with Location

use of org.flywaydb.core.api.Location in project flyway by flyway.

the class ClasspathClassScanner method scanForType.

public List<String> scanForType(String location, Class<?> classType, boolean errorOnNotFound) {
    ClassPathScanner<?> s = new ClassPathScanner<>(classType, classLoader, Charset.defaultCharset(), new Location("classpath:" + location), resourceNameCache, locationScannerCache, errorOnNotFound);
    List<String> discoveredTypes = new ArrayList<>();
    for (LoadableResource resource : s.scanForResources()) {
        if (resource.getAbsolutePath().endsWith(".class")) {
            discoveredTypes.add(toClassName(resource.getAbsolutePath()));
        }
    }
    return discoveredTypes;
}
Also used : ArrayList(java.util.ArrayList) LoadableResource(org.flywaydb.core.api.resource.LoadableResource) ClassPathScanner(org.flywaydb.core.internal.scanner.classpath.ClassPathScanner) Location(org.flywaydb.core.api.Location)

Example 2 with Location

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

the class Flyway7xAutoConfigurationTests method defaultFlyway.

@Test
void defaultFlyway() {
    this.contextRunner.withUserConfiguration(DataSourceAutoConfiguration.class).run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        assertThat(flyway.getConfiguration().getLocations()).containsExactly(new Location("classpath:db/migration"));
    });
}
Also used : Flyway(org.flywaydb.core.Flyway) DataSourceAutoConfiguration(org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration) Location(org.flywaydb.core.api.Location) Test(org.junit.jupiter.api.Test)

Example 3 with Location

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

the class FlywayAutoConfigurationTests method defaultFlyway.

@Test
void defaultFlyway() {
    this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        assertThat(flyway.getConfiguration().getLocations()).containsExactly(new Location("classpath:db/migration"));
    });
}
Also used : EmbeddedDataSourceConfiguration(org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration) Flyway(org.flywaydb.core.Flyway) Location(org.flywaydb.core.api.Location) Test(org.junit.jupiter.api.Test)

Example 4 with Location

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

the class FlywayAutoConfigurationTests method overrideLocationsList.

@Test
void overrideLocationsList() {
    this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).withPropertyValues("spring.flyway.locations[0]:classpath:db/changelog", "spring.flyway.locations[1]:classpath:db/migration").run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        assertThat(flyway.getConfiguration().getLocations()).containsExactly(new Location("classpath:db/changelog"), new Location("classpath:db/migration"));
    });
}
Also used : Flyway(org.flywaydb.core.Flyway) Location(org.flywaydb.core.api.Location) Test(org.junit.jupiter.api.Test)

Example 5 with Location

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

the class FlywayAutoConfigurationTests method overrideLocations.

@Test
void overrideLocations() {
    this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class).withPropertyValues("spring.flyway.locations:classpath:db/changelog,classpath:db/migration").run((context) -> {
        assertThat(context).hasSingleBean(Flyway.class);
        Flyway flyway = context.getBean(Flyway.class);
        assertThat(flyway.getConfiguration().getLocations()).containsExactly(new Location("classpath:db/changelog"), new Location("classpath:db/migration"));
    });
}
Also used : Flyway(org.flywaydb.core.Flyway) Location(org.flywaydb.core.api.Location) Test(org.junit.jupiter.api.Test)

Aggregations

Location (org.flywaydb.core.api.Location)11 Flyway (org.flywaydb.core.Flyway)8 Test (org.junit.jupiter.api.Test)8 DataSourceAutoConfiguration (org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration)3 ArrayList (java.util.ArrayList)2 ClassicConfiguration (org.flywaydb.core.api.configuration.ClassicConfiguration)1 LoadableResource (org.flywaydb.core.api.resource.LoadableResource)1 ClassPathScanner (org.flywaydb.core.internal.scanner.classpath.ClassPathScanner)1 EmbeddedDataSourceConfiguration (org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration)1 Bean (org.springframework.context.annotation.Bean)1 DependsOn (org.springframework.context.annotation.DependsOn)1 Profile (org.springframework.context.annotation.Profile)1