Merge branch '1.5.x' into 2.0.x

This commit is contained in:
Stephane Nicoll
2018-07-24 10:37:31 +02:00
3 changed files with 25 additions and 4 deletions

View File

@@ -176,13 +176,17 @@ public class FlywayAutoConfiguration {
private boolean hasAtLeastOneLocation(String... locations) {
for (String location : locations) {
if (this.resourceLoader.getResource(location).exists()) {
if (this.resourceLoader.getResource(normalizePrefix(location)).exists()) {
return true;
}
}
return false;
}
private String normalizePrefix(String location) {
return location.replace("filesystem:", "file:");
}
@Bean
@ConditionalOnMissingBean
public FlywayMigrationInitializer flywayInitializer(Flyway flyway) {

View File

@@ -181,7 +181,7 @@ public class FlywayAutoConfigurationTests {
@Test
public void changeLogDoesNotExist() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.flyway.locations:file:no-such-dir")
.withPropertyValues("spring.flyway.locations:filesystem:no-such-dir")
.run((context) -> {
assertThat(context).hasFailed();
assertThat(context).getFailure()
@@ -218,6 +218,14 @@ public class FlywayAutoConfigurationTests {
.run((context) -> assertThat(context).hasNotFailed());
}
@Test
public void checkLocationsAllExistWithFilesystemPrefix() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues(
"spring.flyway.locations:filesystem:src/test/resources/db/migration")
.run((context) -> assertThat(context).hasNotFailed());
}
@Test
public void customFlywayMigrationStrategy() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class,