Search in sources :

Example 1 with Pojo

use of org.apache.aries.cdi.test.interfaces.Pojo in project aries by apache.

the class OSGiBeanDescriptorTests method testServices.

public void testServices() throws Exception {
    Bundle tb2Bundle = installBundle("tb2.jar");
    ServiceTracker<Pojo, Pojo> st = new ServiceTracker<Pojo, Pojo>(bundleContext, Pojo.class, null);
    st.open(true);
    try {
        Pojo pojo = st.waitForService(timeout);
        assertNotNull(pojo);
    } finally {
        tb2Bundle.uninstall();
    }
}
Also used : Pojo(org.apache.aries.cdi.test.interfaces.Pojo) ServiceTracker(org.osgi.util.tracker.ServiceTracker) Bundle(org.osgi.framework.Bundle)

Example 2 with Pojo

use of org.apache.aries.cdi.test.interfaces.Pojo in project aries by apache.

the class AbstractTestCase method assertPojoExists.

void assertPojoExists(BeanManager beanManager) {
    Set<Bean<?>> beans = beanManager.getBeans(Pojo.class, any);
    assertFalse(beans.isEmpty());
    Iterator<Bean<?>> iterator = beans.iterator();
    Bean<?> bean = iterator.next();
    assertTrue(Pojo.class.isAssignableFrom(bean.getBeanClass()));
    assertFalse(iterator.hasNext());
    bean = beanManager.resolve(beans);
    CreationalContext<?> ctx = beanManager.createCreationalContext(bean);
    Pojo pojo = (Pojo) beanManager.getReference(bean, Pojo.class, ctx);
    assertNotNull(pojo);
}
Also used : Pojo(org.apache.aries.cdi.test.interfaces.Pojo) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

Pojo (org.apache.aries.cdi.test.interfaces.Pojo)2 Bean (javax.enterprise.inject.spi.Bean)1 Bundle (org.osgi.framework.Bundle)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1