Skip to content

Commit 5dc2339

Browse files
committed
Polish "Consider properties from @AutoConfigureTestDatabase"
See gh-16814
1 parent 92256c8 commit 5dc2339

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.flywaydb.core.api.callback.Context;
3131
import org.flywaydb.core.api.callback.Event;
3232
import org.flywaydb.core.api.callback.FlywayCallback;
33-
import org.flywaydb.core.internal.jdbc.DriverDataSource;
3433
import org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform;
3534
import org.junit.Test;
3635
import org.mockito.InOrder;
@@ -105,11 +104,10 @@ public void createDataSourceFallbackToEmbeddedProperties() {
105104
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
106105
.withPropertyValues("spring.flyway.url:jdbc:hsqldb:mem:flywaytest").run((context) -> {
107106
assertThat(context).hasSingleBean(Flyway.class);
108-
assertThat(context.getBean(Flyway.class).getDataSource()).isNotNull();
109-
assertThat(((DriverDataSource) context.getBean(Flyway.class).getDataSource()).getUser())
110-
.isEqualTo("sa");
111-
assertThat(((DriverDataSource) context.getBean(Flyway.class).getDataSource()).getPassword())
112-
.isEqualTo("");
107+
DataSource dataSource = context.getBean(Flyway.class).getDataSource();
108+
assertThat(dataSource).isNotNull();
109+
assertThat(dataSource).hasFieldOrPropertyWithValue("user", "sa");
110+
assertThat(dataSource).hasFieldOrPropertyWithValue("password", "");
113111
});
114112
}
115113

@@ -118,9 +116,9 @@ public void createDataSourceWithUserAndFallbackToEmbeddedProperties() {
118116
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
119117
.withPropertyValues("spring.flyway.user:sa").run((context) -> {
120118
assertThat(context).hasSingleBean(Flyway.class);
121-
assertThat(context.getBean(Flyway.class).getDataSource()).isNotNull();
122-
assertThat(((DriverDataSource) context.getBean(Flyway.class).getDataSource()).getUrl())
123-
.startsWith("jdbc:h2:mem:");
119+
DataSource dataSource = context.getBean(Flyway.class).getDataSource();
120+
assertThat(dataSource).isNotNull();
121+
assertThat(dataSource).extracting("url").hasSize(1).first().asString().startsWith("jdbc:h2:mem:");
124122
});
125123
}
126124

src/checkstyle/checkstyle-suppressions.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@
3535
<suppress files="LogbackMetricsAutoConfiguration\.java" checks="IllegalImport" />
3636
<suppress files="RemoteUrlPropertyExtractorTests\.java" checks="IllegalImport" />
3737
<suppress files="SampleLogbackApplication\.java" checks="IllegalImport" />
38-
<suppress files="FlywayAutoConfigurationTests\.java" checks="IllegalImport" />
3938
</suppressions>

0 commit comments

Comments
 (0)