Search in sources :

Example 1 with SimpleComponent2

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);
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) SimpleComponent(org.apache.felix.scr.integration.components.SimpleComponent) SimpleComponent2(org.apache.felix.scr.integration.components.SimpleComponent2) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Example 2 with SimpleComponent2

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();
}
Also used : SimpleService2Impl(org.apache.felix.scr.integration.components.SimpleService2Impl) SimpleComponent2(org.apache.felix.scr.integration.components.SimpleComponent2) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) SimpleServiceImpl(org.apache.felix.scr.integration.components.SimpleServiceImpl) Test(org.junit.Test)

Example 3 with SimpleComponent2

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();
}
Also used : SimpleService2Impl(org.apache.felix.scr.integration.components.SimpleService2Impl) SimpleComponent2(org.apache.felix.scr.integration.components.SimpleComponent2) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) SimpleServiceImpl(org.apache.felix.scr.integration.components.SimpleServiceImpl) Test(org.junit.Test)

Aggregations

SimpleComponent2 (org.apache.felix.scr.integration.components.SimpleComponent2)3 SimpleService2Impl (org.apache.felix.scr.integration.components.SimpleService2Impl)2 SimpleServiceImpl (org.apache.felix.scr.integration.components.SimpleServiceImpl)2 Test (org.junit.Test)2 ComponentConfigurationDTO (org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)2 SimpleComponent (org.apache.felix.scr.integration.components.SimpleComponent)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1 ComponentDescriptionDTO (org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)1