use of org.apache.aries.blueprint.testbundlea.multi.InterfaceB in project aries by apache.
the class MultiInterfacesTest method testMultiInterfaceReferences.
@Test
public void testMultiInterfaceReferences() throws Exception {
//bundlea provides the ns handlers, bean processors, interceptors etc for this test.
startBundleBlueprint("org.apache.aries.blueprint.testbundlea");
//bundleb makes use of the extensions provided by bundlea
//bundleb's container will hold the beans we need to query to check the function
//provided by bundlea functioned as expected
BlueprintContainer beanContainer = startBundleBlueprint("org.apache.aries.blueprint.testbundleb");
Object obj1 = beanContainer.getComponentInstance("OnlyA");
Object obj2 = beanContainer.getComponentInstance("AandB");
Object obj3 = beanContainer.getComponentInstance("AandBandC");
Object obj4 = beanContainer.getComponentInstance("AandBandCandD");
assertEquals("A", ((InterfaceA) obj1).methodA());
assertEquals("A", ((InterfaceA) obj2).methodA());
assertEquals("A", ((InterfaceA) obj3).methodA());
assertEquals("B", ((InterfaceB) obj2).methodB());
assertEquals("C", ((InterfaceC) obj3).methodC());
assertFalse(obj1 instanceof InterfaceC);
assertFalse(obj2 instanceof InterfaceC);
assertFalse(obj1 instanceof InterfaceB);
assertTrue(obj4 instanceof InterfaceD);
try {
((InterfaceD) obj4).methodD();
fail("This should not work");
} catch (org.osgi.service.blueprint.container.ServiceUnavailableException t) {
//expected
}
}
Aggregations