|
|
|
@ -63,11 +63,11 @@ public class ConditionalOnSingleCandidateTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void singleCandidateInParentsOneCandidateInCurrent() {
|
|
|
|
|
public void singleCandidateInAncestorsOneCandidateInCurrent() {
|
|
|
|
|
load();
|
|
|
|
|
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
|
|
|
|
|
child.register(FooConfiguration.class,
|
|
|
|
|
OnBeanSingleCandidateInParentsConfiguration.class);
|
|
|
|
|
OnBeanSingleCandidateInAncestorsConfiguration.class);
|
|
|
|
|
child.setParent(this.context);
|
|
|
|
|
child.refresh();
|
|
|
|
|
assertThat(child.containsBean("baz")).isFalse();
|
|
|
|
@ -75,10 +75,10 @@ public class ConditionalOnSingleCandidateTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void singleCandidateInParentsOneCandidateInParent() {
|
|
|
|
|
public void singleCandidateInAncestorsOneCandidateInParent() {
|
|
|
|
|
load(FooConfiguration.class);
|
|
|
|
|
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
|
|
|
|
|
child.register(OnBeanSingleCandidateInParentsConfiguration.class);
|
|
|
|
|
child.register(OnBeanSingleCandidateInAncestorsConfiguration.class);
|
|
|
|
|
child.setParent(this.context);
|
|
|
|
|
child.refresh();
|
|
|
|
|
assertThat(child.containsBean("baz")).isTrue();
|
|
|
|
@ -87,13 +87,13 @@ public class ConditionalOnSingleCandidateTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void singleCandidateInParentsOneCandidateInGrandparent() {
|
|
|
|
|
public void singleCandidateInAncestorsOneCandidateInGrandparent() {
|
|
|
|
|
load(FooConfiguration.class);
|
|
|
|
|
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
|
|
|
|
|
parent.setParent(this.context);
|
|
|
|
|
parent.refresh();
|
|
|
|
|
AnnotationConfigApplicationContext child = new AnnotationConfigApplicationContext();
|
|
|
|
|
child.register(OnBeanSingleCandidateInParentsConfiguration.class);
|
|
|
|
|
child.register(OnBeanSingleCandidateInAncestorsConfiguration.class);
|
|
|
|
|
child.setParent(parent);
|
|
|
|
|
child.refresh();
|
|
|
|
|
assertThat(child.containsBean("baz")).isTrue();
|
|
|
|
@ -177,8 +177,8 @@ public class ConditionalOnSingleCandidateTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
@ConditionalOnSingleCandidate(value = String.class, search = SearchStrategy.PARENTS)
|
|
|
|
|
protected static class OnBeanSingleCandidateInParentsConfiguration {
|
|
|
|
|
@ConditionalOnSingleCandidate(value = String.class, search = SearchStrategy.ANCESTORS)
|
|
|
|
|
protected static class OnBeanSingleCandidateInAncestorsConfiguration {
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public String baz(String s) {
|
|
|
|
|