Search in sources :

Example 81 with ComponentInstance

use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.

the class TestCallbacks method testWithOnePairForTwoService.

@Test
public void testWithOnePairForTwoService() {
    ComponentInstance ci = ipojoHelper.createComponentInstance("PS-Callbacks-both-1");
    // Controller set to true.
    osgiHelper.waitForService(FooService.class.getName(), null, 5000);
    osgiHelper.waitForService(CheckService.class.getName(), null, 5000);
    CheckService check = (CheckService) osgiHelper.getServiceObject(CheckService.class.getName(), null);
    assertNotNull(check);
    Integer reg = (Integer) check.getProps().get("registered");
    Integer unreg = (Integer) check.getProps().get("unregistered");
    assertNotNull(reg);
    assertNotNull(unreg);
    assertEquals(new Integer(2), reg);
    assertEquals(new Integer(0), unreg);
    ci.stop();
    reg = (Integer) check.getProps().get("registered");
    unreg = (Integer) check.getProps().get("unregistered");
    assertEquals(new Integer(2), reg);
    assertEquals(new Integer(2), unreg);
}
Also used : FooService(org.apache.felix.ipojo.runtime.core.services.FooService) ComponentInstance(org.apache.felix.ipojo.ComponentInstance) CheckService(org.apache.felix.ipojo.runtime.core.services.CheckService) Test(org.junit.Test)

Example 82 with ComponentInstance

use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.

the class TestInheritedClasses method testIP12.

@Test
public void testIP12() {
    ComponentInstance ci = ipojoHelper.createComponentInstance(pi12.getName(), "ci");
    ServiceReference ref3 = ipojoHelper.getServiceReferenceByName(ParentInterface2.class.getName(), "ci");
    assertNotNull("Check Parent2", ref3);
    ServiceReference ref4 = ipojoHelper.getServiceReferenceByName(ParentParentInterface.class.getName(), "ci");
    assertNotNull("Check PP", ref4);
    ci.dispose();
}
Also used : ComponentInstance(org.apache.felix.ipojo.ComponentInstance) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Example 83 with ComponentInstance

use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.

the class TestInheritedClasses method testIP3.

@Test
public void testIP3() {
    ComponentInstance ci = ipojoHelper.createComponentInstance(pi3.getName(), "ci");
    ServiceReference ref1 = ipojoHelper.getServiceReferenceByName(ChildInterface.class.getName(), "ci");
    assertNotNull("Check Child", ref1);
    ServiceReference ref2 = ipojoHelper.getServiceReferenceByName(ParentInterface1.class.getName(), "ci");
    assertNotNull("Check Parent1", ref2);
    ServiceReference ref3 = ipojoHelper.getServiceReferenceByName(ParentInterface2.class.getName(), "ci");
    assertNotNull("Check Parent2", ref3);
    ServiceReference ref4 = ipojoHelper.getServiceReferenceByName(ParentParentInterface.class.getName(), "ci");
    assertNotNull("Check PP", ref4);
    ServiceReference ref5 = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "ci");
    assertNotNull("Check FS", ref5);
    ci.dispose();
}
Also used : ComponentInstance(org.apache.felix.ipojo.ComponentInstance) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Example 84 with ComponentInstance

use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.

the class TestInheritedClasses method testIP11.

@Test
public void testIP11() {
    ComponentInstance ci = ipojoHelper.createComponentInstance(pi11.getName(), "ci");
    ServiceReference ref4 = ipojoHelper.getServiceReferenceByName(ParentParentInterface.class.getName(), "ci");
    assertNotNull("Check PP", ref4);
    ci.dispose();
}
Also used : ComponentInstance(org.apache.felix.ipojo.ComponentInstance) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Example 85 with ComponentInstance

use of org.apache.felix.ipojo.ComponentInstance in project felix by apache.

the class TestInheritedClasses method testIP21.

@Test
public void testIP21() {
    ComponentInstance ci = ipojoHelper.createComponentInstance(pi21.getName(), "ci");
    ServiceReference ref4 = ipojoHelper.getServiceReferenceByName(ParentParentInterface.class.getName(), "ci");
    assertNotNull("Check PP", ref4);
    ci.dispose();
}
Also used : ComponentInstance(org.apache.felix.ipojo.ComponentInstance) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Aggregations

ComponentInstance (org.apache.felix.ipojo.ComponentInstance)373 Test (org.junit.Test)360 ServiceReference (org.osgi.framework.ServiceReference)215 Properties (java.util.Properties)142 CheckService (org.apache.felix.ipojo.handler.temporal.services.CheckService)70 FooService (org.apache.felix.ipojo.handler.temporal.services.FooService)70 CheckService (org.apache.felix.ipojo.handler.transaction.services.CheckService)65 Factory (org.apache.felix.ipojo.Factory)53 CheckService (org.apache.felix.ipojo.runtime.core.services.CheckService)50 ServiceContext (org.apache.felix.ipojo.ServiceContext)47 FooService (org.apache.felix.ipojo.runtime.core.services.FooService)39 IOException (java.io.IOException)29 CheckService (org.apache.felix.ipojo.runtime.core.test.services.CheckService)22 BundleContext (org.osgi.framework.BundleContext)19 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)17 ComponentFactory (org.apache.felix.ipojo.ComponentFactory)14 Dictionary (java.util.Dictionary)12 Hashtable (java.util.Hashtable)12 BarService (org.apache.felix.ipojo.runtime.core.services.BarService)10 DependencyDescription (org.apache.felix.ipojo.handlers.dependency.DependencyDescription)9