Added tests for custom qualifier annotations on scoped @Bean methods

Issue: SPR-11116
(cherry picked from commit c5d7977)
This commit is contained in:
Juergen Hoeller
2013-12-11 18:44:13 +01:00
parent 126116e759
commit 2a6c642408

View File

@@ -51,6 +51,7 @@ public class BeanMethodQualificationTests {
assertFalse(ctx.getBeanFactory().containsSingleton("testBean1"));
StandardPojo pojo = ctx.getBean(StandardPojo.class);
assertThat(pojo.testBean.getName(), equalTo("interesting"));
assertThat(pojo.testBean2.getName(), equalTo("boring"));
}
@Test
@@ -60,6 +61,7 @@ public class BeanMethodQualificationTests {
assertFalse(ctx.getBeanFactory().containsSingleton("testBean1"));
StandardPojo pojo = ctx.getBean(StandardPojo.class);
assertThat(pojo.testBean.getName(), equalTo("interesting"));
assertThat(pojo.testBean2.getName(), equalTo("boring"));
}
@Test
@@ -69,6 +71,7 @@ public class BeanMethodQualificationTests {
assertTrue(ctx.getBeanFactory().containsSingleton("testBean1")); // a shared scoped proxy
StandardPojo pojo = ctx.getBean(StandardPojo.class);
assertThat(pojo.testBean.getName(), equalTo("interesting"));
assertThat(pojo.testBean2.getName(), equalTo("boring"));
}
@Test
@@ -89,7 +92,7 @@ public class BeanMethodQualificationTests {
return new TestBean("interesting");
}
@Bean @Qualifier("boring")
@Bean @Boring
public TestBean testBean2() {
return new TestBean("boring");
}
@@ -103,7 +106,7 @@ public class BeanMethodQualificationTests {
return new TestBean("interesting");
}
@Bean @Qualifier("boring") @Scope("prototype")
@Bean @Boring @Scope("prototype")
public TestBean testBean2() {
return new TestBean("boring");
}
@@ -117,7 +120,7 @@ public class BeanMethodQualificationTests {
return new TestBean("interesting");
}
@Bean @Qualifier("boring") @Scope(value="prototype", proxyMode=ScopedProxyMode.TARGET_CLASS)
@Bean @Boring @Scope(value="prototype", proxyMode=ScopedProxyMode.TARGET_CLASS)
public TestBean testBean2() {
return new TestBean("boring");
}
@@ -127,6 +130,13 @@ public class BeanMethodQualificationTests {
static class StandardPojo {
@Autowired @Qualifier("interesting") TestBean testBean;
@Autowired @Boring TestBean testBean2;
}
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
public @interface Boring {
}
@Configuration