Export the helper package of junit4osgi.
Add a test on Java 5 manipulation about generics (injection of typed lists).

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@708513 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/examples/junit4osgi/junit4osgi/pom.xml b/ipojo/examples/junit4osgi/junit4osgi/pom.xml
index 2496eab..1eae448 100644
--- a/ipojo/examples/junit4osgi/junit4osgi/pom.xml
+++ b/ipojo/examples/junit4osgi/junit4osgi/pom.xml
@@ -66,10 +66,11 @@
 						<Private-Package>

 							org.apache.felix.ipojo.junit4osgi.impl,

 							org.apache.felix.ipojo.junit4osgi.test,

-							org.apache.felix.ipojo.junit4osgi.helpers

 						</Private-Package>

 						<Export-Package>

-							org.apache.felix.ipojo.junit4osgi, junit.*

+							org.apache.felix.ipojo.junit4osgi, 

+							org.apache.felix.ipojo.junit4osgi.helpers,

+							junit.*

 						</Export-Package>

 						<Import-Package>!javax.swing*, *</Import-Package>

 						<Test-Suite>

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java
new file mode 100644
index 0000000..83f050c
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java
@@ -0,0 +1,44 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+
+public class FooServiceImpl implements FooService {
+
+    public boolean foo() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public Properties fooProps() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean getBoolean() {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public double getDouble() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public int getInt() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public long getLong() {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public Boolean getObject() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java
new file mode 100644
index 0000000..cc8e3b3
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java
@@ -0,0 +1,32 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+
+public class TestTypedList implements CheckService {
+    
+    private List<FooService> list;
+
+    public boolean check() {
+        return ! list.isEmpty();
+    }
+
+    public Properties getProps() {
+        Properties props = new Properties();
+        if (list != null) {
+            props.put("list", list);
+        
+            int i = 0;
+            for (FooService fs : list) {
+                props.put(i, fs.foo());
+                i++;
+            }
+        }
+        
+        return props;
+    }
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
index a744419..3cf22a3 100644
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
@@ -30,6 +30,7 @@
         ots.addTestSuite(DuplicateMethod.class);

         ots.addTestSuite(Boxing.class);

         ots.addTestSuite(Annotation.class);

+        ots.addTestSuite(TypedList.class);

 		return ots;

 	}

 

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java
new file mode 100644
index 0000000..b515a9e
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java
@@ -0,0 +1,67 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+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.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public class TypedList extends OSGiTestCase {
+    
+    ComponentInstance foo1, foo2;
+    ComponentInstance checker;
+    IPOJOHelper helper; 
+    
+    public void setUp() {
+        helper = new IPOJOHelper(this);
+        foo1 = helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.FooServiceImpl", "foo1");
+        foo2 = helper.createComponentInstance("org.apache.felix.ipojo.test.scenarios.component.FooServiceImpl", "foo2");
+        checker = helper.createComponentInstance("TypedList", "checker");
+        foo1.stop();
+        foo2.stop();
+    }
+    
+    public void tearDown() {
+        foo1.dispose();
+        foo2.dispose();
+        checker.dispose();
+    }
+    
+    public void testTypedList() {
+        ServiceReference ref = getServiceReferenceByName(CheckService.class.getName(), checker.getInstanceName()); 
+        CheckService check = (CheckService) context.getService(ref);
+        assertNotNull("Checker availability", check);
+        // Check without providers
+        assertFalse("Empty list", check.check());
+        
+        // Start the first provider
+        foo1.start();
+        assertTrue("List with one element", check.check());
+        Properties props = check.getProps();
+        List<FooService> list = (List<FooService>) props.get("list");
+        assertEquals("Check size - 1", 1, list.size());
+        
+        // Start the second provider 
+        foo2.start();
+        assertTrue("List with two element", check.check());
+        props = check.getProps();
+        list = (List<FooService>) props.get("list");
+        assertEquals("Check size - 2", 2, list.size());
+        
+        // Stop the first one
+        foo1.stop();
+        assertTrue("List with one element (2)", check.check());
+        props = check.getProps();
+        list = (List<FooService>) props.get("list");
+        assertEquals("Check size - 3", 1, list.size());
+        
+        context.ungetService(ref);
+    }
+    
+    
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml b/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml
index 2c781ed..f29916c 100644
--- a/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml
@@ -1,21 +1,30 @@
-<ipojo

-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

-    xsi:schemaLocation="org.apache.felix.ipojo http://people.apache.org/~clement/ipojo/schemas/core.xsd"

-    xmlns="org.apache.felix.ipojo"

->

+<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+	xsi:schemaLocation="org.apache.felix.ipojo http://people.apache.org/~clement/ipojo/schemas/core.xsd"

+	xmlns="org.apache.felix.ipojo">

 	

 	<!-- Check duplicate method issue -->

-	<component classname="org.apache.felix.ipojo.test.scenarios.component.PlopImpl" name="plopimpl">

+	<component classname="org.apache.felix.ipojo.test.scenarios.component.PlopImpl"

+		name="plopimpl">

 		<provides></provides>

 	</component>

-	

 	<component

 		classname="org.apache.felix.ipojo.test.scenarios.component.Manipulation23Tester"

-		name="ManipulationPrimitives5-PrimitiveManipulationTester" architecture="true">

+		name="ManipulationPrimitives5-PrimitiveManipulationTester"

+		architecture="true">

 		<provides />

 	</component>

-	

+	<component classname="org.apache.felix.ipojo.test.scenarios.component.Annotation"

+		name="Manipulation-Annotations" />

+	    

+	    

+	 <!-- Typed list -->

 	<component

-	    classname="org.apache.felix.ipojo.test.scenarios.component.Annotation"

-	    name="Manipulation-Annotations"/>

-</ipojo>

+		classname="org.apache.felix.ipojo.test.scenarios.component.FooServiceImpl">

+		<provides />

+	</component>

+	<component 

+	    classname="org.apache.felix.ipojo.test.scenarios.component.TestTypedList" name="TypedList">

+	    <provides/>

+	    <requires field="list" optional="true" specification="org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService"/>

+	</component>

+</ipojo>
\ No newline at end of file