提交 2a6c6424 编写于 作者: J Juergen Hoeller

Added tests for custom qualifier annotations on scoped @Bean methods

Issue: SPR-11116
(cherry picked from commit c5d79773)
上级 126116e7
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册