Commit 1a9065f4 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '2.2.x'

Closes gh-20621
parents 34b71561 62f696d5
...@@ -125,7 +125,7 @@ public class FlywayAutoConfiguration { ...@@ -125,7 +125,7 @@ public class FlywayAutoConfiguration {
ObjectProvider<JavaMigration> javaMigrations, ObjectProvider<Callback> callbacks) { ObjectProvider<JavaMigration> javaMigrations, ObjectProvider<Callback> callbacks) {
FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader()); FluentConfiguration configuration = new FluentConfiguration(resourceLoader.getClassLoader());
DataSource dataSourceToMigrate = configureDataSource(configuration, properties, dataSourceProperties, DataSource dataSourceToMigrate = configureDataSource(configuration, properties, dataSourceProperties,
flywayDataSource.getIfAvailable(), dataSource.getIfAvailable()); flywayDataSource.getIfAvailable(), dataSource.getIfUnique());
checkLocationExists(dataSourceToMigrate, properties, resourceLoader); checkLocationExists(dataSourceToMigrate, properties, resourceLoader);
configureProperties(configuration, properties); configureProperties(configuration, properties);
List<Callback> orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList()); List<Callback> orderedCallbacks = callbacks.orderedStream().collect(Collectors.toList());
......
...@@ -77,6 +77,7 @@ import static org.mockito.Mockito.mock; ...@@ -77,6 +77,7 @@ import static org.mockito.Mockito.mock;
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Dominic Gunn * @author Dominic Gunn
* @author András Deák * @author András Deák
* @author Takaaki Shimbo
*/ */
@ExtendWith(OutputCaptureExtension.class) @ExtendWith(OutputCaptureExtension.class)
class FlywayAutoConfigurationTests { class FlywayAutoConfigurationTests {
...@@ -162,6 +163,15 @@ class FlywayAutoConfigurationTests { ...@@ -162,6 +163,15 @@ class FlywayAutoConfigurationTests {
}); });
} }
@Test
void flywayMultipleDataSources() {
this.contextRunner.withUserConfiguration(FlywayMultipleDataSourcesConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(Flyway.class);
assertThat(context.getBean(Flyway.class).getConfiguration().getDataSource())
.isEqualTo(context.getBean("flywayDataSource"));
});
}
@Test @Test
void schemaManagementProviderDetectsDataSource() { void schemaManagementProviderDetectsDataSource() {
this.contextRunner this.contextRunner
...@@ -509,6 +519,27 @@ class FlywayAutoConfigurationTests { ...@@ -509,6 +519,27 @@ class FlywayAutoConfigurationTests {
} }
@Configuration(proxyBeanMethods = false)
static class FlywayMultipleDataSourcesConfiguration {
@Bean
DataSource firstDataSource() {
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:first").username("sa").build();
}
@Bean
DataSource secondDataSource() {
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:second").username("sa").build();
}
@FlywayDataSource
@Bean
DataSource flywayDataSource() {
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:flywaytest").username("sa").build();
}
}
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
static class FlywayJavaMigrationsConfiguration { static class FlywayJavaMigrationsConfiguration {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment