Remove ordering dependence from tests that create embedded databases

Closes gh-15423
pull/15438/head
Andy Wilkinson 6 years ago
parent 05cb4cb379
commit beffc4da9f

@ -75,7 +75,8 @@ public class JdbcRepositoriesAutoConfigurationTests {
EmbeddedDataSourceConfiguration.class)
.withPropertyValues(
"spring.datasource.schema=classpath:data-jdbc-schema.sql",
"spring.datasource.data=classpath:city.sql")
"spring.datasource.data=classpath:city.sql",
"spring.datasource.generate-unique-name:true")
.run((context) -> {
assertThat(context).hasSingleBean(JdbcConfiguration.class);
assertThat(context).hasSingleBean(CityRepository.class);
@ -107,7 +108,8 @@ public class JdbcRepositoriesAutoConfigurationTests {
EmbeddedDataSourceConfiguration.class)
.withPropertyValues(
"spring.datasource.schema=classpath:data-jdbc-schema.sql",
"spring.datasource.data=classpath:city.sql")
"spring.datasource.data=classpath:city.sql",
"spring.datasource.generate-unique-name:true")
.run((context) -> {
assertThat(context).hasSingleBean(JdbcConfiguration.class);
assertThat(context).hasSingleBean(CityRepository.class);

@ -20,6 +20,7 @@ import java.sql.Connection;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.sql.DataSource;
@ -93,7 +94,8 @@ public class FlywayAutoConfigurationTests {
@Test
public void createDataSourceWithUser() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.datasource.url:jdbc:hsqldb:mem:normal",
.withPropertyValues(
"spring.datasource.url:jdbc:hsqldb:mem:" + UUID.randomUUID(),
"spring.flyway.user:sa")
.run((context) -> {
assertThat(context).hasSingleBean(Flyway.class);

@ -205,14 +205,15 @@ public class LiquibaseAutoConfigurationTests {
@Test
public void overrideUser() {
String jdbcUrl = "jdbc:hsqldb:mem:normal";
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.datasource.url:jdbc:hsqldb:mem:normal",
.withPropertyValues("spring.datasource.url:" + jdbcUrl,
"spring.datasource.username:not-sa", "spring.liquibase.user:sa")
.run(assertLiquibase((liquibase) -> {
DataSource dataSource = liquibase.getDataSource();
assertThat(((HikariDataSource) dataSource).isClosed()).isTrue();
assertThat(((HikariDataSource) dataSource).getJdbcUrl())
.isEqualTo("jdbc:hsqldb:mem:normal");
.isEqualTo(jdbcUrl);
assertThat(((HikariDataSource) dataSource).getUsername())
.isEqualTo("sa");
}));

Loading…
Cancel
Save