Skip to content

Commit

Permalink
Merge branch '1.3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Jun 1, 2016
2 parents a3f4b3c + 9bbdbae commit 277ceb7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public ConditionOutcome getMatchOutcome(ConditionContext context,
BeanDefinition dataSourceDefinition = context.getRegistry()
.getBeanDefinition(dataSourceBeanNames[0]);
if (dataSourceDefinition instanceof AnnotatedBeanDefinition
&& ((AnnotatedBeanDefinition) dataSourceDefinition)
.getFactoryMethodMetadata() != null
&& ((AnnotatedBeanDefinition) dataSourceDefinition)
.getFactoryMethodMetadata().getDeclaringClassName()
.startsWith(DataSourceAutoConfiguration.class.getPackage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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;
Expand Down Expand Up @@ -72,6 +73,20 @@ public void multipleDataSourcesAreIgnored() throws SQLException {
}
}

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

0 comments on commit 277ceb7

Please sign in to comment.