use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestSeveralConstructor method testNoEmptyConstructor.
@Test
public void testNoEmptyConstructor() {
ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), ci2.getInstanceName());
CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
assertFalse("Check assignation", cs.check());
String name = (String) cs.getProps().get("name");
assertEquals("Check message", "NULL", name);
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestCallbacks method testWithPostUnregistrationOnly.
@Test
public void testWithPostUnregistrationOnly() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Callbacks-unreg-only");
// Controller set to true.
osgiHelper.waitForService(FooService.class.getName(), null, 5000);
osgiHelper.waitForService(CheckService.class.getName(), null, 5000);
CheckService check = (CheckService) osgiHelper.getServiceObject(CheckService.class.getName(), null);
assertNotNull(check);
Integer reg = (Integer) check.getProps().get("registered");
Integer unreg = (Integer) check.getProps().get("unregistered");
assertNotNull(reg);
assertNotNull(unreg);
assertEquals(new Integer(0), reg);
assertEquals(new Integer(0), unreg);
ci.stop();
reg = (Integer) check.getProps().get("registered");
unreg = (Integer) check.getProps().get("unregistered");
assertNotNull(reg);
assertNotNull(unreg);
assertEquals(new Integer(0), reg);
assertEquals(new Integer(1), unreg);
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestCallbacks method testWithTwoPairsOfCallbacks.
@Test
public void testWithTwoPairsOfCallbacks() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Callbacks-both-2");
// Controller set to true.
osgiHelper.waitForService(FooService.class.getName(), null, 5000);
osgiHelper.waitForService(CheckService.class.getName(), null, 5000);
CheckService check = (CheckService) osgiHelper.getServiceObject(CheckService.class.getName(), null);
assertNotNull(check);
Integer reg = (Integer) check.getProps().get("registered");
Integer unreg = (Integer) check.getProps().get("unregistered");
Integer reg2 = (Integer) check.getProps().get("registered2");
Integer unreg2 = (Integer) check.getProps().get("unregistered2");
assertNotNull(reg);
assertNotNull(unreg);
assertNotNull(reg2);
assertNotNull(unreg2);
assertEquals(new Integer(1), reg);
assertEquals(new Integer(0), unreg);
assertEquals(new Integer(1), reg2);
assertEquals(new Integer(0), unreg2);
ci.stop();
reg = (Integer) check.getProps().get("registered");
unreg = (Integer) check.getProps().get("unregistered");
reg2 = (Integer) check.getProps().get("registered2");
unreg2 = (Integer) check.getProps().get("unregistered2");
assertNotNull(reg2);
assertNotNull(unreg2);
assertEquals(new Integer(1), reg);
assertEquals(new Integer(1), unreg);
assertEquals(new Integer(1), reg2);
assertEquals(new Integer(1), unreg2);
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestCallbacks method testWithOnePairForTwoService.
@Test
public void testWithOnePairForTwoService() {
ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Callbacks-both-1");
// Controller set to true.
osgiHelper.waitForService(FooService.class.getName(), null, 5000);
osgiHelper.waitForService(CheckService.class.getName(), null, 5000);
CheckService check = (CheckService) osgiHelper.getServiceObject(CheckService.class.getName(), null);
assertNotNull(check);
Integer reg = (Integer) check.getProps().get("registered");
Integer unreg = (Integer) check.getProps().get("unregistered");
assertNotNull(reg);
assertNotNull(unreg);
assertEquals(new Integer(2), reg);
assertEquals(new Integer(0), unreg);
ci.stop();
reg = (Integer) check.getProps().get("registered");
unreg = (Integer) check.getProps().get("unregistered");
assertEquals(new Integer(2), reg);
assertEquals(new Integer(2), unreg);
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService 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();
}
Aggregations