Search in sources :

Example 1 with DependencyCallback

use of org.apache.felix.ipojo.handlers.dependency.DependencyCallback in project felix by apache.

the class TestDependencyIdDetection method testAddAndRemoveMethods.

@Test
public void testAddAndRemoveMethods() {
    ComponentInstance instance = ipojoHelper.createComponentInstance(factory);
    DependencyHandlerDescription dh = (DependencyHandlerDescription) instance.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
    DependencyDescription dd = findDependencyById(dh, "MyService");
    assertThat(dd).isNotNull();
    DependencyCallback[] callbacks = dd.getDependency().getDependencyCallbacks();
    assertThat(callbacks).isNotNull();
    DependencyCallback bind = getBindCallback(callbacks);
    DependencyCallback unbind = getUnbindCallback(callbacks);
    assertThat(bind).isNotNull();
    assertThat(unbind).isNotNull();
    assertThat(bind.getMethodName()).isEqualTo("addMyService");
    assertThat(unbind.getMethodName()).isEqualTo("removeMyService");
}
Also used : DependencyCallback(org.apache.felix.ipojo.handlers.dependency.DependencyCallback) DependencyHandlerDescription(org.apache.felix.ipojo.handlers.dependency.DependencyHandlerDescription) ComponentInstance(org.apache.felix.ipojo.ComponentInstance) DependencyDescription(org.apache.felix.ipojo.handlers.dependency.DependencyDescription) Test(org.junit.Test)

Example 2 with DependencyCallback

use of org.apache.felix.ipojo.handlers.dependency.DependencyCallback in project felix by apache.

the class TestDependencyIdDetection method testSetAndUnSetMethods.

@Test
public void testSetAndUnSetMethods() {
    ComponentInstance instance = ipojoHelper.createComponentInstance(factory);
    DependencyHandlerDescription dh = (DependencyHandlerDescription) instance.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
    DependencyDescription dd = findDependencyById(dh, "MyOtherService");
    assertThat(dd).isNotNull();
    DependencyCallback[] callbacks = dd.getDependency().getDependencyCallbacks();
    assertThat(callbacks).isNotNull();
    DependencyCallback bind = getBindCallback(callbacks);
    DependencyCallback unbind = getUnbindCallback(callbacks);
    assertThat(bind).isNotNull();
    assertThat(unbind).isNotNull();
    assertThat(bind.getMethodName()).isEqualTo("setMyOtherService");
    assertThat(unbind.getMethodName()).isEqualTo("unsetMyOtherService");
}
Also used : DependencyCallback(org.apache.felix.ipojo.handlers.dependency.DependencyCallback) DependencyHandlerDescription(org.apache.felix.ipojo.handlers.dependency.DependencyHandlerDescription) ComponentInstance(org.apache.felix.ipojo.ComponentInstance) DependencyDescription(org.apache.felix.ipojo.handlers.dependency.DependencyDescription) Test(org.junit.Test)

Aggregations

ComponentInstance (org.apache.felix.ipojo.ComponentInstance)2 DependencyCallback (org.apache.felix.ipojo.handlers.dependency.DependencyCallback)2 DependencyDescription (org.apache.felix.ipojo.handlers.dependency.DependencyDescription)2 DependencyHandlerDescription (org.apache.felix.ipojo.handlers.dependency.DependencyHandlerDescription)2 Test (org.junit.Test)2