From c542d87c61233e47758f069998ebd94da7b5e96e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 12 Aug 2016 13:17:09 +0100 Subject: [PATCH] Verify that @FlywayDataSource is preferred over any "normal" DataSource --- .../flyway/FlywayAutoConfigurationTests.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java index 1420e5c4cc..6890bf20a9 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfigurationTests.java @@ -41,6 +41,7 @@ import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import org.springframework.core.Ordered; import org.springframework.core.env.MapPropertySource; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; @@ -101,7 +102,8 @@ public class FlywayAutoConfigurationTests { EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); Flyway flyway = this.context.getBean(Flyway.class); - assertThat(flyway.getDataSource()).isNotNull(); + assertThat(flyway.getDataSource()) + .isEqualTo(this.context.getBean("flywayDataSource")); } @Test @@ -241,6 +243,13 @@ public class FlywayAutoConfigurationTests { @Configuration protected static class FlywayDataSourceConfiguration { + @Bean + @Primary + public DataSource normalDataSource() { + return DataSourceBuilder.create().url("jdbc:hsqldb:mem:normal").username("sa") + .build(); + } + @FlywayDataSource @Bean public DataSource flywayDataSource() {