Search in sources :

Example 1 with ActivatorComponent

use of org.apache.felix.scr.integration.components.ActivatorComponent in project felix by apache.

the class ComponentActivationTest method test_activate_register_service.

@Test
public void test_activate_register_service() throws Exception {
    final String componentname = "ActivatorComponent.activate.with.bind";
    ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.ACTIVE);
    ActivatorComponent ac = ActivatorComponent.getInstance();
    TestCase.assertNotNull(ac.getSimpleService());
    disableAndCheck(cc);
    TestCase.assertNull(ac.getSimpleService());
}
Also used : ActivatorComponent(org.apache.felix.scr.integration.components.ActivatorComponent) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) Test(org.junit.Test)

Example 2 with ActivatorComponent

use of org.apache.felix.scr.integration.components.ActivatorComponent in project felix by apache.

the class ComponentActivationTest method testRequiredDependency.

private void testRequiredDependency(final String componentname) throws Exception {
    ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
    SimpleServiceImpl ss = SimpleServiceImpl.create(bundleContext, "foo");
    findComponentConfigurationByName(componentname, ComponentConfigurationDTO.SATISFIED);
    ServiceReference<ActivatorComponent> ref = bundleContext.getServiceReference(ActivatorComponent.class);
    ss.drop();
    findComponentConfigurationByName(componentname, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
    TestCase.assertNull(bundleContext.getServiceReference(ActivatorComponent.class));
    ss = SimpleServiceImpl.create(bundleContext, "foo");
    ref = bundleContext.getServiceReference(ActivatorComponent.class);
    ActivatorComponent ac = bundleContext.getService(ref);
    TestCase.assertNotNull(ac.getSimpleService());
    findComponentConfigurationByName(componentname, ComponentConfigurationDTO.ACTIVE);
    disableAndCheck(cc);
}
Also used : ActivatorComponent(org.apache.felix.scr.integration.components.ActivatorComponent) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) SimpleServiceImpl(org.apache.felix.scr.integration.components.SimpleServiceImpl)

Aggregations

ActivatorComponent (org.apache.felix.scr.integration.components.ActivatorComponent)2 ComponentConfigurationDTO (org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)2 SimpleServiceImpl (org.apache.felix.scr.integration.components.SimpleServiceImpl)1 Test (org.junit.Test)1