@Test public void testBeanDefinitionRegistryPostProcessor() { StaticApplicationContext ac = new StaticApplicationContext(); ac.registerSingleton("tb1", TestBean.class); ac.registerSingleton("tb2", TestBean.class); ac.addBeanFactoryPostProcessor(new PrioritizedBeanDefinitionRegistryPostProcessor()); TestBeanDefinitionRegistryPostProcessor bdrpp = new TestBeanDefinitionRegistryPostProcessor(); ac.addBeanFactoryPostProcessor(bdrpp); assertFalse(bdrpp.wasCalled); ac.refresh(); assertTrue(bdrpp.wasCalled); assertTrue(ac.getBean("bfpp1", TestBeanFactoryPostProcessor.class).wasCalled); assertTrue(ac.getBean("bfpp2", TestBeanFactoryPostProcessor.class).wasCalled); }
@Test public void testRegisteredBeanFactoryPostProcessor() { StaticApplicationContext ac = new StaticApplicationContext(); ac.registerSingleton("tb1", TestBean.class); ac.registerSingleton("tb2", TestBean.class); TestBeanFactoryPostProcessor bfpp = new TestBeanFactoryPostProcessor(); ac.addBeanFactoryPostProcessor(bfpp); assertFalse(bfpp.wasCalled); ac.refresh(); assertTrue(bfpp.wasCalled); }