@@ -0,0 +1,3265 @@
+/*%0A * Copyright 2002-2004 the original author or authors.%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A * %0A *      http://www.apache.org/licenses/LICENSE-2.0%0A * %0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */ %0A%0Apackage org.springframework.beans.factory.config;%0A%0Aimport junit.framework.TestCase;%0A%0Aimport org.springframework.beans.BeansException;%0Aimport org.springframework.beans.MutablePropertyValues;%0Aimport org.springframework.beans.TestBean;%0Aimport org.springframework.beans.factory.support.DefaultListableBeanFactory;%0Aimport org.springframework.beans.factory.support.RootBeanDefinition;%0Aimport org.springframework.context.support.StaticApplicationContext;%0A%0A/**%0A * This test will go away once a real lifecycle test is created for AppContexts%0A * %0A * @author Colin Sampaleanu%0A * @since 02.10.2003%0A */%0Apublic class BeanFactoryPostProcessorTests extends TestCase %7B%0A%0A%09public void testBeanFactoryPostProcessorExecutedByAppContext() %7B%0A%09%09%0A%09%09StaticApplicationContext ac = new StaticApplicationContext();%0A%09%09ac.registerSingleton(%22tb1%22, TestBean.class, new MutablePropertyValues());%0A%09%09ac.registerSingleton(%22tb2%22, TestBean.class, new MutablePropertyValues());%0A%09%09TestBeanFactoryPostProcessor bfpp = new TestBeanFactoryPostProcessor();%0A%09%09ac.addBeanFactoryPostProcessor(bfpp);%0A%09%09assertTrue(bfpp.wasCalled == false);%0A%09%09ac.refresh();%0A%09%09assertTrue(bfpp.wasCalled == true);%0A%09%7D%0A%09%0A%09public void testBeanFactoryPostProcessorExecutedByAppContext2() %7B%0A%09%09%0A%09%09StaticApplicationContext ac = new StaticApplicationContext();%0A%09%09ac.registerSingleton(%22tb1%22, TestBean.class, new MutablePropertyValues());%0A%09%09ac.registerSingleton(%22tb2%22, TestBean.class, new MutablePropertyValues());%0A%09%09ac.registerSingleton(%22bfpp%22, TestBeanFactoryPostProcessor.class, new MutablePropertyValues());%0A%09%09ac.refresh();%0A%09%09TestBeanFactoryPostProcessor bfpp = (TestBeanFactoryPostProcessor) ac.getBean(%22bfpp%22);%0A%09%09assertTrue(bfpp.wasCalled == true);%0A%09%7D%0A%0A%0A%09public void testBeanFactoryPostProcessorNotExecutedByBeanFactory() %7B%0A%09%09%0A%09%09DefaultListableBeanFactory bf = new DefaultListableBeanFactory();%0A        bf.registerBeanDefinition(%22tb1%22,%0A%09%09%09%09new RootBeanDefinition(TestBean.class, new MutablePropertyValues()));%0A        bf.registerBeanDefinition(%22tb2%22,%0A%09%09%09%09new RootBeanDefinition(TestBean.class, new MutablePropertyValues()));%0A        bf.registerBeanDefinition(%22bfpp%22,%0A%09%09%09%09new RootBeanDefinition(TestBeanFactoryPostProcessor.class, new MutablePropertyValues()));%0A%09%09%0A%09%09TestBeanFactoryPostProcessor bfpp = (TestBeanFactoryPostProcessor) bf.getBean(%22bfpp%22);%0A%09%09assertTrue(bfpp.wasCalled == false);%0A%09%7D%0A%0A%09%0A%09public static class TestBeanFactoryPostProcessor implements BeanFactoryPostProcessor %7B%0A%09%09%0A%09%09public boolean wasCalled = false;%0A%09%09%0A%09%09public TestBeanFactoryPostProcessor() %7B%0A%09%09%7D%0A%09%09public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException %7B%0A%09%09%09wasCalled = true;%0A%09%09%7D%0A%09%7D%0A%09%0A%7D%0A

add temportary BeanFactoryPostProcessor test