use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestContextInjectionFromAnnotations method testConstructorInjectionOfInstanceBundleContext.
@Test
public void testConstructorInjectionOfInstanceBundleContext() {
BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
Properties configuration = new Properties();
configuration.put("instance.bundle.context", bc);
ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core" + ".components.annotations.InstanceBundleContextInjectionInConstructor", configuration);
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("context");
assertNotNull(context);
assertEquals(bc, context);
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestContextInjectionFromXML method testMethodInjectionOfComponentBundleContextUsingXML.
@Test
public void testMethodInjectionOfComponentBundleContextUsingXML() {
ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Method-Component");
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("context");
assertNotNull(context);
assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestContextInjectionFromXML method testMethodInjectionOfInstanceBundleContextUsingXML.
@Test
public void testMethodInjectionOfInstanceBundleContextUsingXML() {
BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
Properties configuration = new Properties();
configuration.put("instance.bundle.context", bc);
ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Method-Instance", configuration);
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("context");
assertNotNull(context);
assertEquals(bc, context);
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestContextInjectionFromXML method testFieldInjectionOfComponentBundleContextUsingXML.
@Test
public void testFieldInjectionOfComponentBundleContextUsingXML() {
ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Field-Component");
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("context");
assertNotNull(context);
assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestContextInjectionFromXML method testConstructorInjectionOfInstanceBundleContextUsingXML.
@Test
public void testConstructorInjectionOfInstanceBundleContextUsingXML() {
BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
Properties configuration = new Properties();
configuration.put("instance.bundle.context", bc);
ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Constructor-Instance", configuration);
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("context");
assertNotNull(context);
assertEquals(bc, context);
}
Aggregations