Search in sources :

Example 26 with ComponentDescriptionDTO

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);
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)

Example 27 with ComponentDescriptionDTO

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;
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) Map(java.util.Map) HashMap(java.util.HashMap) ServiceComponentRuntime(org.osgi.service.component.runtime.ServiceComponentRuntime)

Example 28 with ComponentDescriptionDTO

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;
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) ServiceComponentRuntime(org.osgi.service.component.runtime.ServiceComponentRuntime)

Example 29 with ComponentDescriptionDTO

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;
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) ServiceComponentRuntime(org.osgi.service.component.runtime.ServiceComponentRuntime)

Example 30 with ComponentDescriptionDTO

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);
    }
}
Also used : ComponentDescriptionDTO(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO) Iterator(java.util.Iterator) Test(org.junit.Test)

Aggregations

ComponentDescriptionDTO (org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)36 ComponentConfigurationDTO (org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)18 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 Bundle (org.osgi.framework.Bundle)3 ServiceComponentRuntime (org.osgi.service.component.runtime.ServiceComponentRuntime)3 ReferenceDTO (org.osgi.service.component.runtime.dto.ReferenceDTO)3 UnsatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO)3 Iterator (java.util.Iterator)2 TreeMap (java.util.TreeMap)2 Component (org.apache.felix.scr.Component)2 Descriptor (org.apache.felix.service.command.Descriptor)2 JSONWriter (org.apache.felix.utils.json.JSONWriter)2 ServiceReferenceDTO (org.osgi.framework.dto.ServiceReferenceDTO)2 SatisfiedReferenceDTO (org.osgi.service.component.runtime.dto.SatisfiedReferenceDTO)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1