diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java index 28e8c0a497..acef5aefb1 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestSchemaCredentialsIntegrationTests.java @@ -21,7 +21,7 @@ import javax.sql.DataSource; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.TestPropertySource; +import org.springframework.jdbc.core.JdbcTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -31,8 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Andy Wilkinson */ -@DataJpaTest -@TestPropertySource(properties = { "spring.sql.init.username=alice", "spring.sql.init.password=secret" }) +@DataJpaTest(properties = { "spring.sql.init.username=alice", "spring.sql.init.password=secret", + "spring.sql.init.schema-locations=classpath:org/springframework/boot/test/autoconfigure/orm/jpa/schema.sql" }) class DataJpaTestSchemaCredentialsIntegrationTests { @Autowired @@ -42,6 +42,8 @@ class DataJpaTestSchemaCredentialsIntegrationTests { void replacesDefinedDataSourceWithEmbeddedDefault() throws Exception { String product = this.dataSource.getConnection().getMetaData().getDatabaseProductName(); assertThat(product).isEqualTo("H2"); + assertThat(new JdbcTemplate(this.dataSource).queryForList("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES", + String.class)).contains("EXAMPLE"); } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/orm/jpa/schema.sql b/spring-boot-project/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/orm/jpa/schema.sql new file mode 100644 index 0000000000..e22c8c94cc --- /dev/null +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/resources/org/springframework/boot/test/autoconfigure/orm/jpa/schema.sql @@ -0,0 +1 @@ +CREATE TABLE example(identifier INT, name varchar(64));