|
|
|
@ -40,11 +40,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
class AbstractDataSourceInitializerDependencyConfigurationTests {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void beanThatDependsOnDatabaseInitializationDependsOnAbstractDataSourceInitializerBeans() {
|
|
|
|
|
void beansThatDependOnDatabaseInitializationDependOnAbstractDataSourceInitializerBeans() {
|
|
|
|
|
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
|
|
|
|
TestConfiguration.class)) {
|
|
|
|
|
assertThat(context.getBeanFactory().getBeanDefinition("dependsOnDataSourceInitialization").getDependsOn())
|
|
|
|
|
.contains("initializer");
|
|
|
|
|
assertThat(context.getBeanFactory().getBeanDefinition("factoryMethodDependsOnDatabaseInitialization")
|
|
|
|
|
.getDependsOn()).contains("initializer");
|
|
|
|
|
assertThat(context.getBeanFactory().getBeanDefinition("beanClassDependsOnDatabaseInitialization")
|
|
|
|
|
.getDependsOn()).contains("initializer");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -59,10 +61,15 @@ class AbstractDataSourceInitializerDependencyConfigurationTests {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
@DependsOnDatabaseInitialization
|
|
|
|
|
String dependsOnDataSourceInitialization() {
|
|
|
|
|
String factoryMethodDependsOnDatabaseInitialization() {
|
|
|
|
|
return "test";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
DatabaseInitializationDependent beanClassDependsOnDatabaseInitialization() {
|
|
|
|
|
return new DatabaseInitializationDependent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
AbstractDataSourceInitializer initializer(DataSource dataSource, ResourceLoader resourceLoader) {
|
|
|
|
|
return new AbstractDataSourceInitializer(dataSource, resourceLoader) {
|
|
|
|
@ -82,4 +89,9 @@ class AbstractDataSourceInitializerDependencyConfigurationTests {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DependsOnDatabaseInitialization
|
|
|
|
|
static class DatabaseInitializationDependent {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|