public void testBeanDefinitionRemoval() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
lbf.setAllowBeanDefinitionOverriding(false);
lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
lbf.registerAlias("test", "test2");
lbf.preInstantiateSingletons();
lbf.removeBeanDefinition("test");
lbf.removeAlias("test2");
lbf.registerBeanDefinition("test", new RootBeanDefinition(NestedTestBean.class));
lbf.registerAlias("test", "test2");
assertTrue(lbf.getBean("test") instanceof NestedTestBean);