mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '1.3.x'
This commit is contained in:
commit
277ceb7425
@ -140,6 +140,8 @@ public class DevToolsDataSourceAutoConfiguration {
|
||||
BeanDefinition dataSourceDefinition = context.getRegistry()
|
||||
.getBeanDefinition(dataSourceBeanNames[0]);
|
||||
if (dataSourceDefinition instanceof AnnotatedBeanDefinition
|
||||
&& ((AnnotatedBeanDefinition) dataSourceDefinition)
|
||||
.getFactoryMethodMetadata() != null
|
||||
&& ((AnnotatedBeanDefinition) dataSourceDefinition)
|
||||
.getFactoryMethodMetadata().getDeclaringClassName()
|
||||
.startsWith(DataSourceAutoConfiguration.class.getPackage()
|
||||
|
@ -26,6 +26,7 @@ import javax.sql.DataSource;
|
||||
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;
|
||||
@ -72,6 +73,20 @@ public abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyFactoryMethodMetadataIgnored() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
DataSource dataSource = mock(DataSource.class);
|
||||
AnnotatedGenericBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(
|
||||
dataSource.getClass());
|
||||
context.registerBeanDefinition("dataSource", beanDefinition);
|
||||
context.register(DataSourcePropertiesConfiguration.class);
|
||||
context.register(DevToolsDataSourceAutoConfiguration.class);
|
||||
context.refresh();
|
||||
context.close();
|
||||
}
|
||||
|
||||
protected final Statement configureDataSourceBehaviour(DataSource dataSource)
|
||||
throws SQLException {
|
||||
Connection connection = mock(Connection.class);
|
||||
|
Loading…
Reference in New Issue
Block a user