Commit 9d0e1a2c authored by Andy Wilkinson's avatar Andy Wilkinson

Include SQL init auto-config in Data RDBC test slice

Closes gh-24741
parent 05adf02a
...@@ -67,6 +67,7 @@ org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\ ...@@ -67,6 +67,7 @@ org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\ org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration,\ org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration,\
org.springframework.boot.autoconfigure.r2dbc.R2dbcTransactionManagerAutoConfiguration,\ org.springframework.boot.autoconfigure.r2dbc.R2dbcTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
# AutoConfigureDataRedis auto-configuration imports # AutoConfigureDataRedis auto-configuration imports
......
...@@ -21,12 +21,7 @@ import org.junit.jupiter.api.Test; ...@@ -21,12 +21,7 @@ import org.junit.jupiter.api.Test;
import reactor.test.StepVerifier; import reactor.test.StepVerifier;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.r2dbc.connection.init.ResourceDatabasePopulator;
import org.springframework.r2dbc.core.DatabaseClient; import org.springframework.r2dbc.core.DatabaseClient;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -36,7 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -36,7 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Mark Paluch * @author Mark Paluch
*/ */
@DataR2dbcTest @DataR2dbcTest(
properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/test/autoconfigure/data/r2dbc/schema.sql")
class DataR2dbcTestIntegrationTests { class DataR2dbcTestIntegrationTests {
@Autowired @Autowired
...@@ -64,17 +60,4 @@ class DataR2dbcTestIntegrationTests { ...@@ -64,17 +60,4 @@ class DataR2dbcTestIntegrationTests {
assertThat(this.applicationContext.getBeanNamesForType(ExampleRepository.class)).isNotEmpty(); assertThat(this.applicationContext.getBeanNamesForType(ExampleRepository.class)).isNotEmpty();
} }
@TestConfiguration
static class DatabaseInitializationConfiguration {
@Autowired
void initializeDatabase(ConnectionFactory connectionFactory) {
ResourceLoader resourceLoader = new DefaultResourceLoader();
Resource[] scripts = new Resource[] { resourceLoader
.getResource("classpath:org/springframework/boot/test/autoconfigure/data/r2dbc/schema.sql") };
new ResourceDatabasePopulator(scripts).populate(connectionFactory).block();
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment