|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2019 the original author or authors. |
| 2 | + * Copyright 2012-2020 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
74 | 74 | * @author Stephane Nicoll
|
75 | 75 | * @author Dominic Gunn
|
76 | 76 | * @author András Deák
|
| 77 | + * @author Takaaki Shimbo |
77 | 78 | */
|
78 | 79 | class FlywayAutoConfigurationTests {
|
79 | 80 |
|
@@ -158,6 +159,15 @@ void flywayDataSourceWithoutDataSourceAutoConfiguration() {
|
158 | 159 | });
|
159 | 160 | }
|
160 | 161 |
|
| 162 | + @Test |
| 163 | + void flywayMultipleDataSources() { |
| 164 | + this.contextRunner.withUserConfiguration(FlywayMultipleDataSourcesConfiguration.class).run((context) -> { |
| 165 | + assertThat(context).hasSingleBean(Flyway.class); |
| 166 | + assertThat(context.getBean(Flyway.class).getConfiguration().getDataSource()) |
| 167 | + .isEqualTo(context.getBean("flywayDataSource")); |
| 168 | + }); |
| 169 | + } |
| 170 | + |
161 | 171 | @Test
|
162 | 172 | void schemaManagementProviderDetectsDataSource() {
|
163 | 173 | this.contextRunner
|
@@ -509,6 +519,27 @@ DataSource flywayDataSource() {
|
509 | 519 |
|
510 | 520 | }
|
511 | 521 |
|
| 522 | + @Configuration(proxyBeanMethods = false) |
| 523 | + static class FlywayMultipleDataSourcesConfiguration { |
| 524 | + |
| 525 | + @Bean |
| 526 | + DataSource firstDataSource() { |
| 527 | + return DataSourceBuilder.create().url("jdbc:hsqldb:mem:first").username("sa").build(); |
| 528 | + } |
| 529 | + |
| 530 | + @Bean |
| 531 | + DataSource secondDataSource() { |
| 532 | + return DataSourceBuilder.create().url("jdbc:hsqldb:mem:second").username("sa").build(); |
| 533 | + } |
| 534 | + |
| 535 | + @FlywayDataSource |
| 536 | + @Bean |
| 537 | + DataSource flywayDataSource() { |
| 538 | + return DataSourceBuilder.create().url("jdbc:hsqldb:mem:flywaytest").username("sa").build(); |
| 539 | + } |
| 540 | + |
| 541 | + } |
| 542 | + |
512 | 543 | @Configuration(proxyBeanMethods = false)
|
513 | 544 | static class FlywayJavaMigrationsConfiguration {
|
514 | 545 |
|
|
0 commit comments