use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentTestBase method disableAndCheck.
protected void disableAndCheck(String name) throws InvocationTargetException, InterruptedException {
ComponentDescriptionDTO cd = findComponentDescriptorByName(name);
disableAndCheck(cd);
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentTestBase method findComponentConfigurationsByName.
protected Collection<ComponentConfigurationDTO> findComponentConfigurationsByName(Bundle b, String name, int expected) {
ServiceComponentRuntime scr = scrTracker.getService();
if (scr == null) {
TestCase.fail("no ServiceComponentRuntime");
}
ComponentDescriptionDTO cd = scr.getComponentDescriptionDTO(b, name);
Collection<ComponentConfigurationDTO> ccs = scr.getComponentConfigurationDTOs(cd);
if (expected != 0) {
String sep = "[";
StringBuffer sb = new StringBuffer();
for (Map.Entry<Integer, String> entry : STATES.entrySet()) {
if ((expected & entry.getKey()) != 0) {
sb.append(sep).append(entry.getValue());
sep = ", ";
}
}
sb.append("]");
for (ComponentConfigurationDTO cc : ccs) {
Assert.assertTrue("for ComponentConfiguration name: " + cc.description.name + " properties" + cc.properties + "Expected one of state " + sb.toString() + " but was " + STATES.get(cc.state), (expected & cc.state) == cc.state);
}
}
return ccs;
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentTestBase method checkConfigurationCount.
protected ComponentDescriptionDTO checkConfigurationCount(Bundle b, String name, int count, int expectedState) {
ServiceComponentRuntime scr = scrTracker.getService();
if (scr == null) {
TestCase.fail("no ServiceComponentRuntime");
}
ComponentDescriptionDTO cd = scr.getComponentDescriptionDTO(b, name);
Assert.assertTrue("Expected component enabled", scr.isComponentEnabled(cd));
Collection<ComponentConfigurationDTO> ccs = scr.getComponentConfigurationDTOs(cd);
Assert.assertEquals(count, ccs.size());
if (expectedState != -1) {
for (ComponentConfigurationDTO cc : ccs) {
Assert.assertEquals("Expected state " + STATES.get(expectedState) + " but was " + STATES.get(cc.state), expectedState, cc.state);
}
}
return cd;
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class ComponentTestBase method getConfigurationsDisabledThenEnable.
protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable(Bundle b, String name, int count, int initialState) throws InvocationTargetException, InterruptedException {
ServiceComponentRuntime scr = scrTracker.getService();
if (scr == null) {
TestCase.fail("no ServiceComponentRuntime");
}
ComponentDescriptionDTO cd = scr.getComponentDescriptionDTO(b, name);
Assert.assertFalse("Expected component disabled", scr.isComponentEnabled(cd));
scr.enableComponent(cd).getValue();
Assert.assertTrue("Expected component enabled", scr.isComponentEnabled(cd));
Collection<ComponentConfigurationDTO> ccs = scr.getComponentConfigurationDTOs(cd);
Assert.assertEquals(count, ccs.size());
for (ComponentConfigurationDTO cc : ccs) {
Assert.assertEquals("Expected state " + STATES.get(initialState) + " but was " + STATES.get(cc.state), initialState, cc.state);
}
return ccs;
}
use of org.osgi.service.component.runtime.dto.ComponentDescriptionDTO in project felix by apache.
the class Felix3680Test method test_concurrent_reference_bindings.
@Test
public void test_concurrent_reference_bindings() throws Exception {
final ComponentDescriptionDTO main = findComponentDescriptorByName("org.apache.felix.scr.integration.components.felix3680.Main");
enableAndCheck(main);
delay(30);
disableAndCheck(main);
// async deactivate
delay();
for (Iterator it = log.foundWarnings().iterator(); it.hasNext(); ) {
String message = (String) it.next();
if (message.startsWith("Performed ") && message.endsWith(" tests.")) {
continue;
}
TestCase.fail("unexpected warning or error logged: " + message);
}
}
Aggregations