use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestInheritedClasses method testIP2.
@Test
public void testIP2() {
ComponentInstance ci = ipojoHelper.createComponentInstance(pi2.getName(), "ci");
ServiceReference ref1 = ipojoHelper.getServiceReferenceByName(ChildInterface.class.getName(), "ci");
assertNotNull("Check Child", ref1);
ServiceReference ref2 = ipojoHelper.getServiceReferenceByName(ParentInterface1.class.getName(), "ci");
assertNotNull("Check Parent1", ref2);
ServiceReference ref3 = ipojoHelper.getServiceReferenceByName(ParentInterface2.class.getName(), "ci");
assertNotNull("Check Parent2", ref3);
ServiceReference ref4 = ipojoHelper.getServiceReferenceByName(ParentParentInterface.class.getName(), "ci");
assertNotNull("Check PP", ref4);
ci.dispose();
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestInheritedClasses method testIP1.
@Test
public void testIP1() {
ComponentInstance ci = ipojoHelper.createComponentInstance(pi1.getName(), "ci");
ServiceReference ref1 = ipojoHelper.getServiceReferenceByName(ChildInterface.class.getName(), "ci");
assertNotNull("Check Child", ref1);
ServiceReference ref2 = ipojoHelper.getServiceReferenceByName(ParentInterface1.class.getName(), "ci");
assertNotNull("Check Parent1", ref2);
ServiceReference ref3 = ipojoHelper.getServiceReferenceByName(ParentInterface2.class.getName(), "ci");
assertNotNull("Check Parent2", ref3);
ServiceReference ref4 = ipojoHelper.getServiceReferenceByName(ParentParentInterface.class.getName(), "ci");
assertNotNull("Check PP", ref4);
ci.dispose();
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestListeners method testRemoveNonexistentProvidedServiceListener.
@Test(expected = NoSuchElementException.class)
public void testRemoveNonexistentProvidedServiceListener() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Controller-1-default");
ProvidedServiceHandlerDescription pshd = (ProvidedServiceHandlerDescription) ci.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:provides");
ProvidedServiceDescription ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
// Should fail!
ps.removeListener(new ThrowingListener());
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestServiceController method testComponentWithTwoControllersUsingBothSpecificationsTrueFalse.
@Test
public void testComponentWithTwoControllersUsingBothSpecificationsTrueFalse() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Controller-2-spec1");
osgiHelper.waitForService(CheckService.class.getName(), null, 5000);
assertFalse(osgiHelper.isServiceAvailable(FooService.class.getName()));
CheckService check = (CheckService) osgiHelper.getServiceObject(CheckService.class.getName(), null);
assertNotNull(check);
check.getProps();
assertFalse(osgiHelper.isServiceAvailable(CheckService.class.getName()));
assertTrue(osgiHelper.isServiceAvailable(FooService.class.getName()));
FooService fs = (FooService) osgiHelper.getServiceObject(FooService.class.getName(), null);
fs.fooProps();
assertTrue(osgiHelper.isServiceAvailable(CheckService.class.getName()));
assertTrue(osgiHelper.isServiceAvailable(FooService.class.getName()));
ci.dispose();
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestServiceController method testComponentWithTwoControllersUsingBothSpecificationsTrueTrue.
@Test
public void testComponentWithTwoControllersUsingBothSpecificationsTrueTrue() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Controller-2-spec2");
osgiHelper.waitForService(CheckService.class.getName(), null, 5000);
osgiHelper.waitForService(FooService.class.getName(), null, 5000);
CheckService check = (CheckService) osgiHelper.getServiceObject(CheckService.class.getName(), null);
assertNotNull(check);
check.check();
// CheckService not available
assertNull(osgiHelper.getServiceReference(CheckService.class.getName()));
assertNotNull(osgiHelper.getServiceReference(FooService.class.getName()));
FooService fs = (FooService) osgiHelper.getServiceObject(FooService.class.getName(), null);
fs.foo();
assertNull(osgiHelper.getServiceReference(CheckService.class.getName()));
assertNull(osgiHelper.getServiceReference(FooService.class.getName()));
ci.dispose();
}
Aggregations