Make DataJpaTestSchemaCredentialsIntegrationTests create the schema

Closes gh-26106
pull/27537/head
Andy Wilkinson 3 years ago
parent f91604eb72
commit 0326fa47b7

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,7 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; 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; import static org.assertj.core.api.Assertions.assertThat;
@ -31,9 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
@DataJpaTest @DataJpaTest(properties = { "spring.datasource.schema-username=alice", "spring.datasource.schema-password=secret",
@TestPropertySource( "spring.datasource.schema=classpath:org/springframework/boot/test/autoconfigure/orm/jpa/schema.sql" })
properties = { "spring.datasource.schema-username=alice", "spring.datasource.schema-password=secret" })
class DataJpaTestSchemaCredentialsIntegrationTests { class DataJpaTestSchemaCredentialsIntegrationTests {
@Autowired @Autowired
@ -43,6 +42,8 @@ class DataJpaTestSchemaCredentialsIntegrationTests {
void replacesDefinedDataSourceWithEmbeddedDefault() throws Exception { void replacesDefinedDataSourceWithEmbeddedDefault() throws Exception {
String product = this.dataSource.getConnection().getMetaData().getDatabaseProductName(); String product = this.dataSource.getConnection().getMetaData().getDatabaseProductName();
assertThat(product).isEqualTo("H2"); assertThat(product).isEqualTo("H2");
assertThat(new JdbcTemplate(this.dataSource).queryForList("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES",
String.class)).contains("EXAMPLE");
} }
} }

Loading…
Cancel
Save