use of org.springframework.tests.sample.beans.DerivedTestBean in project spring-framework by spring-projects.
the class XmlBeanFactoryTests method testInheritanceWithDifferentClass.
@Test
public void testInheritanceWithDifferentClass() throws Exception {
DefaultListableBeanFactory parent = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(parent).loadBeanDefinitions(PARENT_CONTEXT);
DefaultListableBeanFactory child = new DefaultListableBeanFactory(parent);
new XmlBeanDefinitionReader(child).loadBeanDefinitions(CHILD_CONTEXT);
assertEquals(DerivedTestBean.class, child.getType("inheritsWithClass"));
DerivedTestBean inherits = (DerivedTestBean) child.getBean("inheritsWithDifferentClass");
// Name property value is overridden
assertTrue(inherits.getName().equals("override"));
// Age property is inherited from bean in parent factory
assertTrue(inherits.getAge() == 1);
assertTrue(inherits.wasInitialized());
}
use of org.springframework.tests.sample.beans.DerivedTestBean in project spring-framework by spring-projects.
the class XmlBeanFactoryTests method testLenientDependencyMatching.
@Test
public void testLenientDependencyMatching() {
DefaultListableBeanFactory xbf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(xbf).loadBeanDefinitions(CONSTRUCTOR_ARG_CONTEXT);
LenientDependencyTestBean bean = (LenientDependencyTestBean) xbf.getBean("lenientDependencyTestBean");
assertTrue(bean.tb instanceof DerivedTestBean);
}
Aggregations