use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestStereotypeAnnotation method testMethodStereotype.
@Test
public void testMethodStereotype() {
// verify component's factory is here
// verify that the requires handler has been activated
// verify that a created instance works
Factory factory = ipojoHelper.getFactory(MB_FACTORY_NAME);
Assert.assertNotNull(factory);
assertEquals(Factory.VALID, factory.getState());
assertTrue(factory.getRequiredHandlers().contains("org.apache.felix.ipojo:requires"));
ComponentInstance instance = ipojoHelper.createComponentInstance(MB_FACTORY_NAME, "stereotype-multibind-instance");
assertTrue(ipojoHelper.isInstanceValid(instance));
ipojoHelper.dispose();
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestStereotypeAnnotation method testTypeStereotype.
@Test
public void testTypeStereotype() {
// verify component's factory is here
// verify BazService has been published
// --> verify instance has been created
Factory factory = ipojoHelper.getFactory(BAZ_FACTORY_NAME);
Assert.assertNotNull(factory);
assertEquals(Factory.VALID, factory.getState());
List<BazService> services = osgiHelper.getServiceObjects(BazService.class);
assertEquals(1, services.size());
BazService baz = services.get(0);
assertEquals("Hello Guillaume", baz.hello("Guillaume"));
ipojoHelper.dispose();
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestFilteredExport method setUp.
@Before
public void setUp() {
fooProvider = ipojoHelper.getFactory("BazProviderType");
assertNotNull("Check fooProvider availability", fooProvider);
Properties p1 = new Properties();
p1.put("instance.name", "foo1");
Properties p2 = new Properties();
p2.put("instance.name", "foo2");
try {
foo1 = fooProvider.createComponentInstance(p1);
foo2 = fooProvider.createComponentInstance(p2);
} catch (Exception e) {
fail("Fail to create foos : " + e.getMessage());
}
foo1.stop();
foo2.stop();
Factory factory = ipojoHelper.getFactory("composite.export.5");
Properties props = new Properties();
props.put("instance.name", "export");
try {
export1 = factory.createComponentInstance(props);
} catch (Exception e) {
fail("Fail to instantiate exporter " + e.getMessage());
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestMultipleExport method setUp.
@Before
public void setUp() {
fooProvider = ipojoHelper.getFactory("BazProviderType");
assertNotNull("Check fooProvider availability", fooProvider);
Properties p1 = new Properties();
p1.put("instance.name", "foo1");
Properties p2 = new Properties();
p2.put("instance.name", "foo2");
try {
foo1 = fooProvider.createComponentInstance(p1);
foo2 = fooProvider.createComponentInstance(p2);
} catch (Exception e) {
fail("Fail to create foos : " + e.getMessage());
}
foo1.stop();
foo2.stop();
Factory factory = ipojoHelper.getFactory("composite.export.3");
Properties props = new Properties();
props.put("instance.name", "export");
try {
export3 = factory.createComponentInstance(props);
} catch (Exception e) {
fail("Fail to instantiate exporter " + e.getMessage());
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestOptionalMultipleExport method setUp.
@Before
public void setUp() {
fooProvider = ipojoHelper.getFactory("BazProviderType");
assertNotNull("Check fooProvider availability", fooProvider);
Properties p1 = new Properties();
p1.put("instance.name", "foo1");
Properties p2 = new Properties();
p2.put("instance.name", "foo2");
try {
foo1 = fooProvider.createComponentInstance(p1);
foo2 = fooProvider.createComponentInstance(p2);
} catch (Exception e) {
fail("Fail to create foos : " + e.getMessage());
}
foo1.stop();
foo2.stop();
Factory factory = ipojoHelper.getFactory("composite.export.4");
Properties props = new Properties();
props.put("instance.name", "export");
try {
export3 = factory.createComponentInstance(props);
} catch (Exception e) {
fail("Fail to instantiate exporter " + e.getMessage());
}
}
Aggregations