Test case about Felix-967. (a default constructor delegates to another one with an argument)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@749557 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SeveralConstructors.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SeveralConstructors.java
new file mode 100644
index 0000000..b31278a
--- /dev/null
+++ b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SeveralConstructors.java
@@ -0,0 +1,31 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
+
+public class SeveralConstructors implements CheckService {
+
+
+ private String name;
+
+ public SeveralConstructors(){
+ this("hello world");
+ }
+
+ public SeveralConstructors(final String n) {
+ name = n;
+ }
+
+ public boolean check() {
+ return name != null;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("name", name);
+ return props;
+ }
+
+
+}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
index d589b18..11db1fa 100644
--- a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
+++ b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
@@ -28,6 +28,7 @@
public static Test suite(BundleContext bc) {
OSGiTestSuite ots = new OSGiTestSuite("Manipulation Creation Test Suite", bc);
ots.addTestSuite(POJOCreation.class);
+ ots.addTestSuite(SeveralConstructorTest.class);
return ots;
}
diff --git a/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/SeveralConstructorTest.java b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/SeveralConstructorTest.java
new file mode 100644
index 0000000..4978128
--- /dev/null
+++ b/ipojo/tests/manipulator/creation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/SeveralConstructorTest.java
@@ -0,0 +1,34 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
+import org.osgi.framework.ServiceReference;
+
+import org.apache.felix.ipojo.ComponentInstance;
+
+public class SeveralConstructorTest extends OSGiTestCase {
+
+ private IPOJOHelper helper;
+
+ private ComponentInstance ci;
+
+ public void setUp() {
+ helper = new IPOJOHelper(this);
+ ci = helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.SeveralConstructors");
+ }
+
+ public void tearDown() {
+ helper.dispose();
+ }
+
+
+ public void testSeveralConstructor() {
+ ServiceReference ref = helper.getServiceReferenceByName(CheckService.class.getName(), ci.getInstanceName());
+ CheckService cs = (CheckService) getServiceObject(ref);
+ assertTrue("Check assignation", cs.check());
+ String name = (String) cs.getProps().get("name");
+ assertEquals("Check message", "hello world", name);
+ }
+
+}
diff --git a/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml b/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml
index 34aa341..2b51486 100644
--- a/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml
+++ b/ipojo/tests/manipulator/creation/src/main/resources/metadata.xml
@@ -58,4 +58,9 @@
<!-- Try calling super constructors -->
<component classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructor" immediate="true"/>
<component classname="org.apache.felix.ipojo.test.scenarios.component.CallSuperConstructorWithBC" immediate="true"/>
+
+ <!-- Several constructors -->
+ <component classname="org.apache.felix.ipojo.test.scenarios.component.SeveralConstructors">
+ <provides/>
+ </component>
</ipojo>