use of org.apache.aries.blueprint.di.Repository 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) {
}
}
use of org.apache.aries.blueprint.di.Repository in project aries by apache.
the class BeanLoadingTest method testLoadSimpleBeanNested.
public void testLoadSimpleBeanNested() throws Exception {
ComponentDefinitionRegistryImpl registry = parse("/test-bean-classes.xml");
Repository repository = new TestBlueprintContainer(registry).getRepository();
Object obj = repository.create("simpleBeanNested");
assertNotNull(obj);
assertTrue(obj instanceof SimpleBean.Nested);
}
use of org.apache.aries.blueprint.di.Repository in project aries by apache.
the class BeanLoadingTest method testLoadSimpleBean.
public void testLoadSimpleBean() throws Exception {
ComponentDefinitionRegistryImpl registry = parse("/test-bean-classes.xml");
Repository repository = new TestBlueprintContainer(registry).getRepository();
Object obj = repository.create("simpleBean");
assertNotNull(obj);
assertTrue(obj instanceof SimpleBean);
}
use of org.apache.aries.blueprint.di.Repository in project aries by apache.
the class ServiceRecipe method createRecipe.
private Object createRecipe(Recipe recipe) {
String name = recipe.getName();
Repository repo = blueprintContainer.getRepository();
if (repo.getRecipe(name) != recipe) {
repo.putRecipe(name, recipe);
}
return repo.create(name);
}
Aggregations