use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestContextInjectionFromXML method testFieldInjectionOfInstanceBundleContextUsingXML.
@Test
public void testFieldInjectionOfInstanceBundleContextUsingXML() {
BundleContext bc = osgiHelper.getBundle("org.apache.felix.ipojo").getBundleContext();
Properties configuration = new Properties();
configuration.put("instance.bundle.context", bc);
ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Field-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 testConstructorInjectionOfComponentBundleContextUsingXML.
@Test
public void testConstructorInjectionOfComponentBundleContextUsingXML() {
ComponentInstance instance = ipojoHelper.createComponentInstance("CTX-Constructor-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 TestInjectingComponentAndInstanceContext method testConstructorInjectionOfThreeContext.
/**
* Mix bundle context injection with the default bc injection (legacy).
*/
@Test
public void testConstructorInjectionOfThreeContext() {
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.ComponentWithThreeConstructorParams", configuration);
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("component");
assertNotNull(context);
assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
context = (BundleContext) check.map().get("instance");
assertNotNull(context);
assertEquals(bc, context);
context = (BundleContext) check.map().get("bc");
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 TestInjectingComponentAndInstanceContext method testFieldInjectionOfBothContext.
@Test
public void testFieldInjectionOfBothContext() {
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.ComponentWithTwoFields", configuration);
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("component");
assertNotNull(context);
assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
context = (BundleContext) check.map().get("instance");
assertNotNull(context);
assertEquals(bc, context);
}
use of org.apache.felix.ipojo.runtime.core.services.CheckService in project felix by apache.
the class TestInjectingComponentAndInstanceContext method testConstructorInjectionOfBothContext.
@Test
public void testConstructorInjectionOfBothContext() {
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.ComponentWithTwoConstructorParams", configuration);
CheckService check = ipojoHelper.getServiceObjectByName(CheckService.class, instance.getInstanceName());
assertNotNull(check);
BundleContext context = (BundleContext) check.map().get("component");
assertNotNull(context);
assertEquals(getTestBundle().getSymbolicName(), context.getBundle().getSymbolicName());
context = (BundleContext) check.map().get("instance");
assertNotNull(context);
assertEquals(bc, context);
}
Aggregations