use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentConfigurationTest method test_SimpleComponent_configuration_ignore.
@Test
public void test_SimpleComponent_configuration_ignore() throws Exception {
final String pid = "SimpleComponent.configuration.ignore";
TestCase.assertNull(SimpleComponent.INSTANCE);
deleteConfig(pid);
delay();
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertNotNull(SimpleComponent.INSTANCE);
TestCase.assertNull(SimpleComponent.INSTANCE.getProperty(PROP_NAME));
configure(pid);
delay();
findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertNotNull(SimpleComponent.INSTANCE);
TestCase.assertNull(SimpleComponent.INSTANCE.getProperty(PROP_NAME));
deleteConfig(pid);
delay();
findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertNotNull(SimpleComponent.INSTANCE);
TestCase.assertNull(SimpleComponent.INSTANCE.getProperty(PROP_NAME));
disableAndCheck(cc);
TestCase.assertNull(SimpleComponent.INSTANCE);
}
use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentConfigurationTest method test_SimpleComponent_configuration_require.
@Test
public void test_SimpleComponent_configuration_require() throws Exception {
final String pid = "SimpleComponent.configuration.require";
deleteConfig(pid);
delay();
TestCase.assertNull(SimpleComponent.INSTANCE);
getConfigurationsDisabledThenEnable(pid, 0, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
TestCase.assertNull(SimpleComponent.INSTANCE);
configure(pid);
delay();
ComponentConfigurationDTO cc = findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertNotNull(SimpleComponent.INSTANCE);
TestCase.assertEquals(PROP_NAME, SimpleComponent.INSTANCE.getProperty(PROP_NAME));
deleteConfig(pid);
delay();
checkConfigurationCount(pid, 0, -1);
TestCase.assertNull(SimpleComponent.INSTANCE);
disableAndCheck(cc);
TestCase.assertNull(SimpleComponent.INSTANCE);
}
use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentConfigurationTest method test_SimpleComponent_configuration_optional.
@Test
public void test_SimpleComponent_configuration_optional() throws Exception {
final String pid = "SimpleComponent.configuration.optional";
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent firstInstance = SimpleComponent.INSTANCE;
TestCase.assertNotNull(firstInstance);
TestCase.assertNull(firstInstance.getProperty(PROP_NAME));
configure(pid);
delay();
final SimpleComponent secondInstance = SimpleComponent.INSTANCE;
findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertNotNull(secondInstance);
TestCase.assertEquals(PROP_NAME, secondInstance.getProperty(PROP_NAME));
deleteConfig(pid);
delay();
final SimpleComponent thirdInstance = SimpleComponent.INSTANCE;
findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertNotNull(thirdInstance);
TestCase.assertNull(thirdInstance.getProperty(PROP_NAME));
TestCase.assertNotSame("Expect new instance object after reconfiguration", firstInstance, secondInstance);
TestCase.assertNotSame("Expect new instance object after configuration deletion (1)", firstInstance, thirdInstance);
TestCase.assertNotSame("Expect new instance object after configuration deletion (2)", secondInstance, thirdInstance);
disableAndCheck(cc);
TestCase.assertNull(SimpleComponent.INSTANCE);
}
use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentConfigurationTest method test_SimpleComponent_configuration_require_initialize.
/**
* same as test_SimpleComponent_configuration_require except configuration is present when component is enabled.
*/
@Test
public void test_SimpleComponent_configuration_require_initialize() throws Exception {
final String pid = "SimpleComponent.configuration.require";
deleteConfig(pid);
configure(pid);
delay();
TestCase.assertNull(SimpleComponent.INSTANCE);
ComponentConfigurationDTO cc = getConfigurationsDisabledThenEnable(pid, 1, ComponentConfigurationDTO.ACTIVE).iterator().next();
TestCase.assertNotNull(SimpleComponent.INSTANCE);
TestCase.assertEquals(PROP_NAME, SimpleComponent.INSTANCE.getProperty(PROP_NAME));
deleteConfig(pid);
delay();
checkConfigurationCount(pid, 0, -1);
TestCase.assertNull(SimpleComponent.INSTANCE);
disableAndCheck(cc);
TestCase.assertNull(SimpleComponent.INSTANCE);
}
use of org.osgi.service.component.runtime.dto.ComponentConfigurationDTO in project felix by apache.
the class ComponentEnableTest method test_Component_Enable.
@Test
public void test_Component_Enable() throws Exception {
final String enable = "org.apache.felix.scr.integration.components.enable";
final String name = "org.apache.felix.scr.integration.components.SimpleComponent";
ComponentConfigurationDTO dto = findComponentConfigurationByName(enable, ComponentConfigurationDTO.SATISFIED);
EnableComponent ec = getServiceFromConfiguration(dto, EnableComponent.class);
TestCase.assertEquals(0, SimpleComponent.INSTANCES.size());
ec.enable(name);
delay();
TestCase.assertEquals(1, SimpleComponent.INSTANCES.size());
ec.enable(name);
delay();
TestCase.assertEquals(1, SimpleComponent.INSTANCES.size());
}
Aggregations