use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestUnacceptableConfiguration method testDynamicJustEnoughOpt.
/**
* Check good configuration.
*/
@Test
public void testDynamicJustEnoughOpt() {
Factory f = ipojoHelper.getFactory("Factories-FooProviderType-Dyn2opt");
Properties p = new Properties();
p.put("instance.name", "ok");
p.put("boolean", true);
p.put("string", "absdir");
p.put("strAProp", new String[] { "a" });
ComponentInstance ci;
try {
ci = f.createComponentInstance(p);
ci.dispose();
} catch (Exception e) {
fail("An acceptable configuration is rejected : " + e.getMessage());
}
p = new Properties();
p.put("instance.name", "ok");
p.put("boolean", true);
p.put("strAProp", new String[] { "a" });
try {
ci = f.createComponentInstance(p);
ci.dispose();
} catch (Exception e) {
fail("An acceptable configuration is rejected : " + e.getMessage());
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestUnacceptableConfiguration method testDynamicJustEnough.
/**
* Check good configuration.
*/
@Test
public void testDynamicJustEnough() {
Factory f = ipojoHelper.getFactory("Factories-FooProviderType-Dyn2");
Properties p = new Properties();
p.put("instance.name", "ok");
p.put("boolean", true);
p.put("string", "absdir");
p.put("strAProp", new String[] { "a" });
ComponentInstance ci;
try {
ci = f.createComponentInstance(p);
ci.dispose();
} catch (Exception e) {
fail("An acceptable configuration is rejected : " + e.getMessage());
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestUnacceptableConfiguration method testDynamicUncompleteOpt.
/**
* Check uncomplete configuration.
*/
@Test
public void testDynamicUncompleteOpt() {
Factory f = ipojoHelper.getFactory("Factories-FooProviderType-Dyn2opt");
Properties p = new Properties();
p.put("instance.name", "ok");
p.put("string", "absdir");
p.put("strAProp", new String[] { "a" });
p.put("intAProp", new int[] { 1, 2 });
ComponentInstance ci;
try {
ci = f.createComponentInstance(p);
ci.dispose();
} catch (Exception e) {
fail("An acceptable configuration is refused");
}
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestUnacceptableConfiguration method testUnicity3.
/**
* Check instance name unicity.
*/
@Test
public void testUnicity3() {
Factory f = ipojoHelper.getFactory("Factories-FooProviderType-2");
ComponentInstance ci1 = null, ci2;
try {
Properties p1 = new Properties();
p1.put("instance.name", "name1");
ci1 = f.createComponentInstance(p1);
Properties p2 = new Properties();
p2.put("instance.name", "name1");
ci2 = f.createComponentInstance(p2);
assertThat("Check name ci1, ci2", ci1.getInstanceName(), not(ci2.getInstanceName()));
ci1.dispose();
ci2.dispose();
} catch (Exception e) {
if (ci1 != null) {
ci1.dispose();
}
// OK.
return;
}
fail("An unacceptable configuration is acceptable");
}
use of org.apache.felix.ipojo.Factory in project felix by apache.
the class TestUnacceptableConfiguration method testDoublePropsOpt.
/**
* Check properties affecting services and component.
*/
@Test
public void testDoublePropsOpt() {
Factory f = ipojoHelper.getFactory("Factories-FooProviderType-Dyn2opt");
Properties p = new Properties();
p.put("instance.name", "ok");
p.put("int", 3);
p.put("boolean", true);
p.put("string", "absdir");
p.put("strAProp", new String[] { "a" });
p.put("intAProp", new int[] { 1, 2 });
p.put("boolean", false);
p.put("string", "toto");
ComponentInstance ci;
try {
ci = f.createComponentInstance(p);
ci.dispose();
} catch (Exception e) {
fail("An acceptable configuration is rejected : " + e.getMessage());
}
}
Aggregations