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/primitives/pom.xml b/ipojo/tests/manipulator/primitives/pom.xml
new file mode 100644
index 0000000..7b6c101
--- /dev/null
+++ b/ipojo/tests/manipulator/primitives/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 Primitive Manipulation Test Suite</name>
+ <artifactId>tests.manipulation.primitives</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.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java
new file mode 100644
index 0000000..019980f
--- /dev/null
+++ b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/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.A123;
+
+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; }
+
+ public void setLong(long l, String s) {
+ this.l = l;
+ }
+
+}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java b/ipojo/tests/manipulator/primitives/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/primitives/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/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
new file mode 100644
index 0000000..e8116d2
--- /dev/null
+++ b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
@@ -0,0 +1,35 @@
+/*
+ * 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("Primitive Manipulation Test Suite", bc);
+ ots.addTestSuite(PrimitiveTypeTest.class);
+ ots.addTestSuite(PrimitiveTypeTest2.class);
+ return ots;
+ }
+
+}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
new file mode 100644
index 0000000..493d418
--- /dev/null
+++ b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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 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;
+
+/**
+ * Check the manipulation of primitive type (boxed and unboxed).
+ */
+public class PrimitiveTypeTest 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, "ManipulationPrimitives-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 testByte() {
+ assertEquals("Check - 1", prim.getByte(), 1);
+ prim.setByte((byte) 2);
+ assertEquals("Check - 2", prim.getByte(), 2);
+ }
+
+ public void testShort() {
+ assertEquals("Check - 1", prim.getShort(), 1);
+ prim.setShort((short) 2);
+ assertEquals("Check - 2", prim.getShort(), 2);
+ }
+
+ public void testInt() {
+ assertEquals("Check - 1", prim.getInt(), 1);
+ prim.setInt((int) 2);
+ assertEquals("Check - 2", prim.getInt(), 2);
+ }
+
+ public void testLong() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ prim.setLong((long) 2);
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+ public void testFloat() {
+ assertEquals("Check - 1", prim.getFloat(), 1.1f);
+ prim.setFloat(2.2f);
+ assertEquals("Check - 2", prim.getFloat(), 2.2f);
+ }
+
+ public void testDouble() {
+ assertEquals("Check - 1", prim.getDouble(), 1.1);
+ prim.setDouble(2.2);
+ assertEquals("Check - 2", prim.getDouble(), 2.2);
+ }
+
+ public void testBoolean() {
+ assertFalse("Check - 1", prim.getBoolean());
+ prim.setBoolean(true);
+ assertTrue("Check - 2", prim.getBoolean());
+ }
+
+ public void testChar() {
+ assertEquals("Check - 1", prim.getChar(), 'a');
+ prim.setChar('b');
+ assertEquals("Check - 2", prim.getChar(), 'b');
+ }
+
+
+}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java
new file mode 100644
index 0000000..2ef112b
--- /dev/null
+++ b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/PrimitiveTypeTest2.java
@@ -0,0 +1,114 @@
+/*
+ * 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 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;
+
+/**
+ * Check the manipulation of primitive type (boxed and unboxed).
+ * The targeted implementation contains numbers.
+ */
+public class PrimitiveTypeTest2 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, "ManipulationPrimitives-PrimitiveManipulationTesterA", 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 testByte() {
+ assertEquals("Check - 1", prim.getByte(), 1);
+ prim.setByte((byte) 2);
+ assertEquals("Check - 2", prim.getByte(), 2);
+ }
+
+ public void testShort() {
+ assertEquals("Check - 1", prim.getShort(), 1);
+ prim.setShort((short) 2);
+ assertEquals("Check - 2", prim.getShort(), 2);
+ }
+
+ public void testInt() {
+ assertEquals("Check - 1", prim.getInt(), 1);
+ prim.setInt((int) 2);
+ assertEquals("Check - 2", prim.getInt(), 2);
+ }
+
+ public void testLong() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ prim.setLong((long) 2);
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+ public void testLong2() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ prim.setLong(2, "ss");
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+
+
+ public void testFloat() {
+ assertEquals("Check - 1", prim.getFloat(), 1.1f);
+ prim.setFloat(2.2f);
+ assertEquals("Check - 2", prim.getFloat(), 2.2f);
+ }
+
+ public void testDouble() {
+ assertEquals("Check - 1", prim.getDouble(), 1.1);
+ prim.setDouble(2.2);
+ assertEquals("Check - 2", prim.getDouble(), 2.2);
+ }
+
+ public void testBoolean() {
+ assertFalse("Check - 1", prim.getBoolean());
+ prim.setBoolean(true);
+ assertTrue("Check - 2", prim.getBoolean());
+ }
+
+ public void testChar() {
+ assertEquals("Check - 1", prim.getChar(), 'a');
+ prim.setChar('b');
+ assertEquals("Check - 2", prim.getChar(), 'b');
+ }
+
+}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
new file mode 100644
index 0000000..5f5b74b
--- /dev/null
+++ b/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/CheckService2.java
@@ -0,0 +1,25 @@
+/*
+ * 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.A123;
+
+public interface CheckService2 {
+
+ public boolean check();
+
+}
diff --git a/ipojo/tests/manipulator/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/BarService.java b/ipojo/tests/manipulator/primitives/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/primitives/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/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/CheckService.java b/ipojo/tests/manipulator/primitives/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/primitives/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/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/FooService.java b/ipojo/tests/manipulator/primitives/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/primitives/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/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/Plop.java b/ipojo/tests/manipulator/primitives/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/primitives/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/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/PrimitiveManipulationTestService.java b/ipojo/tests/manipulator/primitives/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/primitives/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/primitives/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/manipulator/primitives/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/primitives/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/primitives/src/main/resources/metadata.xml b/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml
new file mode 100644
index 0000000..43474bb
--- /dev/null
+++ b/ipojo/tests/manipulator/primitives/src/main/resources/metadata.xml
@@ -0,0 +1,22 @@
+<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"
+>
+
+ <!-- Manipulation -->
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.Manipulation23Tester"
+ name="ManipulationPrimitives-PrimitiveManipulationTester" architecture="true">
+ <provides />
+ </component>
+
+ <!-- Manipulation with numbers -->
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.A123.Manipulation23Tester"
+ name="ManipulationPrimitives-PrimitiveManipulationTesterA" architecture="true">
+ <provides />
+ </component>
+
+
+</ipojo>