use of org.apache.aries.cdi.test.interfaces.BundleContextBeanQualifier in project aries by apache.
the class CdiBeanTests method testBundleContextInjection.
public void testBundleContextInjection() throws Exception {
BeanManager beanManager = cdiContainer.getBeanManager();
assertNotNull(beanManager);
@SuppressWarnings("serial") Set<Bean<?>> beans = beanManager.getBeans(Object.class, new AnnotationLiteral<BundleContextBeanQualifier>() {
});
Bean<?> bean = beanManager.resolve(beans);
CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
Object bcb = beanManager.getReference(bean, Object.class, ctx);
assertNotNull(bcb);
@SuppressWarnings("unchecked") BeanService<BundleContext> bti = (BeanService<BundleContext>) bcb;
assertNotNull(bti.get());
assertTrue(bti.get() instanceof BundleContext);
}
Aggregations