Skip to content

Commit c542d87

Browse files
committed
Verify that @FlywayDataSource is preferred over any "normal" DataSource
1 parent d41d732 commit c542d87

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
4242
import org.springframework.context.annotation.Bean;
4343
import org.springframework.context.annotation.Configuration;
44+
import org.springframework.context.annotation.Primary;
4445
import org.springframework.core.Ordered;
4546
import org.springframework.core.env.MapPropertySource;
4647
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
@@ -101,7 +102,8 @@ public void flywayDataSource() throws Exception {
101102
EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class,
102103
PropertyPlaceholderAutoConfiguration.class);
103104
Flyway flyway = this.context.getBean(Flyway.class);
104-
assertThat(flyway.getDataSource()).isNotNull();
105+
assertThat(flyway.getDataSource())
106+
.isEqualTo(this.context.getBean("flywayDataSource"));
105107
}
106108

107109
@Test
@@ -241,6 +243,13 @@ private void registerAndRefresh(Class<?>... annotatedClasses) {
241243
@Configuration
242244
protected static class FlywayDataSourceConfiguration {
243245

246+
@Bean
247+
@Primary
248+
public DataSource normalDataSource() {
249+
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:normal").username("sa")
250+
.build();
251+
}
252+
244253
@FlywayDataSource
245254
@Bean
246255
public DataSource flywayDataSource() {

0 commit comments

Comments
 (0)