Search in sources :

Example 1 with FieldActivatorComponent

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

the class ComponentFieldActivationTest method test_field_activator_failure.

@Test
public void test_field_activator_failure() throws Exception {
    final String componentname = "FieldActivatorComponent.unsatisfied";
    ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
    assertEquals(1, cc.description.activationFields.length);
    assertTrue(Arrays.asList(cc.description.activationFields).contains("foo"));
    // we get the component, although the field does not exist!
    FieldActivatorComponent cmp = this.getServiceFromConfiguration(cc, FieldActivatorComponent.class);
    assertTrue(cmp.isActivateCalled());
    assertTrue(cmp.setBeforeActivate().isEmpty());
    assertEquals(4, cmp.notSetBeforeActivate().size());
    assertNull(cmp.additionalError());
    disableAndCheck(cc);
}
Also used : FieldActivatorComponent(org.apache.felix.scr.integration.components.FieldActivatorComponent) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) Test(org.junit.Test)

Example 2 with FieldActivatorComponent

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

the class ComponentFieldActivationTest method test_field_activator_failure_partially.

@Test
public void test_field_activator_failure_partially() throws Exception {
    final String componentname = "FieldActivatorComponent.partiallysatisfied";
    ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
    assertEquals(3, cc.description.activationFields.length);
    assertTrue(Arrays.asList(cc.description.activationFields).contains("bundle"));
    assertTrue(Arrays.asList(cc.description.activationFields).contains("context"));
    assertTrue(Arrays.asList(cc.description.activationFields).contains("foo"));
    // we get the component, although some fields do not exist!
    FieldActivatorComponent cmp = this.getServiceFromConfiguration(cc, FieldActivatorComponent.class);
    assertTrue(cmp.isActivateCalled());
    assertEquals(2, cmp.setBeforeActivate().size());
    assertTrue(cmp.setBeforeActivate().contains("bundle"));
    assertTrue(cmp.setBeforeActivate().contains("context"));
    assertEquals(2, cmp.notSetBeforeActivate().size());
    assertNull(cmp.additionalError());
    disableAndCheck(cc);
}
Also used : FieldActivatorComponent(org.apache.felix.scr.integration.components.FieldActivatorComponent) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) Test(org.junit.Test)

Example 3 with FieldActivatorComponent

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

the class ComponentFieldActivationTest method test_field_activator_success.

@Test
public void test_field_activator_success() throws Exception {
    final String componentname = "FieldActivatorComponent.satisfied";
    ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
    assertEquals(4, cc.description.activationFields.length);
    assertTrue(Arrays.asList(cc.description.activationFields).contains("bundle"));
    assertTrue(Arrays.asList(cc.description.activationFields).contains("context"));
    assertTrue(Arrays.asList(cc.description.activationFields).contains("config"));
    assertTrue(Arrays.asList(cc.description.activationFields).contains("annotation"));
    FieldActivatorComponent cmp = this.getServiceFromConfiguration(cc, FieldActivatorComponent.class);
    assertTrue(cmp.isActivateCalled());
    assertTrue(cmp.notSetBeforeActivate().isEmpty());
    assertEquals(4, cmp.setBeforeActivate().size());
    assertNull(cmp.additionalError());
    disableAndCheck(cc);
}
Also used : FieldActivatorComponent(org.apache.felix.scr.integration.components.FieldActivatorComponent) ComponentConfigurationDTO(org.osgi.service.component.runtime.dto.ComponentConfigurationDTO) Test(org.junit.Test)

Aggregations

FieldActivatorComponent (org.apache.felix.scr.integration.components.FieldActivatorComponent)3 Test (org.junit.Test)3 ComponentConfigurationDTO (org.osgi.service.component.runtime.dto.ComponentConfigurationDTO)3