Commit 48703494 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '1.5.x'

parents a2803f41 2be55445
...@@ -151,7 +151,7 @@ public class EndpointWebMvcChildContextConfiguration { ...@@ -151,7 +151,7 @@ public class EndpointWebMvcChildContextConfiguration {
@Configuration @Configuration
@ConditionalOnClass({ EnableWebSecurity.class, Filter.class }) @ConditionalOnClass({ EnableWebSecurity.class, Filter.class })
@ConditionalOnBean(name = "springSecurityFilterChain", search = SearchStrategy.PARENTS) @ConditionalOnBean(name = "springSecurityFilterChain", search = SearchStrategy.ANCESTORS)
public static class EndpointWebMvcChildContextSecurityConfiguration { public static class EndpointWebMvcChildContextSecurityConfiguration {
@Bean @Bean
......
...@@ -126,7 +126,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit ...@@ -126,7 +126,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit
private List<String> getMatchingBeans(ConditionContext context, private List<String> getMatchingBeans(ConditionContext context,
BeanSearchSpec beans) { BeanSearchSpec beans) {
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
if (beans.getStrategy() == SearchStrategy.PARENTS) { if (beans.getStrategy() == SearchStrategy.ANCESTORS) {
BeanFactory parent = beanFactory.getParentBeanFactory(); BeanFactory parent = beanFactory.getParentBeanFactory();
Assert.isInstanceOf(ConfigurableListableBeanFactory.class, parent, Assert.isInstanceOf(ConfigurableListableBeanFactory.class, parent,
"Unable to use SearchStrategy.PARENTS"); "Unable to use SearchStrategy.PARENTS");
......
...@@ -29,9 +29,9 @@ public enum SearchStrategy { ...@@ -29,9 +29,9 @@ public enum SearchStrategy {
CURRENT, CURRENT,
/** /**
* Search all parents and ancestors, but not the current context. * Search all ancestors, but not the current context.
*/ */
PARENTS, ANCESTORS,
/** /**
* Search the entire hierarchy. * Search the entire hierarchy.
......
...@@ -258,7 +258,7 @@ public class ConditionalOnMissingBeanTests { ...@@ -258,7 +258,7 @@ public class ConditionalOnMissingBeanTests {
} }
@Test @Test
public void grandparentIsConsideredWhenUsingParentsStrategy() { public void grandparentIsConsideredWhenUsingAncestorsStrategy() {
this.context.register(ExampleBeanConfiguration.class); this.context.register(ExampleBeanConfiguration.class);
this.context.refresh(); this.context.refresh();
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
...@@ -267,7 +267,7 @@ public class ConditionalOnMissingBeanTests { ...@@ -267,7 +267,7 @@ public class ConditionalOnMissingBeanTests {
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
child.setParent(parent); child.setParent(parent);
child.register(ExampleBeanConfiguration.class, child.register(ExampleBeanConfiguration.class,
OnBeanInParentsConfiguration.class); OnBeanInAncestorsConfiguration.class);
child.refresh(); child.refresh();
assertThat(child.getBeansOfType(ExampleBean.class)).hasSize(1); assertThat(child.getBeansOfType(ExampleBean.class)).hasSize(1);
child.close(); child.close();
...@@ -275,21 +275,21 @@ public class ConditionalOnMissingBeanTests { ...@@ -275,21 +275,21 @@ public class ConditionalOnMissingBeanTests {
} }
@Test @Test
public void currentContextIsIgnoredWhenUsingParentsStrategy() { public void currentContextIsIgnoredWhenUsingAncestorsStrategy() {
this.context.refresh(); this.context.refresh();
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
child.register(ExampleBeanConfiguration.class, child.register(ExampleBeanConfiguration.class,
OnBeanInParentsConfiguration.class); OnBeanInAncestorsConfiguration.class);
child.setParent(this.context); child.setParent(this.context);
child.refresh(); child.refresh();
assertThat(child.getBeansOfType(ExampleBean.class)).hasSize(2); assertThat(child.getBeansOfType(ExampleBean.class)).hasSize(2);
} }
@Configuration @Configuration
protected static class OnBeanInParentsConfiguration { protected static class OnBeanInAncestorsConfiguration {
@Bean @Bean
@ConditionalOnMissingBean(search = SearchStrategy.PARENTS) @ConditionalOnMissingBean(search = SearchStrategy.ANCESTORS)
public ExampleBean exampleBean2() { public ExampleBean exampleBean2() {
return new ExampleBean("test"); return new ExampleBean("test");
} }
......
...@@ -63,11 +63,11 @@ public class ConditionalOnSingleCandidateTests { ...@@ -63,11 +63,11 @@ public class ConditionalOnSingleCandidateTests {
} }
@Test @Test
public void singleCandidateInParentsOneCandidateInCurrent() { public void singleCandidateInAncestorsOneCandidateInCurrent() {
load(); load();
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
child.register(FooConfiguration.class, child.register(FooConfiguration.class,
OnBeanSingleCandidateInParentsConfiguration.class); OnBeanSingleCandidateInAncestorsConfiguration.class);
child.setParent(this.context); child.setParent(this.context);
child.refresh(); child.refresh();
assertThat(child.containsBean("baz")).isFalse(); assertThat(child.containsBean("baz")).isFalse();
...@@ -75,10 +75,10 @@ public class ConditionalOnSingleCandidateTests { ...@@ -75,10 +75,10 @@ public class ConditionalOnSingleCandidateTests {
} }
@Test @Test
public void singleCandidateInParentsOneCandidateInParent() { public void singleCandidateInAncestorsOneCandidateInParent() {
load(FooConfiguration.class); load(FooConfiguration.class);
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
child.register(OnBeanSingleCandidateInParentsConfiguration.class); child.register(OnBeanSingleCandidateInAncestorsConfiguration.class);
child.setParent(this.context); child.setParent(this.context);
child.refresh(); child.refresh();
assertThat(child.containsBean("baz")).isTrue(); assertThat(child.containsBean("baz")).isTrue();
...@@ -87,13 +87,13 @@ public class ConditionalOnSingleCandidateTests { ...@@ -87,13 +87,13 @@ public class ConditionalOnSingleCandidateTests {
} }
@Test @Test
public void singleCandidateInParentsOneCandidateInGrandparent() { public void singleCandidateInAncestorsOneCandidateInGrandparent() {
load(FooConfiguration.class); load(FooConfiguration.class);
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
parent.setParent(this.context); parent.setParent(this.context);
parent.refresh(); parent.refresh();
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext(); AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
child.register(OnBeanSingleCandidateInParentsConfiguration.class); child.register(OnBeanSingleCandidateInAncestorsConfiguration.class);
child.setParent(parent); child.setParent(parent);
child.refresh(); child.refresh();
assertThat(child.containsBean("baz")).isTrue(); assertThat(child.containsBean("baz")).isTrue();
...@@ -177,8 +177,8 @@ public class ConditionalOnSingleCandidateTests { ...@@ -177,8 +177,8 @@ public class ConditionalOnSingleCandidateTests {
} }
@Configuration @Configuration
@ConditionalOnSingleCandidate(value = String.class, search = SearchStrategy.PARENTS) @ConditionalOnSingleCandidate(value = String.class, search = SearchStrategy.ANCESTORS)
protected static class OnBeanSingleCandidateInParentsConfiguration { protected static class OnBeanSingleCandidateInAncestorsConfiguration {
@Bean @Bean
public String baz(String s) { public String baz(String s) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment