use of org.apache.aries.blueprint.pojos.FITestBean in project aries by apache.
the class WiringTest method testFieldInjection.
public void testFieldInjection() throws Exception {
ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
Repository repository = new TestBlueprintContainer(registry).getRepository();
Object fiTestBean = repository.create("FITestBean");
assertNotNull(fiTestBean);
assertTrue(fiTestBean instanceof FITestBean);
FITestBean bean = (FITestBean) fiTestBean;
// single field injection
assertEquals("value", bean.getAttr());
// prefer setter injection to field injection
assertEquals("IS_LOWER", bean.getUpperCaseAttr());
// support cascaded injection 'bean.name' via fields
assertEquals("aName", bean.getBeanName());
// fail if field-injection is not specified
try {
repository.create("FIFailureTestBean");
Assert.fail("Expected exception");
} catch (ComponentDefinitionException cde) {
}
// fail if field-injection is false
try {
repository.create("FIFailureTest2Bean");
Assert.fail("Expected exception");
} catch (ComponentDefinitionException cde) {
}
}
Aggregations