You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/10/28 11:28:56 UTC

svn commit: r708513 - in /felix/trunk/ipojo: examples/junit4osgi/junit4osgi/ tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/tes...

Author: clement
Date: Tue Oct 28 03:28:51 2008
New Revision: 708513

URL: http://svn.apache.org/viewvc?rev=708513&view=rev
Log:
Export the helper package of junit4osgi.
Add a test on Java 5 manipulation about generics (injection of typed lists).

Added:
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java
Modified:
    felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
    felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml

Modified: felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml?rev=708513&r1=708512&r2=708513&view=diff
==============================================================================
--- felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml (original)
+++ felix/trunk/ipojo/examples/junit4osgi/junit4osgi/pom.xml Tue Oct 28 03:28:51 2008
@@ -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>

Added: felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java?rev=708513&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java (added)
+++ felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooServiceImpl.java Tue Oct 28 03:28:51 2008
@@ -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;
+    }
+
+}

Added: felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java?rev=708513&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java (added)
+++ felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/TestTypedList.java Tue Oct 28 03:28:51 2008
@@ -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;
+    }
+
+}

Modified: felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java?rev=708513&r1=708512&r2=708513&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java (original)
+++ felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java Tue Oct 28 03:28:51 2008
@@ -30,6 +30,7 @@
         ots.addTestSuite(DuplicateMethod.class);
         ots.addTestSuite(Boxing.class);
         ots.addTestSuite(Annotation.class);
+        ots.addTestSuite(TypedList.class);
 		return ots;
 	}
 

Added: felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java?rev=708513&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java (added)
+++ felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/TypedList.java Tue Oct 28 03:28:51 2008
@@ -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);
+    }
+    
+    
+
+}

Modified: felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml?rev=708513&r1=708512&r2=708513&view=diff
==============================================================================
--- felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml (original)
+++ felix/trunk/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml Tue Oct 28 03:28:51 2008
@@ -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