Added distinct factory name to avoid name clash (changed because of FELIX-3789)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1423329 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/PrimitiveComponentTest.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/PrimitiveComponentTest.java
index de92867..469a348 100644
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/PrimitiveComponentTest.java
+++ b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/PrimitiveComponentTest.java
@@ -165,6 +165,7 @@
private PrimitiveComponentType createAnOptionalConsumer() {
return new SingletonComponentType()
.setBundleContext(context)
+ .setComponentTypeName("cons.optional")
.setClassName(org.example.service.impl.MyComponentImpl.class.getName())
.addDependency(new Dependency().setField("myFoo").setOptional(true))
.setValidateMethod("start");
diff --git a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/SingletonComponentTest.java b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/SingletonComponentTest.java
index 7023df8..732fa4d 100644
--- a/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/SingletonComponentTest.java
+++ b/ipojo/tests/api/src/test/java/org/apache/felix/ipojo/tests/api/SingletonComponentTest.java
@@ -1,17 +1,5 @@
package org.apache.felix.ipojo.tests.api;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.ops4j.pax.exam.CoreOptions.felix;
-import static org.ops4j.pax.exam.CoreOptions.knopflerfish;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.provision;
-
import org.apache.felix.ipojo.ComponentInstance;
import org.apache.felix.ipojo.ConfigurationException;
import org.apache.felix.ipojo.MissingHandlerException;
@@ -34,7 +22,11 @@
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import static org.ops4j.pax.exam.MavenUtils.*;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+import static org.ops4j.pax.exam.CoreOptions.*;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
@RunWith( JUnit4TestRunner.class )
@@ -84,6 +76,7 @@
ServiceReference ref = ipojo.getServiceReferenceByName(Foo.class
.getName(), ci.getInstanceName());
assertThat(ref, is(notNullValue()));
+ type.disposeInstance(ci);
}
@@ -114,23 +107,27 @@
ci = type.create();
assertThat("Ci is invalid", ci.getState(),
is(ComponentInstance.INVALID));
-
+ type.stop();
}
@Test
public void createBoth() throws Exception {
- ComponentInstance cons = createAConsumer().create();
+ SingletonComponentType consFactory = createAConsumer();
+ ComponentInstance cons = consFactory.create();
// cons is invalid
assertThat("cons is invalid", cons.getState(), is(ComponentInstance.INVALID));
- ComponentInstance prov = createAProvider().create();
+ SingletonComponentType provFactory = createAProvider();
+ ComponentInstance prov = provFactory.create();
assertThat("prov is valid", prov.getState(), is(ComponentInstance.VALID));
assertThat("cons is valid", cons.getState(), is(ComponentInstance.VALID));
-
+ consFactory.stop();
+ provFactory.stop();
}
@Test
public void createTwoCons() throws Exception {
+ SingletonComponentType consFactory = createAConsumer();
ComponentInstance cons1 = createAConsumer().create();
// cons is invalid
assertThat("cons is invalid", cons1.getState(), is(ComponentInstance.INVALID));
@@ -149,7 +146,7 @@
}
@Test
- @Ignore
+ @Ignore // TODO Why is this ignored ?
public void setObject() throws Exception {
ComponentInstance cons = createAConsumer().setObject(new MyComponentImpl(5)).create();
// cons is invalid
@@ -174,6 +171,7 @@
PrimitiveComponentType type = new SingletonComponentType()
.setBundleContext(context)
.setClassName(org.example.service.impl.MyComponentImpl.class.getName())
+ .setComponentTypeName("singleton.cons")
.addDependency(new Dependency().setField("myFoo"))
.setValidateMethod("start");
@@ -183,8 +181,9 @@
private SingletonComponentType createAnOptionalConsumer() {
PrimitiveComponentType type = new SingletonComponentType()
.setBundleContext(context)
- .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
+ .setClassName(MyComponentImpl.class.getName())
.addDependency(new Dependency().setField("myFoo").setOptional(true))
+ .setComponentTypeName("singleton.optional.consumer")
.setValidateMethod("start");
return (SingletonComponentType) type;