use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestOptionalImport method setUp.
@Before
public void setUp() {
osgiHelper.waitForService(Factory.class, "(factory.name=COMPO-FooProviderType-1)", 1000);
fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");
assertNotNull("Check fooProvider availability", fooProvider);
Properties p = new Properties();
p.put("instance.name", "importer");
Factory compFact = ipojoHelper.getFactory("composite.requires.3");
try {
import3 = compFact.createComponentInstance(p);
} catch (Exception e) {
fail("Cannot instantiate the component : " + e.getMessage());
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestOptionalMultipleImport method setUp.
@Before
public void setUp() {
osgiHelper.waitForService(Factory.class, "(factory.name=COMPO-FooProviderType-1)", 1000);
fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");
assertNotNull("Check fooProvider availability", fooProvider);
Properties p = new Properties();
p.put("instance.name", "importer");
Factory compFact = ipojoHelper.getFactory("composite.requires.4");
try {
import2 = compFact.createComponentInstance(p);
} catch (Exception e) {
fail("Cannot instantiate the component : " + e.getMessage());
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestMultipleInstantiation method setUp.
@Before
public void setUp() {
bar2Factory = (ComponentFactory) ipojoHelper.getFactory("composite.bar.2");
Factory fact = ipojoHelper.getFactory("composite.empty");
Properties props = new Properties();
props.put("instance.name", "empty");
try {
empty = fact.createComponentInstance(props);
} catch (Exception e) {
fail("Cannot create the empty composite : " + e.getMessage());
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestOptionalMultipleInstantiation method setUp.
@Before
public void setUp() {
bar2Factory = (ComponentFactory) ipojoHelper.getFactory("composite.bar.4");
assertNotNull("Check bar2factory availability", bar2Factory);
Factory fact = ipojoHelper.getFactory("composite.empty");
Properties props = new Properties();
props.put("instance.name", "empty");
try {
empty = fact.createComponentInstance(props);
} catch (Exception e) {
fail("Cannot create the empty composite : " + e.getMessage());
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class EmptyCompositeTest method testEmptyCompositeCreation.
@Test
public void testEmptyCompositeCreation() {
Factory factory = ipojoHelper.getFactory("composite.empty");
Properties props = new Properties();
props.put("instance.name", "empty");
ComponentInstance ci = null;
try {
ci = factory.createComponentInstance(props);
} catch (Exception e) {
e.printStackTrace();
fail("Unacceptable configuration : " + e.getMessage());
}
ComponentTypeDescription cd = ci.getFactory().getComponentDescription();
assertEquals("Check component type name", cd.getName(), "composite.empty");
// assertEquals("Check class name (" + cd.getClassName() + ")", cd.getClassName(), "composite");
assertEquals("Check offered service", cd.getprovidedServiceSpecification().length, 0);
assertEquals("Check configurable properties", cd.getProperties().length, 0);
CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();
assertEquals("Check composite instance name", id.getName(), "empty");
assertEquals("Check composite instance state (" + id.getState() + ")", id.getState(), ComponentInstance.VALID);
assertEquals("Check contained instance", id.getContainedInstances().length, 0);
assertTrue("Check composite manager", ci instanceof CompositeManager);
CompositeManager cm = (CompositeManager) ci;
ServiceContext sc = cm.getServiceContext();
try {
assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);
} catch (InvalidSyntaxException e) {
fail("Invalid filter : " + e.getMessage());
}
ci.dispose();
}
Aggregations