Check factory method metadata to avoid NPE in devtools condition

Closes gh-6056
This commit is contained in:
Martin Lippert
2016-05-27 16:09:21 +02:00
committed by Andy Wilkinson
parent f3e9f1e6e3
commit efd541d26b
2 changed files with 17 additions and 0 deletions

View File

@@ -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 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);