Gracefully handle exclusion of DataSourceAutoConfiguration
This commit makes sure that an auto-configuration that requires `DataSourceProperties` will not break if `DataSourceAutoConfiguration` has been explicitly excluded. Closes gh-12512
This commit is contained in:
@@ -28,8 +28,6 @@ import org.junit.Test;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.test.util.TestPropertyValues;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -53,7 +51,6 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
@Test
|
||||
public void singleManuallyConfiguredDataSourceIsNotClosed() throws SQLException {
|
||||
ConfigurableApplicationContext context = createContext(
|
||||
DataSourcePropertiesConfiguration.class,
|
||||
SingleDataSourceConfiguration.class);
|
||||
DataSource dataSource = context.getBean(DataSource.class);
|
||||
Statement statement = configureDataSourceBehavior(dataSource);
|
||||
@@ -63,7 +60,6 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
@Test
|
||||
public void multipleDataSourcesAreIgnored() throws SQLException {
|
||||
ConfigurableApplicationContext context = createContext(
|
||||
DataSourcePropertiesConfiguration.class,
|
||||
MultipleDataSourcesConfiguration.class);
|
||||
Collection<DataSource> dataSources = context.getBeansOfType(DataSource.class)
|
||||
.values();
|
||||
@@ -80,7 +76,6 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
AnnotatedGenericBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(
|
||||
dataSource.getClass());
|
||||
context.registerBeanDefinition("dataSource", beanDefinition);
|
||||
context.register(DataSourcePropertiesConfiguration.class);
|
||||
context.register(DevToolsDataSourceAutoConfiguration.class);
|
||||
context.refresh();
|
||||
context.close();
|
||||
@@ -146,12 +141,6 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(DataSourceProperties.class)
|
||||
static class DataSourcePropertiesConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class DataSourceSpyConfiguration {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user