From 2a6c6424082cce9f243e3985b27db6dedf963987 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 11 Dec 2013 18:44:13 +0100 Subject: [PATCH] Added tests for custom qualifier annotations on scoped @Bean methods Issue: SPR-11116 (cherry picked from commit c5d7977) --- .../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 bd2808eb0df..8765a53ebf2 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 @@ -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