|
19 | 19 | import org.junit.Before; |
20 | 20 | import org.junit.Test; |
21 | 21 |
|
| 22 | +import org.springframework.aop.scope.ScopedProxyUtils; |
22 | 23 | import org.springframework.beans.factory.FactoryBean; |
23 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
24 | 25 | import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor; |
25 | 26 | import org.springframework.beans.factory.annotation.Qualifier; |
26 | 27 | import org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver; |
| 28 | +import org.springframework.beans.factory.config.BeanDefinitionHolder; |
27 | 29 | import org.springframework.beans.factory.support.ChildBeanDefinition; |
28 | 30 | import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
29 | 31 | import org.springframework.beans.factory.support.RootBeanDefinition; |
@@ -124,6 +126,19 @@ public void testPostProcessorDoesNotOverrideRegularBeanDefinitions() { |
124 | 126 | beanFactory.getBean("bar", TestBean.class); |
125 | 127 | } |
126 | 128 |
|
| 129 | + @Test |
| 130 | + public void testPostProcessorDoesNotOverrideRegularBeanDefinitionsEvenWithScopedProxy() { |
| 131 | + RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); |
| 132 | + rbd.setResource(new DescriptiveResource("XML or something")); |
| 133 | + BeanDefinitionHolder proxied = ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(rbd, "bar"), beanFactory, true); |
| 134 | + beanFactory.registerBeanDefinition("bar", proxied.getBeanDefinition()); |
| 135 | + beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); |
| 136 | + ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); |
| 137 | + pp.postProcessBeanFactory(beanFactory); |
| 138 | + beanFactory.getBean("foo", Foo.class); |
| 139 | + beanFactory.getBean("bar", TestBean.class); |
| 140 | + } |
| 141 | + |
127 | 142 | @Test |
128 | 143 | public void testProcessingAllowedOnlyOncePerProcessorRegistryPair() { |
129 | 144 | DefaultListableBeanFactory bf1 = new DefaultListableBeanFactory(); |
|
0 commit comments