From c5d797736ba5fc098472d5cfeb24321a75316cc7 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 10 Dec 2013 22:35:34 +0100 Subject: [PATCH] Added tests for custom qualifier annotations on scoped @Bean methods Issue: SPR-11116 --- .../BeanMethodQualificationTests.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java index 65591d8485..429d61c926 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java @@ -52,6 +52,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 @@ -61,6 +62,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 @@ -70,6 +72,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 @@ -99,7 +102,7 @@ public class BeanMethodQualificationTests { return new TestBean("interesting"); } - @Bean @Qualifier("boring") + @Bean @Boring public TestBean testBean2() { return new TestBean("boring"); } @@ -113,7 +116,7 @@ public class BeanMethodQualificationTests { return new TestBean("interesting"); } - @Bean @Qualifier("boring") @Scope("prototype") + @Bean @Boring @Scope("prototype") public TestBean testBean2() { return new TestBean("boring"); } @@ -127,7 +130,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"); } @@ -137,6 +140,13 @@ public class BeanMethodQualificationTests { static class StandardPojo { @Autowired @Qualifier("interesting") TestBean testBean; + + @Autowired @Boring TestBean testBean2; + } + + @Qualifier + @Retention(RetentionPolicy.RUNTIME) + public @interface Boring { } @Configuration -- GitLab