use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class CollectionMergingTests method setUp.
@Before
public void setUp() throws Exception {
BeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
reader.loadBeanDefinitions(new ClassPathResource("collectionMerging.xml", getClass()));
}
use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class QualifierAnnotationTests method testQualifiedByParameterName.
@Test
public void testQualifiedByParameterName() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(CONFIG_LOCATION);
context.registerSingleton("testBean", QualifiedByParameterNameTestBean.class);
context.refresh();
QualifiedByParameterNameTestBean testBean = (QualifiedByParameterNameTestBean) context.getBean("testBean");
Person person = testBean.getLarry();
assertEquals("LarryBean", person.getName());
}
use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class QualifierAnnotationTests method testQualifiedByValue.
@Test
public void testQualifiedByValue() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(CONFIG_LOCATION);
context.registerSingleton("testBean", QualifiedByValueTestBean.class);
context.refresh();
QualifiedByValueTestBean testBean = (QualifiedByValueTestBean) context.getBean("testBean");
Person person = testBean.getLarry();
assertEquals("Larry", person.getName());
}
use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class QualifierAnnotationTests method testQualifiedByParentValue.
@Test
public void testQualifiedByParentValue() {
StaticApplicationContext parent = new StaticApplicationContext();
GenericBeanDefinition parentLarry = new GenericBeanDefinition();
parentLarry.setBeanClass(Person.class);
parentLarry.getPropertyValues().add("name", "ParentLarry");
parentLarry.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "parentLarry"));
parent.registerBeanDefinition("someLarry", parentLarry);
GenericBeanDefinition otherLarry = new GenericBeanDefinition();
otherLarry.setBeanClass(Person.class);
otherLarry.getPropertyValues().add("name", "OtherLarry");
otherLarry.addQualifier(new AutowireCandidateQualifier(Qualifier.class, "otherLarry"));
parent.registerBeanDefinition("someOtherLarry", otherLarry);
parent.refresh();
StaticApplicationContext context = new StaticApplicationContext(parent);
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(CONFIG_LOCATION);
context.registerSingleton("testBean", QualifiedByParentValueTestBean.class);
context.refresh();
QualifiedByParentValueTestBean testBean = (QualifiedByParentValueTestBean) context.getBean("testBean");
Person person = testBean.getLarry();
assertEquals("ParentLarry", person.getName());
}
use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class QualifierAnnotationTests method testQualifiedByBeanName.
@Test
public void testQualifiedByBeanName() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(CONFIG_LOCATION);
context.registerSingleton("testBean", QualifiedByBeanNameTestBean.class);
context.refresh();
QualifiedByBeanNameTestBean testBean = (QualifiedByBeanNameTestBean) context.getBean("testBean");
Person person = testBean.getLarry();
assertEquals("LarryBean", person.getName());
assertTrue(testBean.myProps != null && testBean.myProps.isEmpty());
}
Aggregations