use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestServiceController method testComponentWithAControllerSetToFalse.
@Test
public void testComponentWithAControllerSetToFalse() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Controller-1-false");
// Controller set to false.
osgiHelper.waitForService(CheckService.class.getName(), null, 5000);
assertNull(osgiHelper.getServiceReference(FooService.class.getName()));
CheckService check = (CheckService) osgiHelper.getServiceObject(CheckService.class.getName(), null);
assertNotNull(check);
assertTrue(check.check());
assertNotNull(osgiHelper.getServiceReference(FooService.class.getName()));
assertFalse(check.check());
// FooService should not be there anymore
assertNull(osgiHelper.getServiceReference(FooService.class.getName()));
ci.dispose();
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestServiceController method testComponentWithTwoControllersSetToTrueAndFalse.
@Test
public void testComponentWithTwoControllersSetToTrueAndFalse() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Controller-2-truefalse");
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 testComponentWithTwoControllersUsingSpecificationAndAllTrueTrue.
@Test
public void testComponentWithTwoControllersUsingSpecificationAndAllTrueTrue() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Controller-2-spec3");
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();
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestSimplePS method testWhenNoInterface.
@Test
public void testWhenNoInterface() {
String factoryName = "org.apache.felix.ipojo.runtime.core.components.SimpleClass";
ComponentInstance ci = ipojoHelper.createComponentInstance(factoryName);
osgiHelper.waitForService(SimpleClass.class.getName(), null, 5000);
SimpleClass simple = (SimpleClass) osgiHelper.getServiceObject(SimpleClass.class.getName(), null);
assertEquals("Hello", simple.hello());
ci.dispose();
}
use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.
the class TestContextInjectionFromAnnotations method testFieldInjectionOfComponentBundleContext.
@Test
public void testFieldInjectionOfComponentBundleContext() {
ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" + ".components.annotations.ComponentBundleContextInjectionInField");
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("context");
assertNotNull(context);
assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
}
Aggregations