Merge branch '2.0.x'

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

View File

@@ -195,13 +195,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

@@ -189,7 +189,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()
@@ -226,6 +226,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,