use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class QualifierAnnotationTests method testNonQualifiedFieldFails.
@Test
public void testNonQualifiedFieldFails() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(CONFIG_LOCATION);
context.registerSingleton("testBean", NonQualifiedTestBean.class);
try {
context.refresh();
fail("Should have thrown a BeanCreationException");
} catch (BeanCreationException e) {
assertTrue(e.getMessage().contains("found 6"));
}
}
use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class CustomAutowireConfigurerTests method testCustomResolver.
@Test
public void testCustomResolver() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(bf);
reader.loadBeanDefinitions(CONTEXT);
CustomAutowireConfigurer cac = new CustomAutowireConfigurer();
CustomResolver customResolver = new CustomResolver();
bf.setAutowireCandidateResolver(customResolver);
cac.postProcessBeanFactory(bf);
TestBean testBean = (TestBean) bf.getBean("testBean");
assertEquals("#1!", testBean.getName());
}
use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class QualifierAnnotationTests method testQualifiedByAttributesFailsWithoutCustomQualifierRegistered.
@Test
public void testQualifiedByAttributesFailsWithoutCustomQualifierRegistered() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(CONFIG_LOCATION);
context.registerSingleton("testBean", QualifiedByAttributesTestBean.class);
try {
context.refresh();
fail("should have thrown a BeanCreationException");
} catch (BeanCreationException e) {
assertTrue(e.getMessage().contains("found 6"));
}
}
use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class QualifierAnnotationTests method testQualifiedByAnnotation.
@Test
public void testQualifiedByAnnotation() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(CONFIG_LOCATION);
context.registerSingleton("testBean", QualifiedByAnnotationTestBean.class);
context.refresh();
QualifiedByAnnotationTestBean testBean = (QualifiedByAnnotationTestBean) context.getBean("testBean");
Person person = testBean.getLarry();
assertEquals("LarrySpecial", person.getName());
}
use of org.springframework.beans.factory.support.BeanDefinitionReader in project spring-framework by spring-projects.
the class QualifierAnnotationTests method testQualifiedByAnnotationValue.
@Test
public void testQualifiedByAnnotationValue() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
reader.loadBeanDefinitions(CONFIG_LOCATION);
context.registerSingleton("testBean", QualifiedByAnnotationValueTestBean.class);
context.refresh();
QualifiedByAnnotationValueTestBean testBean = (QualifiedByAnnotationValueTestBean) context.getBean("testBean");
Person person = testBean.getLarry();
assertEquals("LarrySpecial", person.getName());
}
Aggregations