Include SQL init auto-config in Data RDBC test slice
Closes gh-24741
This commit is contained in:
parent
05adf02a47
commit
9d0e1a2cb3
|
|
@ -67,6 +67,7 @@ org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\
|
|||
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.r2dbc.R2dbcTransactionManagerAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
|
||||
|
||||
# AutoConfigureDataRedis auto-configuration imports
|
||||
|
|
|
|||
|
|
@ -21,12 +21,7 @@ import org.junit.jupiter.api.Test;
|
|||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
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 static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -36,7 +31,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@DataR2dbcTest
|
||||
@DataR2dbcTest(
|
||||
properties = "spring.sql.init.schemaLocations=classpath:org/springframework/boot/test/autoconfigure/data/r2dbc/schema.sql")
|
||||
class DataR2dbcTestIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
|
|
@ -64,17 +60,4 @@ class DataR2dbcTestIntegrationTests {
|
|||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue