use of org.apache.felix.scr.integration.components.SimpleComponent2 in project felix by apache.
the class Felix4350Test method doTest.
protected void doTest(String componentName) throws Exception {
ServiceRegistration dep1Reg = register(new SimpleComponent(), 0);
ServiceRegistration dep2Reg = register(new SimpleComponent2(), 1000);
final ComponentDescriptionDTO main = findComponentDescriptorByName(componentName);
TestCase.assertNotNull(main);
// needs to be async
asyncEnable(main);
// dep2 getService has not yet returned
delay(300);
dep1Reg.unregister();
// dep2 getService has returned
delay(2000);
Felix4350Component.check(0, 0, false);
dep1Reg = register(new SimpleComponent(), 0);
delay(300);
Felix4350Component.check(1, 0, true);
// does not need to be asyncv??
disableAndCheck(main);
dep1Reg.unregister();
dep2Reg.unregister();
Felix4350Component.check(1, 1, false);
dep1Reg = register(new SimpleComponent(), 0);
dep2Reg = register(new SimpleComponent2(), 1000);
Felix4350Component.check(1, 1, false);
// needs to be async
asyncEnable(main);
delay(300);
dep1Reg.unregister();
delay(100);
dep1Reg = register(new SimpleComponent(), 0);
delay(2000);
// n.b. counts are cumulative
Felix4350Component.check(2, 1, true);
}
use of org.apache.felix.scr.integration.components.SimpleComponent2 in project felix by apache.
the class ServiceBindTest method test_multi_service_bind_unbind_order.
@Test
public void test_multi_service_bind_unbind_order() throws Exception {
final SimpleServiceImpl srv1 = SimpleServiceImpl.create(bundleContext, "srv1");
final SimpleService2Impl srv2 = SimpleService2Impl.create(bundleContext, "srv2");
String name = "test_multi_service_bind_unbind_order";
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent2 comp10 = SimpleComponent2.INSTANCE;
TestCase.assertNotNull(comp10);
TestCase.assertEquals(2, comp10.getBindings().size());
TestCase.assertEquals("bindSimpleService", comp10.getBindings().get(0));
TestCase.assertEquals("bindSimpleService2", comp10.getBindings().get(1));
disableAndCheck(cc);
delay();
TestCase.assertEquals(4, comp10.getBindings().size());
TestCase.assertEquals("bindSimpleService", comp10.getBindings().get(0));
TestCase.assertEquals("bindSimpleService2", comp10.getBindings().get(1));
TestCase.assertEquals("unbindSimpleService2", comp10.getBindings().get(2));
TestCase.assertEquals("unbindSimpleService", comp10.getBindings().get(3));
srv1.drop();
srv2.drop();
}
use of org.apache.felix.scr.integration.components.SimpleComponent2 in project felix by apache.
the class ServiceBindGreedyTest method test_multi_service_bind_unbind_order.
@Test
public void test_multi_service_bind_unbind_order() throws Exception {
final SimpleServiceImpl srv1 = SimpleServiceImpl.create(bundleContext, "srv1");
final SimpleService2Impl srv2 = SimpleService2Impl.create(bundleContext, "srv2");
String name = "test_multi_service_bind_unbind_order";
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(name, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent2 comp10 = SimpleComponent2.INSTANCE;
TestCase.assertNotNull(comp10);
TestCase.assertEquals(2, comp10.getBindings().size());
TestCase.assertEquals("bindSimpleService", comp10.getBindings().get(0));
TestCase.assertEquals("bindSimpleService2", comp10.getBindings().get(1));
disableAndCheck(cc);
delay();
TestCase.assertEquals(4, comp10.getBindings().size());
TestCase.assertEquals("bindSimpleService", comp10.getBindings().get(0));
TestCase.assertEquals("bindSimpleService2", comp10.getBindings().get(1));
TestCase.assertEquals("unbindSimpleService2", comp10.getBindings().get(2));
TestCase.assertEquals("unbindSimpleService", comp10.getBindings().get(3));
srv1.drop();
srv2.drop();
}
Aggregations