Search in sources :

Example 1 with FooRegistrationListener

use of org.apache.aries.blueprint.sample.FooRegistrationListener in project aries by apache.

the class TestRegistrationListener method testWithAutoExportEnabled.

@Test
public void testWithAutoExportEnabled() throws Exception {
    BlueprintContainer blueprintContainer = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.blueprint.sample");
    assertNotNull(blueprintContainer);
    Foo foo = context().getService(Foo.class, "(" + BlueprintConstants.COMPONENT_NAME_PROPERTY + "=foo)");
    assertEquals(5, foo.getA());
    FooRegistrationListener listener = (FooRegistrationListener) blueprintContainer.getComponentInstance("fooRegistrationListener");
    // If registration listener works fine, the registration method should
    // have already been called and properties that were passed to this
    // method should have been not null
    Map<?, ?> props = listener.getProperties();
    assertNotNull(props);
    assertTrue(props.containsKey(BlueprintConstants.COMPONENT_NAME_PROPERTY));
    assertEquals("foo", props.get(BlueprintConstants.COMPONENT_NAME_PROPERTY));
    assertTrue(props.containsKey("key"));
    assertEquals("value", props.get("key"));
}
Also used : BlueprintContainer(org.osgi.service.blueprint.container.BlueprintContainer) Foo(org.apache.aries.blueprint.sample.Foo) FooRegistrationListener(org.apache.aries.blueprint.sample.FooRegistrationListener) Test(org.junit.Test)

Aggregations

Foo (org.apache.aries.blueprint.sample.Foo)1 FooRegistrationListener (org.apache.aries.blueprint.sample.FooRegistrationListener)1 Test (org.junit.Test)1 BlueprintContainer (org.osgi.service.blueprint.container.BlueprintContainer)1