Add test for @Fallback with BeanFactory.getBean(Class)
This commit is contained in:
parent
4ff0f86ae2
commit
9a1e5eb8d7
|
@ -116,6 +116,19 @@ class BeanMethodQualificationTests {
|
||||||
ctx.close();
|
ctx.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One regular bean along with fallback beans is considered effective primary
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void effectivePrimary() {
|
||||||
|
AnnotationConfigApplicationContext ctx = context(EffectivePrimaryConfig.class);
|
||||||
|
|
||||||
|
TestBean testBean = ctx.getBean(TestBean.class);
|
||||||
|
assertThat(testBean.getName()).isEqualTo("effective-primary");
|
||||||
|
|
||||||
|
ctx.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void customWithLazyResolution() {
|
void customWithLazyResolution() {
|
||||||
AnnotationConfigApplicationContext ctx = context(CustomConfig.class, CustomPojo.class);
|
AnnotationConfigApplicationContext ctx = context(CustomConfig.class, CustomPojo.class);
|
||||||
|
@ -314,6 +327,24 @@ class BeanMethodQualificationTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
static class EffectivePrimaryConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TestBean effectivePrimary() {
|
||||||
|
return new TestBean("effective-primary");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean @Fallback
|
||||||
|
public TestBean fallback1() {
|
||||||
|
return new TestBean("fallback1");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean @Fallback
|
||||||
|
public TestBean fallback2() {
|
||||||
|
return new TestBean("fallback2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component @Lazy
|
@Component @Lazy
|
||||||
static class StandardPojo {
|
static class StandardPojo {
|
||||||
|
|
Loading…
Reference in New Issue