Search in sources :

Example 1 with CdiEvent

use of org.osgi.service.cdi.CdiEvent in project aries by apache.

the class EventsTests method testEventsGetSent.

public void testEventsGetSent() throws Exception {
    BeanManager beanManager = cdiContainer.getBeanManager();
    assertNotNull(beanManager);
    @SuppressWarnings("serial") Set<Bean<?>> beans = beanManager.getBeans(Object.class, new AnnotationLiteral<CdiEventObserverQualifier>() {
    });
    Bean<?> bean = beanManager.resolve(beans);
    CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
    Object bcb = beanManager.getReference(bean, Object.class, ctx);
    assertNotNull(bcb);
    @SuppressWarnings("unchecked") BeanService<List<CdiEvent>> bti = (BeanService<List<CdiEvent>>) bcb;
    List<CdiEvent> list = bti.get();
    assertNotNull(list);
    assertEquals(3, list.size());
}
Also used : Bean(javax.enterprise.inject.spi.Bean) List(java.util.List) CdiEvent(org.osgi.service.cdi.CdiEvent) BeanManager(javax.enterprise.inject.spi.BeanManager) CdiEventObserverQualifier(org.apache.aries.cdi.test.interfaces.CdiEventObserverQualifier) BeanService(org.apache.aries.cdi.test.interfaces.BeanService)

Aggregations

List (java.util.List)1 Bean (javax.enterprise.inject.spi.Bean)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 BeanService (org.apache.aries.cdi.test.interfaces.BeanService)1 CdiEventObserverQualifier (org.apache.aries.cdi.test.interfaces.CdiEventObserverQualifier)1 CdiEvent (org.osgi.service.cdi.CdiEvent)1