use of org.springframework.beans.factory.xml.ConstructorDependenciesBean in project spring-framework by spring-projects.
the class DefaultListableBeanFactoryTests method testAutowireConstructor.
@Test
public void testAutowireConstructor() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
lbf.registerBeanDefinition("spouse", bd);
ConstructorDependenciesBean bean = (ConstructorDependenciesBean) lbf.autowire(ConstructorDependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, true);
Object spouse = lbf.getBean("spouse");
assertTrue(bean.getSpouse1() == spouse);
assertTrue(BeanFactoryUtils.beanOfType(lbf, TestBean.class) == spouse);
}
use of org.springframework.beans.factory.xml.ConstructorDependenciesBean in project spring-framework by spring-projects.
the class DefaultListableBeanFactoryTests method autowireConstructor.
@Test
void autowireConstructor() {
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
lbf.registerBeanDefinition("spouse", bd);
ConstructorDependenciesBean bean = (ConstructorDependenciesBean) lbf.autowire(ConstructorDependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, true);
Object spouse = lbf.getBean("spouse");
assertThat(bean.getSpouse1() == spouse).isTrue();
assertThat(BeanFactoryUtils.beanOfType(lbf, TestBean.class) == spouse).isTrue();
}
Aggregations