Updates the test suite:
- the manipulation test suite was split into 4 bundles in order to reduce the bundle size (for the MIKA VM).
- a test suite for Java 5 was created. This test suite focus on Java 5 specific features (annotation, auto-boxing, new inheritance features ...)
- a temporal test suite was improved to assert waiting time
- the configuration admin test suite was improved to test the integration with Equinox Configuration Admin and KF2 Configuration Admin (as well as the Felix configuration admin)
Those tests contain test about the Felix-739 issue

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@701978 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/manipulator/manipulator-java5/pom.xml b/ipojo/tests/manipulator/manipulator-java5/pom.xml
new file mode 100644
index 0000000..8725d78
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/pom.xml
@@ -0,0 +1,102 @@
+<!--

+	Licensed to the Apache Software Foundation (ASF) under one

+	or more contributor license agreements.  See the NOTICE file

+	distributed with this work for additional information

+	regarding copyright ownership.  The ASF licenses this file

+	to you under the Apache License, Version 2.0 (the

+	"License"); you may not use this file except in compliance

+	with the License.  You may obtain a copy of the License at

+	

+	http://www.apache.org/licenses/LICENSE-2.0

+	

+	Unless required by applicable law or agreed to in writing,

+	software distributed under the License is distributed on an

+	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+	KIND, either express or implied.  See the License for the

+	specific language governing permissions and limitations

+	under the License.

+-->

+<project>

+	<modelVersion>4.0.0</modelVersion>

+	<packaging>bundle</packaging>

+	<name>iPOJO Manipulation Test Suite For Java 5</name>

+	<artifactId>tests.manipulation.java5</artifactId>

+	<groupId>ipojo.tests</groupId>

+	<version>0.9.0-SNAPSHOT</version>

+	<dependencies>

+		<dependency>

+			<groupId>org.apache.felix</groupId>

+			<artifactId>org.apache.felix.ipojo</artifactId>

+			<version>0.9.0-SNAPSHOT</version>

+		</dependency>

+		<dependency>

+			<groupId>org.apache.felix</groupId>

+			<artifactId>org.apache.felix.ipojo.metadata</artifactId>

+			<version>0.9.0-SNAPSHOT</version>

+		</dependency>

+		<dependency>

+			<groupId>org.apache.felix</groupId>

+			<artifactId>org.osgi.core</artifactId>

+			<version>1.0.0</version>

+		</dependency>

+		<dependency>

+			<groupId>junit</groupId>

+			<artifactId>junit</artifactId>

+			<version>3.8.1</version>

+		</dependency>

+		<dependency>

+			<groupId>ipojo.examples</groupId>

+			<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>

+			<version>0.9.0-SNAPSHOT</version>

+		</dependency>

+	</dependencies>

+	<build>

+		<plugins>

+			<plugin>

+				<groupId>org.apache.felix</groupId>

+				<artifactId>maven-bundle-plugin</artifactId>

+				<version>1.4.2</version>

+				<extensions>true</extensions>

+				<configuration>

+					<instructions>

+						<Export-Package>

+							org.apache.felix.ipojo.test.scenarios.manipulation.service

+						</Export-Package>

+						<Bundle-SymbolicName>

+							${pom.artifactId}

+						</Bundle-SymbolicName>

+						<Private-Package>

+							org.apache.felix.ipojo.test*

+						</Private-Package>

+						<Test-Suite>

+							org.apache.felix.ipojo.test.scenarios.manipulation.ManipulationTestSuite

+						</Test-Suite>

+					</instructions>

+				</configuration>

+			</plugin>

+			<plugin>

+				<groupId>org.apache.felix</groupId>

+				<artifactId>maven-ipojo-plugin</artifactId>

+				<version>0.9.0-SNAPSHOT</version>

+				<executions>

+					<execution>

+						<goals>

+							<goal>ipojo-bundle</goal>

+						</goals>

+						<configuration>

+							<ignoreAnnotations>true</ignoreAnnotations>

+						</configuration>

+					</execution>

+				</executions>

+			</plugin>

+			<plugin>

+				<groupId>org.apache.maven.plugins</groupId>

+				<artifactId>maven-compiler-plugin</artifactId>

+				<configuration>

+					<source>1.5</source>

+					<target>1.5</target>

+				</configuration>

+			</plugin>

+		</plugins>

+	</build>

+</project>

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Annotation.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Annotation.java
new file mode 100644
index 0000000..0e21b2c
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Annotation.java
@@ -0,0 +1,29 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import org.apache.felix.ipojo.test.scenarios.component.Marker.Type;
+
+public class Annotation {
+    
+    @Marker(name="marker", type=Type.BAR, 
+            sub=@SubMarker(subname="foo"),
+            arrayOfObjects={"foo", "bar", "baz"},
+            arrayOfAnnotations= {@SubMarker(subname="foo")}
+    )
+    @SubMarker(subname="bar")
+    @Invisible
+    public void doSomething() {
+        System.out.println("Foo ...");
+    }
+    
+    @Marker(name="marker", type=Type.BAR, 
+            sub=@SubMarker(subname="foo"),
+            arrayOfObjects={"foo", "bar", "baz"},
+            arrayOfAnnotations= {@SubMarker(subname="foo")}
+    )
+    @SubMarker(subname="bar")
+    @Invisible
+    public Annotation() {
+        
+    }
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Invisible.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Invisible.java
new file mode 100644
index 0000000..2026df9
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Invisible.java
@@ -0,0 +1,5 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+public @interface Invisible {
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
new file mode 100644
index 0000000..fb273c5
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
@@ -0,0 +1,124 @@
+/* 

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.felix.ipojo.test.scenarios.component;

+

+import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;

+

+

+public class Manipulation23Tester implements PrimitiveManipulationTestService {

+	

+	// Integer types

+	byte b = 1;

+	short s = 1;

+	int i = 1;

+	long l = 1;

+	

+	// Floatting types

+	double d = 1.1;

+	float f = 1.1f;

+	

+	// Character

+	char c = 'a';

+	

+	// Boolean

+	boolean bool = false;

+	

+	// Integer arrays 

+	byte[] bs = new byte[] {0,1,2};

+	short[] ss = new short[] {0,1,2};

+	int[] is = new int[] {0,1,2};

+	long[] ls = new long[] {0,1,2};

+	

+	double[] ds = new double[] {0.0, 1.1, 2.2};

+	float[] fs = new float[] {0.0f, 1.1f, 2.2f};

+	

+	char[] cs = new char[] {'a', 'b', 'c'};

+	

+	boolean[] bools = new boolean[] {false, true, false};

+

+	public boolean getBoolean() { return bool; }

+

+	public boolean[] getBooleans() { return bools; }

+

+	public byte getByte() { return b; }

+

+	public byte[] getBytes() { return bs; }

+

+	public char getChar() { return c; }

+

+	public char[] getChars() { return cs; }

+

+	public double getDouble() { return d; }

+

+	public double[] getDoubles() { return ds; }

+

+	public float getFloat() { return f; }

+

+	public float[] getFloats() { return fs; }

+

+	public int getInt() { return i; }

+

+	public int[] getInts() { return is; }

+

+	public long getLong() { return l; }

+

+	public long[] getLongs() { return ls; }

+

+	public short getShort() { return s; }

+

+	public short[] getShorts() { return ss; }

+

+	public void setBoolean(boolean b) { this.bool = b; }

+

+	public void setBooleans(boolean[] bs) { this.bools = bs; }

+

+	public void setByte(byte b) { this.b = b; }

+

+	public void setBytes(byte[] bs) { this.bs = bs; }

+

+	public void setChar(char c) { this.c = c; }

+

+	public void setChars(char[] cs) { this.cs = cs; }

+

+	public void setDouble(double d) { this.d = d; }

+

+	public void setDoubles(double[] ds) { this.ds = ds; }

+

+	public void setFloat(float f) { this.f = f; }

+

+	public void setFloats(float[] fs) { this.fs = fs; }

+

+	public void setInt(int i) { this.i = i; }

+

+	public void setInts(int[] is) { this.is = is; }

+

+	public void setLong(long l) { this.l = l; }

+

+	public void setLongs(long[] ls) { this.ls = ls; }

+

+ 	public void setShort(short s) { this.s = s; }

+

+	public void setShorts(short[] ss) { this.ss = ss; }	

+	

+	// This method has been added to test an issue when autoboxing.

+	public void setLong(long l, String s) {

+	    this.l = l;

+	}

+

+}

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Marker.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Marker.java
new file mode 100644
index 0000000..98252eb
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Marker.java
@@ -0,0 +1,21 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Marker {
+    
+    String name();
+    
+    String[] arrayOfObjects();
+    
+    SubMarker sub();
+    
+    SubMarker[] arrayOfAnnotations();
+    
+    Type type();
+    
+    public enum Type {FOO, BAR, BAZ};
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PlopImpl.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PlopImpl.java
new file mode 100644
index 0000000..005dc0c
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PlopImpl.java
@@ -0,0 +1,11 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.Plop;
+//TODO this test requires source compatibility 1.5
+public class PlopImpl implements Plop {
+
+    public String getPlop() {
+        return "plop";
+    }
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SubMarker.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SubMarker.java
new file mode 100644
index 0000000..4ee14b9
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/component/SubMarker.java
@@ -0,0 +1,12 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface SubMarker {
+    
+    String subname();
+
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Annotation.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Annotation.java
new file mode 100644
index 0000000..0dba85d
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Annotation.java
@@ -0,0 +1,120 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.component.Marker;
+import org.apache.felix.ipojo.test.scenarios.component.SubMarker;
+
+public class Annotation extends OSGiTestCase {
+    
+    private Class clazz;
+    
+    public void setUp() {
+        try {
+            clazz = context.getBundle().
+                loadClass("org.apache.felix.ipojo.test.scenarios.component.Annotation");
+        } catch (ClassNotFoundException e) {
+            fail("Cannot load the annotation class : " + e.getMessage());
+        }
+    }
+    
+    public void testAnnotationOnMethod() {
+        Method method = null;
+        try {
+            method = this.clazz.getMethod("doSomething", new Class[0]);
+        } catch (Exception e) {
+            fail("Cannot find the doSomething method : " + e.getMessage());
+        } 
+        assertNotNull("Check method existence", method);
+        
+        java.lang.annotation.Annotation[] annotations = method.getDeclaredAnnotations();
+        assertNotNull("Check annotations size - 1", annotations);
+        assertEquals("Check annotations size - 2", 2, annotations.length); // Invisible is not visible
+        
+        /*
+            @Marker(name="marker", type=Type.BAR, 
+            sub=@SubMarker(subname="foo"),
+            arrayOfObjects={"foo", "bar", "baz"},
+            arrayOfAnnotations= {@SubMarker(subname="foo")}
+            )
+            @SubMarker(subname="bar")
+            @Invisible
+         */
+        
+        Marker marker = getMarkerAnnotation(annotations);
+        assertNotNull("Check marker", marker);
+        
+        assertEquals("Check marker name", "marker", marker.name());
+        assertEquals("Check marker type", Marker.Type.BAR, marker.type());
+        assertEquals("Check sub marker attribute", "foo", marker.sub().subname());
+        assertEquals("Check objects [0]", "foo", marker.arrayOfObjects()[0]);
+        assertEquals("Check objects [1]", "bar", marker.arrayOfObjects()[1]);
+        assertEquals("Check objects [2]", "baz", marker.arrayOfObjects()[2]);
+        assertEquals("Check annotations[0]", "foo", marker.arrayOfAnnotations()[0].subname());
+        
+        SubMarker sub = getSubMarkerAnnotation(annotations);
+        assertNotNull("Check submarker", sub);
+        assertEquals("Check submarker", "bar", sub.subname());
+        
+    }
+    
+    public void testAnnotationOnConstructor() {
+        Constructor method = null;
+        try {
+            method = clazz.getConstructor(new Class[0]);
+        } catch (Exception e) {
+            fail("Cannot find the constructor method : " + e.getMessage());
+        } 
+        assertNotNull("Check method existence", method);
+        
+        java.lang.annotation.Annotation[] annotations = method.getDeclaredAnnotations();
+        assertNotNull("Check annotations size - 1", annotations);
+        assertEquals("Check annotations size - 2", 2, annotations.length); // Invisible is not visible
+        
+        /*
+            @Marker(name="marker", type=Type.BAR, 
+            sub=@SubMarker(subname="foo"),
+            arrayOfObjects={"foo", "bar", "baz"},
+            arrayOfAnnotations= {@SubMarker(subname="foo")}
+            )
+            @SubMarker(subname="bar")
+            @Invisible
+         */
+        
+        Marker marker = getMarkerAnnotation(annotations);
+        assertNotNull("Check marker", marker);
+        
+        assertEquals("Check marker name", "marker", marker.name());
+        assertEquals("Check marker type", Marker.Type.BAR, marker.type());
+        assertEquals("Check sub marker attribute", "foo", marker.sub().subname());
+        assertEquals("Check objects [0]", "foo", marker.arrayOfObjects()[0]);
+        assertEquals("Check objects [1]", "bar", marker.arrayOfObjects()[1]);
+        assertEquals("Check objects [2]", "baz", marker.arrayOfObjects()[2]);
+        assertEquals("Check annotations[0]", "foo", marker.arrayOfAnnotations()[0].subname());
+        
+        SubMarker sub = getSubMarkerAnnotation(annotations);
+        assertNotNull("Check submarker", sub);
+        assertEquals("Check submarker", "bar", sub.subname());
+    }
+    
+    private Marker getMarkerAnnotation(java.lang.annotation.Annotation[] annotations) {
+        for (int i = 0; i < annotations.length; i++) {
+            if (annotations[i].annotationType().getName().equals("org.apache.felix.ipojo.test.scenarios.component.Marker")) {
+                return (Marker) annotations[i];
+            }
+        }
+        return null;
+    }
+    
+    private SubMarker getSubMarkerAnnotation(java.lang.annotation.Annotation[] annotations) {
+        for (int i = 0; i < annotations.length; i++) {
+            if (annotations[i].annotationType().getName().equals("org.apache.felix.ipojo.test.scenarios.component.SubMarker")) {
+                return (SubMarker) annotations[i];
+            }
+        }
+        return null;
+    }
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Boxing.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Boxing.java
new file mode 100644
index 0000000..2a800c1
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/Boxing.java
@@ -0,0 +1,50 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class Boxing extends OSGiTestCase {
+    
+    ComponentInstance instance; // Instance under test
+
+    PrimitiveManipulationTestService prim;
+
+    ServiceReference prim_ref;
+
+    public void setUp() {
+        Properties p1 = new Properties();
+        p1.put("instance.name","primitives");
+        instance = Utils.getComponentInstance(context, "ManipulationPrimitives5-PrimitiveManipulationTester", p1);
+        assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
+        prim_ref = Utils.getServiceReferenceByName(context, PrimitiveManipulationTestService.class.getName(), instance.getInstanceName());
+        assertNotNull("Check prim availability", prim_ref);
+        prim = (PrimitiveManipulationTestService) context.getService(prim_ref);
+    }
+
+    public void tearDown() {
+        context.ungetService(prim_ref);
+        prim = null;
+        instance.dispose();
+        instance = null;
+    }
+    
+  public void testLongFromObject() {
+      assertEquals("Check - 1", prim.getLong(), 1);
+      Long l = new Long(2);
+      prim.setLong(l);
+      assertEquals("Check - 2", prim.getLong(), 2);
+  }
+
+  public void testLongFromObject2() {
+      assertEquals("Check - 1", prim.getLong(), 1);
+      Long l = new Long(2);
+      prim.setLong(l, "ss");
+      assertEquals("Check - 2", prim.getLong(), 2);
+  }
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/DuplicateMethod.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/DuplicateMethod.java
new file mode 100644
index 0000000..439135c
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/DuplicateMethod.java
@@ -0,0 +1,22 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.Plop;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class DuplicateMethod extends OSGiTestCase {
+    
+    
+    public void testDuplicateMethod() {
+        ComponentInstance instance = Utils.getComponentInstanceByName(context, "plopimpl", "plop");
+        ServiceReference ref = Utils.getServiceReferenceByName(context, Plop.class.getName(), "plop");
+        assertNotNull("Check plop", ref);
+        Plop plop = (Plop) context.getService(ref);
+        Object o = plop.getPlop();
+        assertEquals("Check result", "plop", o);
+        context.ungetService(ref);
+        instance.dispose();
+    }
+}
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
new file mode 100644
index 0000000..a744419
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
@@ -0,0 +1,36 @@
+/* 

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.felix.ipojo.test.scenarios.manipulation;

+

+import junit.framework.Test;

+

+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;

+import org.osgi.framework.BundleContext;

+

+public class ManipulationTestSuite {

+

+	public static Test suite(BundleContext bc) {

+		OSGiTestSuite ots = new OSGiTestSuite("Manipulation Test Suite for Java 5", bc);

+        ots.addTestSuite(DuplicateMethod.class);

+        ots.addTestSuite(Boxing.class);

+        ots.addTestSuite(Annotation.class);

+		return ots;

+	}

+

+}

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
new file mode 100644
index 0000000..dfe2b9c
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java
@@ -0,0 +1,29 @@
+/* 

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.felix.ipojo.test.scenarios.manipulation.service;

+

+import java.util.Properties;

+

+public interface BarService {

+	

+	public boolean bar();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
new file mode 100644
index 0000000..ef7e1ee
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java
@@ -0,0 +1,31 @@
+/* 

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.felix.ipojo.test.scenarios.manipulation.service;

+

+import java.util.Properties;

+

+public interface CheckService {

+    

+    public static final String foo = "foo";

+	

+	public boolean check();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
new file mode 100644
index 0000000..f1e8dc0
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java
@@ -0,0 +1,39 @@
+/* 

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.felix.ipojo.test.scenarios.manipulation.service;

+

+import java.util.Properties;

+

+public interface FooService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
new file mode 100644
index 0000000..1bb177c
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.test.scenarios.manipulation.service;
+
+public interface Plop {
+    
+   Object getPlop();
+
+}
diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
new file mode 100644
index 0000000..cd61e3b
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java
@@ -0,0 +1,75 @@
+/* 

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.felix.ipojo.test.scenarios.manipulation.service;

+

+public interface PrimitiveManipulationTestService {

+	

+	byte getByte();

+	void setByte(byte b);

+	

+	short getShort();

+	void setShort(short s);

+	

+	int getInt();

+	void setInt(int i);

+	

+	long getLong();

+	void setLong(long l);

+	

+	float getFloat();

+	void setFloat(float f);

+	

+	double getDouble();

+	void setDouble(double d);

+	

+	char getChar();

+	void setChar(char c);

+	

+	boolean getBoolean();

+	void setBoolean(boolean b);

+	

+	// Array types

+	byte[] getBytes();

+	void setBytes(byte[] bs);

+	

+	short[] getShorts();

+	void setShorts(short[] ss);

+	

+	int[] getInts();

+	void setInts(int is[]);

+	

+	long[] getLongs();

+	void setLongs(long[] ls);

+	

+	float[] getFloats();

+	void setFloats(float[] fs);

+	

+	double[] getDoubles();

+	void setDoubles(double[] ds);

+	

+	char[] getChars();

+	void setChars(char[] cs);

+	

+	boolean[] getBooleans();

+	void setBooleans(boolean[] bs);	

+	

+	// This method has been added to test an issue when autoboxing.

+	void setLong(long l, String s);

+

+}

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
new file mode 100644
index 0000000..bcec3d5
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -0,0 +1,329 @@
+/* 

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.felix.ipojo.test.scenarios.util;

+

+import java.util.Dictionary;

+import java.util.Properties;

+

+import junit.framework.Assert;

+

+import org.apache.felix.ipojo.ComponentInstance;

+import org.apache.felix.ipojo.Factory;

+import org.apache.felix.ipojo.Handler;

+import org.apache.felix.ipojo.HandlerManagerFactory;

+import org.apache.felix.ipojo.ServiceContext;

+import org.apache.felix.ipojo.architecture.Architecture;

+//import org.apache.felix.ipojo.composite.CompositeManager;

+import org.osgi.framework.BundleContext;

+import org.osgi.framework.InvalidSyntaxException;

+import org.osgi.framework.ServiceReference;

+import org.osgi.service.cm.ManagedServiceFactory;

+

+public class Utils {

+

+    public static Factory getFactoryByName(BundleContext bc, String factoryName) {

+        ServiceReference[] refs;

+        try {

+            refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");

+            if (refs == null) {

+                System.err.println("Cannot get the factory " + factoryName);

+                return null;

+            }

+            return ((Factory) bc.getService(refs[0]));

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

+            return null;

+        }

+    }

+

+    public static HandlerManagerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {

+        ServiceReference[] refs;

+        try {

+            refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");

+            if (refs == null) {

+                System.err.println("Cannot get the factory " + factoryName);

+                return null;

+            }

+            return (HandlerManagerFactory) bc.getService(refs[0]);

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

+            return null;

+        }

+    }

+

+    public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {

+        Factory fact = getFactoryByName(bc, factoryName);

+

+        if (fact == null) {

+            System.err.println("Factory " + factoryName + " not found");

+            return null;

+        }

+

+        // if(fact.isAcceptable(configuration)) {

+        try {

+            return fact.createComponentInstance(configuration);

+        } catch (Exception e) {

+            e.printStackTrace();

+            Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());

+            return null;

+        }

+        // }

+        // else {

+        // System.err.println("Configuration not accepted by : " + factoryName);

+        // return null;

+        // }

+    }

+

+    public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {

+        Factory fact = getFactoryByName(bc, factoryName);

+

+        if (fact == null) {

+            System.err.println("Factory " + factoryName + " not found");

+            return null;

+        }

+

+        try {

+            Properties props = new Properties();

+            props.put("instance.name",name);

+            return fact.createComponentInstance(props);

+        } catch (Exception e) {

+            System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());

+            e.printStackTrace();

+            return null;

+        }

+    }

+

+    public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {

+        ServiceReference[] refs = null;

+        try {

+            refs = bc.getServiceReferences(itf, filter);

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Invalid Filter : " + filter);

+        }

+        if (refs == null) {

+            return new ServiceReference[0];

+        } else {

+            return refs;

+        }

+    }

+

+    public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {

+        ServiceReference[] refs = null;

+        try {

+            refs = bc.getServiceReferences(itf, filter);

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Invalid Filter : " + filter);

+        }

+        if (refs == null) {

+            return null;

+        } else {

+            return refs[0];

+        }

+    }

+

+    public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {

+        ServiceReference[] refs = null;

+        String filter = null;

+        if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {

+            filter = "(" + "factory.name" + "=" + name + ")";

+        } else if (itf.equals(Architecture.class.getName())) {

+            filter = "(" + "architecture.instance" + "=" + name + ")";

+        } else {

+            filter = "(" + "instance.name" + "=" + name + ")";

+        }

+        try {

+            refs = bc.getServiceReferences(itf, filter);

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Invalid Filter : " + filter);

+        }

+        if (refs == null) {

+            return null;

+        } else {

+            return refs[0];

+        }

+    }

+    

+    public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {

+        ServiceReference[] refs = null;

+        String filter = "(" + "service.pid" + "=" + pid + ")";

+        try {

+            refs = bc.getServiceReferences(itf, filter);

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Invalid Filter : " + filter);

+        }

+        if (refs == null) {

+            return null;

+        } else if (refs.length == 1) {

+            return refs[0];

+        } else {

+            Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);

+            return null;

+        }

+    }

+

+    public static Object getServiceObject(BundleContext bc, String itf, String filter) {

+        ServiceReference ref = getServiceReference(bc, itf, filter);

+        if (ref != null) {

+            return bc.getService(ref);

+        } else {

+            return null;

+        }

+    }

+

+    public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {

+        ServiceReference[] refs = getServiceReferences(bc, itf, filter);

+        if (refs != null) {

+            Object[] list = new Object[refs.length];

+            for (int i = 0; i < refs.length; i++) {

+                list[i] = bc.getService(refs[i]);

+            }

+            return list;

+        } else {

+            return new Object[0];

+        }

+    }

+

+//    public static ServiceContext getServiceContext(ComponentInstance ci) {

+//        if (ci instanceof CompositeManager) {

+//            return ((CompositeManager) ci).getServiceContext();

+//        } else {

+//            throw new RuntimeException("Cannot get the service context form an non composite instance");

+//        }

+//    }

+

+    public static Factory getFactoryByName(ServiceContext bc, String factoryName) {

+        ServiceReference[] refs;

+        try {

+            refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");

+            if (refs == null) { return null; }

+            return ((Factory) bc.getService(refs[0]));

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());

+            return null;

+        }

+    }

+

+    public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {

+        Factory fact = getFactoryByName(bc, factoryName);

+

+        if (fact == null) { return null; }

+

+        if (fact.isAcceptable(configuration)) {

+            try {

+                return fact.createComponentInstance(configuration);

+            } catch (Exception e) {

+                System.err.println(e.getMessage());

+                e.printStackTrace();

+                return null;

+            }

+        } else {

+            System.err.println("Configuration not accepted by : " + factoryName);

+            return null;

+        }

+    }

+

+    public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {

+        ServiceReference[] refs = null;

+        try {

+            refs = bc.getServiceReferences(itf, filter);

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Invalid Filter : " + filter);

+        }

+        if (refs == null) {

+            return new ServiceReference[0];

+        } else {

+            return refs;

+        }

+    }

+

+    public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {

+        ServiceReference[] refs = null;

+        try {

+            refs = bc.getServiceReferences(itf, filter);

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Invalid Filter : " + filter);

+        }

+        if (refs == null) {

+            return null;

+        } else {

+            return refs[0];

+        }

+    }

+

+    public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {

+        ServiceReference[] refs = null;

+        String filter = null;

+        if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {

+            filter = "(" + "factory.name" + "=" + name + ")";

+        } else {

+            filter = "(" + "instance.name" + "=" + name + ")";

+        }

+        try {

+            refs = bc.getServiceReferences(itf, filter);

+        } catch (InvalidSyntaxException e) {

+            System.err.println("Invalid Filter : " + filter);

+        }

+        if (refs == null) {

+            return null;

+        } else {

+            return refs[0];

+        }

+    }

+

+    public static Object getServiceObject(ServiceContext bc, String itf, String filter) {

+        ServiceReference ref = getServiceReference(bc, itf, filter);

+        if (ref != null) {

+            return bc.getService(ref);

+        } else {

+            return null;

+        }

+    }

+

+    public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {

+        ServiceReference[] refs = getServiceReferences(bc, itf, filter);

+        if (refs != null) {

+            Object[] list = new Object[refs.length];

+            for (int i = 0; i < refs.length; i++) {

+                list[i] = bc.getService(refs[i]);

+            }

+            return list;

+        } else {

+            return new Object[0];

+        }

+    }

+    

+    public static boolean contains(String string, String[] array) {

+        for (int i = 0; array != null && i < array.length; i++) {

+            if (array[i] != null  && array[i].equals(string)) {

+                return true;

+            }

+        }

+        return false;

+    }

+    

+    public static boolean contains(int value, int[] array) {

+        for (int i = 0; array != null && i < array.length; i++) {

+            if (array[i] == value) {

+                return true;

+            }

+        }

+        return false;

+    }

+

+}

diff --git a/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml b/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml
new file mode 100644
index 0000000..2c781ed
--- /dev/null
+++ b/ipojo/tests/manipulator/manipulator-java5/src/main/resources/metadata.xml
@@ -0,0 +1,21 @@
+<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">

+		<provides></provides>

+	</component>

+	

+	<component

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

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

+		<provides />

+	</component>

+	

+	<component

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

+	    name="Manipulation-Annotations"/>

+</ipojo>