FELIX-3903 - Migrate manipulator tests to pax exam 3
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1449171 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/manipulator-it/pom.xml b/ipojo/manipulator/manipulator-it/pom.xml
new file mode 100644
index 0000000..5876650
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/pom.xml
@@ -0,0 +1,441 @@
+<!--
+ 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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix-parent</artifactId>
+ <version>1.2.1</version>
+ <relativePath>../../../pom/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.felix.ipojo.manipulator.manipulator-it</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ <name>Apache Felix iPOJO Runtime Project ~ Manipulator Integration Tests</name>
+ <packaging>pom</packaging>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>.</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>LICENSE*</include>
+ <include>NOTICE*</include>
+ <include>DEPENDENCIES*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>generate-config</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <properties>
+ <exam.version>3.0.0</exam.version>
+ <url.version>1.5.1</url.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-native</artifactId>
+ <version>${exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit4</artifactId>
+ <version>${exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-link-mvn</artifactId>
+ <version>${exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-aether</artifactId>
+ <version>${url.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>4.2.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <version>0.9.6</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <version>0.9.6</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.tinybundles</groupId>
+ <artifactId>tinybundles</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <!-- Define the tested version -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ </dependency>
+ <!-- End of tested version -->
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.6.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ow2.chameleon.testing</groupId>
+ <artifactId>osgi-helpers</artifactId>
+ <version>0.6.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ow2.chameleon.testing</groupId>
+ <artifactId>tinybundles-ipojo</artifactId>
+ <version>0.3.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.log</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-wrap</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>project</descriptorRef>
+ </descriptorRefs>
+ <!-- we don't want to attach all the assemblies, such as bz2 -->
+ <attach>false</attach>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!-- only attach the project and bin assemblies, in tar.gz and zip flavors -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-assemblies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>
+ ${project.build.directory}/${project.artifactId}-${project.version}-project.tar.gz
+ </file>
+ <classifier>project</classifier>
+ <type>tar.gz</type>
+ </artifact>
+ <artifact>
+ <file>
+ ${project.build.directory}/${project.artifactId}-${project.version}-project.zip
+ </file>
+ <classifier>project</classifier>
+ <type>zip</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>knopflerfish</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ <property>
+ <name>pax.exam.framework</name>
+ <value>knopflerfish</value>
+ </property>
+ </activation>
+ <properties>
+ <pax.exam.framework>knopflerfish</pax.exam.framework>
+ </properties>
+ <repositories>
+ <repository>
+ <id>knopflerfish-releases</id>
+ <url>http://www.knopflerfish.org/maven2</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>org.knopflerfish</groupId>
+ <artifactId>framework</artifactId>
+ <version>5.2.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <profile>
+ <id>equinox</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ <property>
+ <name>pax.exam.framework</name>
+ <value>equinox</value>
+ </property>
+ </activation>
+ <properties>
+ <pax.exam.framework>equinox</pax.exam.framework>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>3.8.1.v20120830-144521</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <profile>
+ <id>felix</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ <property>
+ <name>pax.exam.framework</name>
+ <value>felix</value>
+ </property>
+ </activation>
+ <properties>
+ <pax.exam.framework>felix</pax.exam.framework>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.framework</artifactId>
+ <version>4.2.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+ <profile>
+ <id>test</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>1.8</version>
+ <configuration>
+ <streamLogs>true</streamLogs>
+ <goals>
+ <goal>clean</goal>
+ <goal>test</goal>
+ </goals>
+ <cloneClean>true</cloneClean>
+ </configuration>
+ <executions>
+ <execution>
+ <id>regular</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <profiles>
+ <profile>felix</profile>
+ </profiles>
+ <cloneProjectsTo>${project.build.directory}/regular</cloneProjectsTo>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>test-all</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>1.8</version>
+ <configuration>
+ <streamLogs>true</streamLogs>
+ <goals>
+ <goal>clean</goal>
+ <goal>test</goal>
+ </goals>
+ <cloneClean>true</cloneClean>
+ </configuration>
+ <executions>
+ <execution>
+ <id>equinox-native</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <profiles>
+ <profile>equinox</profile>
+ </profiles>
+ <cloneProjectsTo>${project.build.directory}/equinox-native</cloneProjectsTo>
+
+ </configuration>
+ </execution>
+ <execution>
+ <id>felix-native</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <profiles>
+ <profile>felix</profile>
+ </profiles>
+ <cloneProjectsTo>${project.build.directory}/felix-native</cloneProjectsTo>
+ </configuration>
+ </execution>
+ <execution>
+ <id>knopflerfish-native</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <profiles>
+ <profile>knopflerfish</profile>
+ </profiles>
+ <cloneProjectsTo>${project.build.directory}/knopflerfish-native</cloneProjectsTo>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/pom.xml b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/pom.xml
new file mode 100644
index 0000000..6a16af6
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.manipulator.manipulator-it</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.felix</groupId>
+ <artifactId>ipojo-manipulator-creation-test</artifactId>
+
+ <name>${project.artifactId}</name>
+
+</project>
\ No newline at end of file
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ASimpleParentClass.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ASimpleParentClass.java
new file mode 100644
index 0000000..27b558b
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ASimpleParentClass.java
@@ -0,0 +1,11 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class ASimpleParentClass {
+
+ protected String name;
+
+ public ASimpleParentClass() {
+ name = "hello";
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructor.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructor.java
new file mode 100644
index 0000000..733a076
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructor.java
@@ -0,0 +1,10 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class CallSuperConstructor extends ParentClass {
+
+ public CallSuperConstructor() {
+ super("test");
+ System.out.println("plop");
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructorWithBC.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructorWithBC.java
new file mode 100644
index 0000000..06d0caa
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructorWithBC.java
@@ -0,0 +1,13 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.osgi.framework.BundleContext;
+
+public class CallSuperConstructorWithBC extends ParentClassWithBC {
+
+ public CallSuperConstructorWithBC(BundleContext bc) {
+ super("bc", bc, "bundle");
+ String message = "plop-bc";
+ System.out.println(message);
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructorWithNew.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructorWithNew.java
new file mode 100644
index 0000000..9b2ed76
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperConstructorWithNew.java
@@ -0,0 +1,10 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class CallSuperConstructorWithNew extends ParentClass {
+
+ public CallSuperConstructorWithNew() {
+ super(new StringBuffer("test"));
+ System.out.println("plop");
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperSuperConstructorWithNew.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperSuperConstructorWithNew.java
new file mode 100644
index 0000000..e556b21
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CallSuperSuperConstructorWithNew.java
@@ -0,0 +1,10 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class CallSuperSuperConstructorWithNew extends ParentClass2 {
+
+ public CallSuperSuperConstructorWithNew() {
+ super(new String("test"));
+ System.out.println("plop");
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
new file mode 100644
index 0000000..4d6add7
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
@@ -0,0 +1,117 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+public class FooProviderType1 implements FooService {
+
+ private int m_bar;
+ private String m_foo;
+
+ private BundleContext m_context;
+
+ private static FooProviderType1 singleton;
+ private static int count = 0;
+
+ private static FooProviderType1 singleton(BundleContext bc) {
+ if (singleton == null) {
+ count++;
+ singleton = new FooProviderType1(bc);
+ }
+ return singleton;
+ }
+
+ public static FooProviderType1 several(BundleContext bc) {
+ count++;
+ return new FooProviderType1(bc);
+ }
+
+ public FooProviderType1(BundleContext bc) {
+ if (bc ==null) {
+ throw new RuntimeException("Injected bundle context null");
+ }
+ m_context = bc;
+ }
+
+ public boolean foo() {
+ return true;
+ }
+
+ public Properties fooProps() {
+ Properties p = new Properties();
+ p.put("bar", new Integer(m_bar));
+ if(m_foo != null) {
+ p.put("foo", m_foo);
+ }
+ p.put("context", m_context);
+
+ p.put("count", new Integer(count));
+ return p;
+ }
+
+ public void testException() throws Exception {
+ String a = "foobarbaz";
+ throw new Exception("foo"+a);
+ }
+
+ public void testTry() {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ public void testTry2(String s) {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ private void nexttry(String s) {
+ try {
+ s += "foo";
+ } catch(RuntimeException e) {
+
+ }
+ }
+
+ public boolean getBoolean() { return true; }
+
+ public double getDouble() { return 1.0; }
+
+ public int getInt() { return 1; }
+
+ public long getLong() { return 1; }
+
+ public Boolean getObject() { return new Boolean(true); }
+
+ /**
+ * Custom constructor.
+ * @param bar
+ * @param foo
+ * @param bc
+ */
+ public FooProviderType1(int bar, String foo, BundleContext bc) {
+ m_bar = bar;
+ m_foo = foo;
+ m_context = bc;
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/NoEmptyConstructor.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/NoEmptyConstructor.java
new file mode 100644
index 0000000..4b57e25
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/NoEmptyConstructor.java
@@ -0,0 +1,31 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+
+import java.util.Properties;
+
+public class NoEmptyConstructor implements CheckService {
+
+
+ private String name;
+
+ public NoEmptyConstructor(final String n) {
+ name = n;
+ }
+
+ public boolean check() {
+ return name != null;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ if (name == null) {
+ props.put("name", "NULL");
+ } else {
+ props.put("name", name);
+ }
+ return props;
+ }
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/NoEmptyConstructorWithParentClass.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/NoEmptyConstructorWithParentClass.java
new file mode 100644
index 0000000..079cc44
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/NoEmptyConstructorWithParentClass.java
@@ -0,0 +1,27 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+
+import java.util.Properties;
+
+public class NoEmptyConstructorWithParentClass extends ASimpleParentClass implements CheckService {
+
+ public NoEmptyConstructorWithParentClass(final String n) {
+ name = n;
+ }
+
+ public boolean check() {
+ return name != null;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ if (name == null) {
+ props.put("name", "NULL");
+ } else {
+ props.put("name", name);
+ }
+ return props;
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass.java
new file mode 100644
index 0000000..b9de05f
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass.java
@@ -0,0 +1,15 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class ParentClass {
+
+ private String name;
+
+ public ParentClass(final String n) {
+ name = n;
+ }
+
+ public ParentClass(final StringBuffer n) {
+ name = n.toString();
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass2.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass2.java
new file mode 100644
index 0000000..76112f8
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClass2.java
@@ -0,0 +1,9 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class ParentClass2 extends SuperParentClass {
+
+ public ParentClass2(String n) {
+ super(n);
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClassWithBC.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClassWithBC.java
new file mode 100644
index 0000000..725b32d
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ParentClassWithBC.java
@@ -0,0 +1,14 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.osgi.framework.BundleContext;
+
+public class ParentClassWithBC {
+
+ private BundleContext bc;
+
+ public ParentClassWithBC(String foo, BundleContext bc, String bar) {
+ this.bc = bc;
+ System.out.println(foo + " : " + this.bc + "(" + bar + ")");
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SeveralConstructors.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SeveralConstructors.java
new file mode 100644
index 0000000..8f78c82
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SeveralConstructors.java
@@ -0,0 +1,31 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+
+import java.util.Properties;
+
+public class SeveralConstructors implements CheckService {
+
+
+ private String name;
+
+ public SeveralConstructors(){
+ this("hello world");
+ }
+
+ public SeveralConstructors(final String n) {
+ name = n;
+ }
+
+ public boolean check() {
+ return name != null;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("name", name);
+ return props;
+ }
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SuperParentClass.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SuperParentClass.java
new file mode 100644
index 0000000..c8cccfe
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SuperParentClass.java
@@ -0,0 +1,17 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class SuperParentClass {
+
+ private String name;
+
+ public SuperParentClass(final String n) {
+ System.out.println("Hello from super super !");
+ name = n;
+ }
+
+ public SuperParentClass(final StringBuffer n) {
+ name = n.toString();
+ }
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
new file mode 100644
index 0000000..e31a24a
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services.A123;
+
+public interface CheckService2 {
+
+ public boolean check();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
new file mode 100644
index 0000000..f704138
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+import java.util.Properties;
+
+public interface BarService {
+
+ public boolean bar();
+
+ public Properties getProps();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
new file mode 100644
index 0000000..eca0faa
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
new file mode 100644
index 0000000..37c1a65
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+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/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java
new file mode 100644
index 0000000..bbe8a7e
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.runtime.core.services;
+
+public interface Plop {
+
+ Object getPlop();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/PrimitiveManipulationTestService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/PrimitiveManipulationTestService.java
new file mode 100644
index 0000000..10a6288
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+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/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/resources/metadata.xml b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/resources/metadata.xml
new file mode 100644
index 0000000..b3be98e
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/main/resources/metadata.xml
@@ -0,0 +1,76 @@
+<ipojo
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
+ xmlns="org.apache.felix.ipojo"
+ >
+ <!-- Simple provider used for manipulation analysis -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="ManipulationCreation-FooProviderType-1" architecture="true">
+ <provides/>
+ </component>
+
+ <!-- Non lazzy service provider, to check instantiation -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="ManipulationCreation-ImmediateFooProviderType" immediate="true"
+ architecture="true">
+ <provides/>
+ </component>
+
+ <!-- Type checking different creation policy -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="ManipulationCreation-FooProviderType-1-Sing" factory-method="singleton"
+ architecture="true">
+ <provides/>
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="ManipulationCreation-FooProviderType-1-Sev" factory-method="several"
+ architecture="true">
+ <provides/>
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="ManipulationCreation-FooProviderType-1-SingM" factory-method="singleton"
+ architecture="true">
+ <provides/>
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="ManipulationCreation-FooProviderType-1-SevM" factory-method="several"
+ architecture="true">
+ <provides/>
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="ManipulationCreation-ImmediateFooProviderTypeSingleton" immediate="true"
+ factory-method="singleton" architecture="true">
+ <provides/>
+ </component>
+
+
+ <!-- Try calling super constructors -->
+ <component classname="org.apache.felix.ipojo.runtime.core.components.CallSuperConstructor" immediate="true"/>
+ <component classname="org.apache.felix.ipojo.runtime.core.components.CallSuperConstructorWithNew" immediate="true"/>
+ <component classname="org.apache.felix.ipojo.runtime.core.components.CallSuperConstructorWithBC" immediate="true"/>
+ <component classname="org.apache.felix.ipojo.runtime.core.components.CallSuperSuperConstructorWithNew"
+ immediate="true"/>
+
+ <!-- Several constructors -->
+ <component classname="org.apache.felix.ipojo.runtime.core.components.SeveralConstructors">
+ <provides/>
+ </component>
+ <!-- No Empty constructor -->
+ <component classname="org.apache.felix.ipojo.runtime.core.components.NoEmptyConstructor">
+ <provides/>
+ </component>
+ <component classname="org.apache.felix.ipojo.runtime.core.components.NoEmptyConstructorWithParentClass">
+ <provides/>
+ </component>
+</ipojo>
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
new file mode 100644
index 0000000..509721c
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -0,0 +1,198 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+ @Inject
+ BundleContext bc;
+
+ OSGiHelper osgiHelper;
+ IPOJOHelper ipojoHelper;
+
+ @Configuration
+ public Option[] config() throws IOException {
+ Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+ root.setLevel(Level.INFO);
+
+ return options(
+ ipojoBundles(),
+ junitBundles(),
+ testedBundle(),
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+ );
+ }
+
+ public static Option junitAndMockitoBundles() {
+ return new DefaultCompositeOption(
+ // Repository required to load harmcrest (OSGi-fied version).
+ repository("http://repository.springsource.com/maven/bundles/external").id(
+ "com.springsource.repository.bundles.external"),
+
+ // Mockito without Hamcrest and Objenesis
+ mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+ // Hamcrest with a version matching the range expected by Mockito
+ mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+ // Objenesis with a version matching the range expected by Mockito
+ wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+ .exports("*;version=1.2"),
+
+ // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+ // 4.9 which does not match the Mockito import.
+ CoreOptions.junitBundles(),
+
+ /*
+ * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+ * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+ * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+ * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+ * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+ * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+ * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+ * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+ * proxy/Callback used in the signature
+ *
+ * So we disable the bootdelegation.
+ */
+ frameworkProperty("felix.bootdelegation.implicit").value("false")
+ );
+ }
+
+
+ @Before
+ public void commonSetUp() {
+ osgiHelper = new OSGiHelper(bc);
+ ipojoHelper = new IPOJOHelper(bc);
+
+ // Dump OSGi Framework information
+ String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+ if (vendor == null) {
+ vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+ }
+ String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+ System.out.println("OSGi Framework : " + vendor + " - " + version);
+ }
+
+ @After
+ public void commonTearDown() {
+ ipojoHelper.dispose();
+ osgiHelper.dispose();
+ }
+
+ public CompositeOption ipojoBundles() {
+ return new DefaultCompositeOption(
+ mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+ mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+ // harmcrest-all
+ //mavenBundle("de.twentyeleven.skysail", "org.hamcrest.hamcrest-all-osgi").versionAsInProject(),
+ // configuration admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
+ );
+ }
+
+ public Option testedBundle() throws MalformedURLException {
+ File out = new File("target/tested/bundle.jar");
+ if (out.exists()) {
+ return bundle(out.toURI().toURL().toExternalForm());
+ }
+
+ TinyBundle tested = TinyBundles.bundle();
+
+ // We look inside target/classes to find the class and resources
+ File classes = new File("target/classes");
+ Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+ List<File> services = new ArrayList<File>();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ // By convention we export of .services and .service package
+ if (file.getAbsolutePath().contains("/services") || file.getAbsolutePath().contains("/service")) {
+ services.add(file);
+ }
+ } else {
+ // We need to compute the path
+ String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+ tested.add(path, file.toURI().toURL());
+ System.out.println(file.getName() + " added to " + path);
+ }
+ }
+
+ // We export components.
+ String export = "org.apache.felix.ipojo.runtime.core.components";
+ for (File file : services) {
+ if (export.length() > 0) { export += ", "; }
+ String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+ String packageName = path.replace('/', '.');
+ export += packageName;
+ }
+
+ System.out.println("Exported packages : " + export);
+
+ InputStream inputStream = tested
+ .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+ .set(Constants.IMPORT_PACKAGE, "*")
+ .set(Constants.EXPORT_PACKAGE, export)
+ .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+ try {
+ org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+ return bundle(out.toURI().toURL().toExternalForm());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot write of the manipulated bundle");
+ }
+ }
+
+ public void assertContains(String s, String[] arrays, String object) {
+ for (String suspect : arrays) {
+ if (object.equals(suspect)) {
+ return;
+ }
+ }
+ fail("Assertion failed : " + s);
+ }
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPOJOCreation.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPOJOCreation.java
new file mode 100644
index 0000000..c4ce866
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPOJOCreation.java
@@ -0,0 +1,274 @@
+/*
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.runtime.core.components.FooProviderType1;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+/**
+ * Check the different method to create POJO object.
+ */
+public class TestPOJOCreation extends Common {
+
+ private ComponentInstance ci_lazzy;
+ private ComponentInstance ci_immediate;
+ private ComponentInstance ci_immediate_singleton;
+
+ private Architecture lazzyArch;
+ private Architecture immeArch;
+ private Architecture immeArchSing;
+
+
+ private ComponentInstance ci_lazzy_sing;
+ private ComponentInstance ci_lazzy_sev;
+
+ private Architecture lazzyArchSing;
+ private Architecture lazzyArchSev;
+ private ComponentInstance ci_lazzy_singM;
+ private ComponentInstance ci_lazzy_sevM;
+
+ private Architecture lazzyArchSingM;
+ private Architecture lazzyArchSevM;
+
+ @Before
+ public void setUp() {
+ String factName = "ManipulationCreation-FooProviderType-1";
+ String compName = "FooProvider-1";
+ ci_lazzy = ipojoHelper.createComponentInstance(factName, compName);
+
+ String factName2 = "ManipulationCreation-ImmediateFooProviderType";
+ String compName2 = "FooProvider-2";
+ ci_immediate = ipojoHelper.createComponentInstance(factName2, compName2);
+
+ String factName3 = "ManipulationCreation-ImmediateFooProviderTypeSingleton";
+ String compName3 = "FooProvider-3";
+ ci_immediate_singleton = ipojoHelper.createComponentInstance(factName3, compName3);
+
+ String factName4 = "ManipulationCreation-FooProviderType-1-Sing";
+ String compName4 = "FooProvider-1-Sing";
+ ci_lazzy_sing = ipojoHelper.createComponentInstance(factName4, compName4);
+
+ String factName5 = "ManipulationCreation-FooProviderType-1-Sev";
+ String compName5 = "FooProvider-1-Sev";
+ ci_lazzy_sev = ipojoHelper.createComponentInstance(factName5, compName5);
+
+ String factName6 = "ManipulationCreation-FooProviderType-1-SingM";
+ String compName6 = "FooProvider-1-SingM";
+ ci_lazzy_singM = ipojoHelper.createComponentInstance(factName6, compName6);
+
+ String factName7 = "ManipulationCreation-FooProviderType-1-SevM";
+ String compName7 = "FooProvider-1-SevM";
+ ci_lazzy_sevM = ipojoHelper.createComponentInstance(factName7, compName7);
+
+ lazzyArch = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + compName + ")");
+ immeArch = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + compName2 + ")");
+ immeArchSing = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + compName3 + ")");
+ lazzyArchSing = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + compName4 + ")");
+ lazzyArchSev = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + compName5 + ")");
+ lazzyArchSingM = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + compName6 + ")");
+ lazzyArchSevM = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + compName7 + ")");
+ }
+
+ public void tearDown() {
+ lazzyArch = null;
+ immeArch = null;
+ immeArchSing = null;
+ lazzyArchSing = null;
+ lazzyArchSev = null;
+ lazzyArchSingM = null;
+ lazzyArchSevM = null;
+ ipojoHelper.dispose();
+ }
+
+ /**
+ * Check lazy creation.
+ */
+ @Test
+ public void testLazyCreation() {
+ assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArch.getInstanceDescription()).getCreatedObjects().length);
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available", ref);
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check the FooService invocation", fs.foo());
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) lazzyArch.getInstanceDescription()).getCreatedObjects().length);
+ }
+
+ /**
+ * Check lazy and singleton creation.
+ */
+ @Test
+ public void testLazyCreationSingleton() {
+ assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArchSing.getInstanceDescription()).getCreatedObjects().length);
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy_sing.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_lazzy_sing.getInstanceName() + " is available", ref);
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check the FooService invocation", fs.foo());
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) lazzyArchSing.getInstanceDescription()).getCreatedObjects().length);
+ }
+
+ /**
+ * Check lazy and "several" creation.
+ */
+ @Test
+ public void testLazyCreationSeveral() {
+ assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArchSev.getInstanceDescription()).getCreatedObjects().length);
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy_sev.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_lazzy_sev.getInstanceName() + " is available", ref);
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+ FooService fs2 = (FooService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check the FooService invocation", fs.foo());
+ assertTrue("Check the FooService invocation-2", fs2.foo());
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) lazzyArchSev.getInstanceDescription()).getCreatedObjects().length);
+ }
+
+ /**
+ * Check immediate creation.
+ */
+ @Test
+ public void testImmediateCreation() {
+ assertEquals("Check that one object is created ", 1, ((PrimitiveInstanceDescription) immeArch.getInstanceDescription()).getCreatedObjects().length);
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_immediate.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_immediate.getInstanceName() + " is available", ref);
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check the FooService invocation", fs.foo());
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) immeArch.getInstanceDescription()).getCreatedObjects().length);
+ }
+
+ /**
+ * Check bundle context injection.
+ */
+ @Test
+ public void testBundleContext() {
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available", ref);
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+ Properties p = fs.fooProps();
+ assertNotNull("Check the bundle context", p.get("context"));
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) lazzyArch.getInstanceDescription()).getCreatedObjects().length);
+ }
+
+ /**
+ * Test immediate singleton creation.
+ */
+ @Test
+ public void testImmediateSingletonCreation() {
+ assertEquals("Check that one object is created ", 1, ((PrimitiveInstanceDescription) immeArchSing.getInstanceDescription()).getCreatedObjects().length);
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_immediate_singleton.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_immediate_singleton.getInstanceName() + " is available", ref);
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check the FooService invocation", fs.foo());
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) immeArchSing.getInstanceDescription()).getCreatedObjects().length);
+ }
+
+ /**
+ * Check creation through a factory method.
+ * (lazy & singleton creation)
+ */
+ @Test
+ public void testLazyCreationSingletonM() {
+ assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArchSingM.getInstanceDescription()).getCreatedObjects().length);
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy_singM.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_lazzy_singM.getInstanceName() + " is available", ref);
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+ FooService fs2 = (FooService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check the FooService invocation", fs.foo());
+ assertTrue("Check the FooService invocation", fs2.foo());
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) lazzyArchSingM.getInstanceDescription()).getCreatedObjects().length);
+ }
+
+ /**
+ * Check creation through a factory method.
+ * (lazy & several creation)
+ */
+ @Test
+ public void testLazyCreationSeveralM() {
+ assertEquals("Check that no objects are created ", 0, ((PrimitiveInstanceDescription) lazzyArchSevM.getInstanceDescription()).getCreatedObjects().length);
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy_sevM.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_lazzy_sevM.getInstanceName() + " is available", ref);
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check the FooService invocation", fs.foo());
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) lazzyArchSevM.getInstanceDescription()).getCreatedObjects().length);
+ FooService fs2 = (FooService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check the FooService invocation-2", fs2.foo());
+ // Only one object as the getService method is called only once (service factory) despite the policy="method".
+ assertEquals("Check the creation of 1 object", 1, ((PrimitiveInstanceDescription) lazzyArchSevM.getInstanceDescription()).getCreatedObjects().length);
+ }
+
+ /**
+ * Test a custom constructor.
+ * Not manipulated.
+ */
+ @Test
+ public void testCustomConstuctor() {
+ FooService fs = new FooProviderType1(0, "foo", bc);
+ Properties props = fs.fooProps();
+ assertEquals("Check bar", 0, ((Integer) props.get("bar")).intValue());
+ assertEquals("Check foo", "foo", props.get("foo"));
+ assertEquals("Check context", bc, props.get("context"));
+ }
+
+ @Test
+ public void testSuperCall() {
+ try {
+ ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.CallSuperConstructor");
+ } catch (Throwable e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testSuperCallWithNew() {
+ try {
+ ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.CallSuperConstructorWithNew");
+ } catch (Throwable e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testSuperSuperCallWithNew() {
+ try {
+ ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.CallSuperSuperConstructorWithNew");
+ } catch (Throwable e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testSuperCallWithBC() {
+ try {
+ ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.CallSuperConstructorWithBC");
+ } catch (Throwable e) {
+ fail(e.getMessage());
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConstructor.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConstructor.java
new file mode 100644
index 0000000..87d6f53
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-creation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestSeveralConstructor.java
@@ -0,0 +1,53 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestSeveralConstructor extends Common {
+
+ private ComponentInstance ci, ci2, ci3;
+
+ @Before
+ public void setUp() {
+ ci = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.SeveralConstructors");
+ ci2 = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.NoEmptyConstructor");
+ ci3 = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.NoEmptyConstructorWithParentClass");
+
+ }
+
+ @Test
+ public void testSeveralConstructor() {
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), ci.getInstanceName());
+ CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check assignation", cs.check());
+ String name = (String) cs.getProps().get("name");
+ assertEquals("Check message", "hello world", name);
+ //assertNull("Check message", name);
+ }
+
+ @Test
+ public void testNoEmptyConstructor() {
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), ci2.getInstanceName());
+ CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
+ assertFalse("Check assignation", cs.check());
+ String name = (String) cs.getProps().get("name");
+ assertEquals("Check message", "NULL", name);
+ }
+
+ @Test
+ public void testNoEmptyConstructorWithAParentClass() {
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), ci3.getInstanceName());
+ CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
+ assertTrue("Check assignation", cs.check()); // super set name to "hello"
+ String name = (String) cs.getProps().get("name");
+ assertEquals("Check message", "hello", name);
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/pom.xml b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/pom.xml
new file mode 100644
index 0000000..a040cb8
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.manipulator.manipulator-it</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.felix</groupId>
+ <artifactId>ipojo-manipulator-manipulation-metadata-test</artifactId>
+
+ <name>${project.artifactId}</name>
+
+</project>
\ No newline at end of file
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Child.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Child.java
new file mode 100644
index 0000000..1ab2130
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Child.java
@@ -0,0 +1,9 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class Child extends Parent {
+
+ public Child(String s) {
+ super(s);
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
new file mode 100644
index 0000000..aa19da1
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
@@ -0,0 +1,64 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.BarService;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.Properties;
+
+public class FooBarProviderType1 implements FooService, BarService {
+
+ public boolean foo() {
+ return true;
+ }
+
+ public Properties fooProps() {
+ return new Properties();
+ }
+
+ public boolean bar() {
+ return true;
+ }
+
+ public Properties getProps() {
+ return new Properties();
+ }
+
+ public boolean getBoolean() {
+ return true;
+ }
+
+ public double getDouble() {
+ return 1.0;
+ }
+
+ public int getInt() {
+ return 1;
+ }
+
+ public long getLong() {
+ return 1;
+ }
+
+ public Boolean getObject() {
+ return new Boolean(true);
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
new file mode 100644
index 0000000..12d4d6a
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
@@ -0,0 +1,128 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+public class FooProviderType1 implements FooService {
+
+ private int m_bar;
+ private String m_foo;
+
+ private BundleContext m_context;
+
+ private static FooProviderType1 singleton;
+ private static int count = 0;
+
+ private static FooProviderType1 singleton(BundleContext bc) {
+ if (singleton == null) {
+ count++;
+ singleton = new FooProviderType1(bc);
+ }
+ return singleton;
+ }
+
+ public static FooProviderType1 several(BundleContext bc) {
+ count++;
+ return new FooProviderType1(bc);
+ }
+
+ public FooProviderType1(BundleContext bc) {
+ if (bc == null) {
+ throw new RuntimeException("Injected bundle context null");
+ }
+ m_context = bc;
+ }
+
+ public boolean foo() {
+ return true;
+ }
+
+ public Properties fooProps() {
+ Properties p = new Properties();
+ p.put("bar", new Integer(m_bar));
+ if (m_foo != null) {
+ p.put("foo", m_foo);
+ }
+ p.put("context", m_context);
+
+ p.put("count", new Integer(count));
+ return p;
+ }
+
+ public void testException() throws Exception {
+ String a = "foobarbaz";
+ throw new Exception("foo" + a);
+ }
+
+ public void testTry() {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ public void testTry2(String s) {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ private void nexttry(String s) {
+ try {
+ s += "foo";
+ } catch (RuntimeException e) {
+
+ }
+ }
+
+ public boolean getBoolean() {
+ return true;
+ }
+
+ public double getDouble() {
+ return 1.0;
+ }
+
+ public int getInt() {
+ return 1;
+ }
+
+ public long getLong() {
+ return 1;
+ }
+
+ public Boolean getObject() {
+ return new Boolean(true);
+ }
+
+ /**
+ * Custom constructor.
+ *
+ * @param bar
+ * @param foo
+ * @param bc
+ */
+ public FooProviderType1(int bar, String foo, BundleContext bc) {
+ m_bar = bar;
+ m_foo = foo;
+ m_context = bc;
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
new file mode 100644
index 0000000..b23152b
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
@@ -0,0 +1,76 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.Properties;
+
+public class FooProviderTypeDyn implements FooService {
+
+ private int intProp;
+ private String strProp;
+ private String[] strAProp;
+ private int[] intAProp;
+ private boolean boolProp;
+
+ public boolean foo() {
+ intProp = 3;
+ boolProp = true;
+ if (strProp.equals("foo")) {
+ strProp = "bar";
+ } else {
+ strProp = "foo";
+ }
+ strAProp = new String[]{"foo", "bar", "baz"};
+ intAProp = new int[]{3, 2, 1};
+ return true;
+ }
+
+ public Properties fooProps() {
+ Properties p = new Properties();
+ p.put("intProp", new Integer(intProp));
+ p.put("boolProp", new Boolean(boolProp));
+ p.put("strProp", strProp);
+ p.put("strAProp", strAProp);
+ p.put("intAProp", intAProp);
+ return p;
+ }
+
+ public boolean getBoolean() {
+ return true;
+ }
+
+ public double getDouble() {
+ return 1.0;
+ }
+
+ public int getInt() {
+ return 1;
+ }
+
+ public long getLong() {
+ return 1;
+ }
+
+ public Boolean getObject() {
+ return new Boolean(true);
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Manipulation23Tester.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Manipulation23Tester.java
new file mode 100644
index 0000000..6ff3408
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Manipulation23Tester.java
@@ -0,0 +1,188 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.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/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Multiconstructor.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Multiconstructor.java
new file mode 100644
index 0000000..bb4746d
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Multiconstructor.java
@@ -0,0 +1,17 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class Multiconstructor {
+
+ public Multiconstructor(String s1, String s2) {
+ this(s1, s2, -1);
+ }
+
+ public Multiconstructor(String s1, int s2) {
+ this(s1, "" + s2, s2);
+ }
+
+ public Multiconstructor(String s1, String s2, int i) {
+ //...
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MultipleCheckService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MultipleCheckService.java
new file mode 100644
index 0000000..938fe4d
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MultipleCheckService.java
@@ -0,0 +1,158 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+public class MultipleCheckService implements CheckService {
+
+ FooService fs[];
+
+ int simpleB = 0;
+
+ int objectB = 0;
+
+ int refB = 0;
+
+ int bothB = 0;
+
+ int simpleU = 0;
+
+ int objectU = 0;
+
+ int refU = 0;
+
+ int bothU = 0;
+
+ public boolean check() {
+ boolean r = fs.length != 0;
+ for (int i = 0; i < fs.length; i++) {
+ r = r & fs[i].foo();
+ }
+ return r;
+ }
+
+ private boolean getBoolean() {
+ return check();
+ }
+
+ private int getInt() {
+ int r = 0;
+ for (int i = 0; i < fs.length; i++) {
+ r = r + fs[i].getInt();
+ }
+ return r;
+ }
+
+ private long getLong() {
+ long r = 0;
+ for (int i = 0; i < fs.length; i++) {
+ r = r + fs[i].getLong();
+ }
+ return r;
+ }
+
+ private double getDouble() {
+ double r = 0.0;
+ for (int i = 0; i < fs.length; i++) {
+ r = r + fs[i].getInt();
+ }
+ return r;
+ }
+
+ protected Object doNothing(Object o, String s) {
+ return null;
+ }
+
+ // private Object getObject() {
+ // boolean r = true;
+ // for(int i = 0; i < fs.length; i++) {
+ // r = r && ((Boolean) fs[i].getObject()).booleanValue();
+ // }
+ // return new Boolean(r);
+ // }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("result", new Boolean(check()));
+ props.put("voidB", new Integer(simpleB));
+ props.put("objectB", new Integer(objectB));
+ props.put("refB", new Integer(refB));
+ props.put("bothB", new Integer(bothB));
+ props.put("voidU", new Integer(simpleU));
+ props.put("objectU", new Integer(objectU));
+ props.put("refU", new Integer(refU));
+ props.put("bothU", new Integer(bothU));
+ props.put("boolean", new Boolean(getBoolean()));
+ props.put("int", new Integer(getInt()));
+ props.put("long", new Long(getLong()));
+ props.put("double", new Double(getDouble()));
+
+ return props;
+ }
+
+ public void voidBind() {
+ simpleB++;
+ }
+
+ public void voidUnbind() {
+ simpleU++;
+ }
+
+ public void objectBind(FooService o) {
+ if (o != null && o instanceof FooService) {
+ objectB++;
+ }
+ }
+
+ public void objectUnbind(FooService o) {
+ if (o != null && o instanceof FooService) {
+ objectU++;
+ }
+ }
+
+ public void refBind(ServiceReference sr) {
+ if (sr != null) {
+ refB++;
+ }
+ }
+
+ public void refUnbind(ServiceReference sr) {
+ if (sr != null) {
+ refU++;
+ }
+ }
+
+ public void bothBind(FooService o, ServiceReference sr) {
+ if (o != null && o instanceof FooService && sr != null) {
+ bothB++;
+ }
+ }
+
+ public void bothUnbind(FooService o, ServiceReference sr) {
+ if (o != null && o instanceof FooService && sr != null) {
+ bothU++;
+ }
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Parent.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Parent.java
new file mode 100644
index 0000000..40e3395
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Parent.java
@@ -0,0 +1,15 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public class Parent {
+
+ private String s;
+
+ public Parent(String s) {
+ this.s = s;
+ }
+
+ public String getS() {
+ return s;
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
new file mode 100644
index 0000000..e31a24a
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services.A123;
+
+public interface CheckService2 {
+
+ public boolean check();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
new file mode 100644
index 0000000..f704138
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+import java.util.Properties;
+
+public interface BarService {
+
+ public boolean bar();
+
+ public Properties getProps();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
new file mode 100644
index 0000000..eca0faa
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
new file mode 100644
index 0000000..37c1a65
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+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/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java
new file mode 100644
index 0000000..bbe8a7e
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.runtime.core.services;
+
+public interface Plop {
+
+ Object getPlop();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/PrimitiveManipulationTestService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/PrimitiveManipulationTestService.java
new file mode 100644
index 0000000..10a6288
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+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/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/resources/metadata.xml b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/resources/metadata.xml
new file mode 100644
index 0000000..7b39437
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/main/resources/metadata.xml
@@ -0,0 +1,57 @@
+<ipojo
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="org.apache.felix.ipojo hhttp://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
+ xmlns="org.apache.felix.ipojo"
+>
+ <!-- Simple provider used for manipulation analysis -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="ManipulationMetadata-FooProviderType-1" architecture="true">
+ <provides />
+ </component>
+
+ <!-- Provider providing 2 services -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"
+ name="ManipulationMetadata-FooBarProviderType-1" architecture="true">
+ <provides />
+ </component>
+
+ <!-- Provider with dynamic property -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn"
+ name="ManipulationMetadata-FooProviderType-Dyn" architecture="true">
+ <provides>
+ <property name="int" field="intProp" value="2" />
+ <property name="boolean" field="boolProp" value="false" />
+ <property name="string" field="strProp" value="foo" />
+ <property name="strAProp" field="strAProp"
+ value="[foo, bar]" />
+ <property name="intAProp" field="intAProp" value="[ 1,2,3]" />
+ </provides>
+ </component>
+
+ <!-- Manipulation -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.Manipulation23Tester"
+ name="ManipulationMetadata-PrimitiveManipulationTester" architecture="true">
+ <provides />
+ </component>
+
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.MultipleCheckService"
+ name="ManipulationMetadata-SimpleMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs" />
+ <provides />
+ </component>
+
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.Child">
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.Multiconstructor">
+ </component>
+</ipojo>
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
new file mode 100644
index 0000000..39d6474
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -0,0 +1,200 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+ @Inject
+ BundleContext bc;
+
+ protected OSGiHelper osgiHelper;
+ protected IPOJOHelper ipojoHelper;
+ protected Bundle testedBundle;
+
+ @Configuration
+ public Option[] config() throws IOException {
+ Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+ root.setLevel(Level.INFO);
+
+ return options(
+ ipojoBundles(),
+ junitBundles(),
+ testedBundle(),
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+ );
+ }
+
+ public static Option junitAndMockitoBundles() {
+ return new DefaultCompositeOption(
+ // Repository required to load harmcrest (OSGi-fied version).
+ repository("http://repository.springsource.com/maven/bundles/external").id(
+ "com.springsource.repository.bundles.external"),
+
+ // Mockito without Hamcrest and Objenesis
+ mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+ // Hamcrest with a version matching the range expected by Mockito
+ mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+ // Objenesis with a version matching the range expected by Mockito
+ wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+ .exports("*;version=1.2"),
+
+ // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+ // 4.9 which does not match the Mockito import.
+ CoreOptions.junitBundles(),
+
+ /*
+ * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+ * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+ * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+ * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+ * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+ * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+ * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+ * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+ * proxy/Callback used in the signature
+ *
+ * So we disable the bootdelegation.
+ */
+ frameworkProperty("felix.bootdelegation.implicit").value("false")
+ );
+ }
+
+
+ @Before
+ public void commonSetUp() {
+ osgiHelper = new OSGiHelper(bc);
+ ipojoHelper = new IPOJOHelper(bc);
+
+ testedBundle = osgiHelper.getBundle("test.bundle");
+
+ // Dump OSGi Framework information
+ String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+ if (vendor == null) {
+ vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+ }
+ String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+ System.out.println("OSGi Framework : " + vendor + " - " + version);
+ }
+
+ @After
+ public void commonTearDown() {
+ ipojoHelper.dispose();
+ osgiHelper.dispose();
+ }
+
+ public CompositeOption ipojoBundles() {
+ return new DefaultCompositeOption(
+ mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+ mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+ // configuration admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
+ );
+ }
+
+ public Option testedBundle() throws MalformedURLException {
+ File out = new File("target/tested/bundle.jar");
+ if (out.exists()) {
+ return bundle(out.toURI().toURL().toExternalForm());
+ }
+
+ TinyBundle tested = TinyBundles.bundle();
+
+ // We look inside target/classes to find the class and resources
+ File classes = new File("target/classes");
+ Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+ List<File> services = new ArrayList<File>();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ // By convention we export of .services and .service package
+ if (file.getAbsolutePath().contains("/services") || file.getAbsolutePath().contains("/service")) {
+ services.add(file);
+ }
+ } else {
+ // We need to compute the path
+ String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+ tested.add(path, file.toURI().toURL());
+ System.out.println(file.getName() + " added to " + path);
+ }
+ }
+
+ // We export components.
+ String export = "org.apache.felix.ipojo.runtime.core.components";
+ for (File file : services) {
+ if (export.length() > 0) { export += ", "; }
+ String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+ String packageName = path.replace('/', '.');
+ export += packageName;
+ }
+
+ System.out.println("Exported packages : " + export);
+
+ InputStream inputStream = tested
+ .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+ .set(Constants.IMPORT_PACKAGE, "*")
+ .set(Constants.EXPORT_PACKAGE, export)
+ .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+ try {
+ org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+ return bundle(out.toURI().toURL().toExternalForm());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot write of the manipulated bundle");
+ }
+ }
+
+ public void assertContains(String s, String[] arrays, String object) {
+ for (String suspect : arrays) {
+ if (object.equals(suspect)) {
+ return;
+ }
+ }
+ fail("Assertion failed : " + s);
+ }
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManipulationMetadata.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManipulationMetadata.java
new file mode 100644
index 0000000..1ae7fe2
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManipulationMetadata.java
@@ -0,0 +1,251 @@
+/*
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.ManifestMetadataParser;
+import org.apache.felix.ipojo.parser.ParseException;
+import org.apache.felix.ipojo.parser.ParseUtils;
+import org.apache.felix.ipojo.runtime.core.services.BarService;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+/**
+ * Check manipulation metadata written in the manifest.
+ */
+public class TestManipulationMetadata extends Common {
+
+ @Test
+ public void testGetMetadata() {
+ String header = (String) testedBundle.getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parseHeaderMetadata(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+
+ Element manip = getManipulationForComponent(elem, "ManipulationMetadata-FooProviderType-1");
+ assertNotNull("Check manipulation metadata not null for " + "FooProviderType-1", manip);
+ }
+
+ @Test
+ public void testInterface() {
+ String comp_name = "ManipulationMetadata-FooProviderType-1";
+ Element manip = getManipulationForComponent(comp_name);
+ Element[] itf = manip.getElements("Interface");
+ assertEquals("Check interfaces number", itf.length, 1);
+ assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
+ }
+
+ @Test
+ public void testInterfaces() {
+ String comp_name = "ManipulationMetadata-FooBarProviderType-1";
+ Element manip = getManipulationForComponent(comp_name);
+ Element[] itf = manip.getElements("Interface");
+ assertEquals("Check interfaces number", itf.length, 2);
+ assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
+ assertEquals("Check itf name", itf[1].getAttribute("name"), BarService.class.getName());
+ }
+
+ @Test
+ public void testFields() {
+ String comp_name = "ManipulationMetadata-FooProviderType-Dyn";
+ Element manip = getManipulationForComponent(comp_name);
+ Element[] fields = manip.getElements("field");
+ assertEquals("Check field count " + fields.length, fields.length, 5);
+ /*
+ private int intProp;
+ private String strProp;
+ private String[] strAProp;
+ private int[] intAProp;
+ private boolean boolProp;
+ */
+
+ Element field;
+
+ field = getFieldFromName(manip, "intProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "intProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");
+
+ field = getFieldFromName(manip, "strProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "strProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "java.lang.String");
+
+ field = getFieldFromName(manip, "strAProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "strAProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "java.lang.String[]");
+
+ field = getFieldFromName(manip, "intAProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "intAProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");
+
+ field = getFieldFromName(manip, "boolProp");
+ assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "boolProp");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");
+ }
+
+ @Test
+ public void testPrimitivesFields() {
+ String comp_name = "ManipulationMetadata-PrimitiveManipulationTester";
+ Element manip = getManipulationForComponent(comp_name);
+ Element[] fields = manip.getElements("Field");
+ assertEquals("Check field count", fields.length, 16);
+ /*
+ byte b = 1;
+ short s = 1;
+ int i = 1;
+ long l = 1;
+ double d = 1.1;
+ float f = 1.1f;
+ char c = 'a';
+ boolean bool = false;
+ 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};
+ */
+ Element field;
+
+ field = getFieldFromName(manip, "b");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte");
+ field = getFieldFromName(manip, "s");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short");
+ field = getFieldFromName(manip, "i");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");
+ field = getFieldFromName(manip, "l");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long");
+ field = getFieldFromName(manip, "d");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double");
+ field = getFieldFromName(manip, "f");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float");
+ field = getFieldFromName(manip, "c");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char");
+ field = getFieldFromName(manip, "bool");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");
+
+ field = getFieldFromName(manip, "bs");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte[]");
+ field = getFieldFromName(manip, "ss");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short[]");
+ field = getFieldFromName(manip, "is");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");
+ field = getFieldFromName(manip, "ls");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long[]");
+ field = getFieldFromName(manip, "ds");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double[]");
+ field = getFieldFromName(manip, "fs");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float[]");
+ field = getFieldFromName(manip, "cs");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char[]");
+ field = getFieldFromName(manip, "bools");
+ assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean[]");
+ }
+
+ @Test
+ public void testNoArgMethod() {
+ String comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
+ Element manip = getManipulationForComponent(comp_name);
+ Element method = getMethodFromName(manip, "check");
+ assertFalse("Check no args", method.containsAttribute("arguments"));
+ assertEquals("Check return", method.getAttribute("return"), "boolean");
+ }
+
+ @Test
+ public void testOneArgsMethod() {
+ String comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
+ Element manip = getManipulationForComponent(comp_name);
+ Element method = getMethodFromName(manip, "refBind");
+ assertEquals("Check args", method.getAttribute("arguments"), "{org.osgi.framework.ServiceReference}");
+ assertEquals("Check args count", 1, ParseUtils.parseArrays("{org.osgi.framework.ServiceReference}").length);
+ assertFalse("Check return", method.containsAttribute("return"));
+ }
+
+ @Test
+ public void testTwoArgsMethod() {
+ String comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
+ Element manip = getManipulationForComponent(comp_name);
+ Element method = getMethodFromName(manip, "doNothing");
+ assertEquals("Check args", method.getAttribute("arguments"), "{java.lang.Object,java.lang.String}");
+ assertEquals("Check args count", 2, ParseUtils.parseArrays("{java.lang.Object,java.lang.String}").length);
+ assertEquals("Check return", method.getAttribute("return"), "java.lang.Object");
+ }
+
+ private Element getManipulationForComponent(Element metadata, String comp_name) {
+ Element[] comps = metadata.getElements("component");
+ for (Element comp : comps) {
+ if (comp.containsAttribute("factory") && comp.getAttribute("factory").equals(comp_name)) {
+ return comp.getElements("manipulation")[0];
+ }
+ if (comp.containsAttribute("name") && comp.getAttribute("name").equals(comp_name)) {
+ return comp.getElements("manipulation")[0];
+ }
+ }
+ return null;
+ }
+
+ private Element getManipulationForComponent(String comp_name) {
+ String header = (String) testedBundle.getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parseHeaderMetadata(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+ Element manip = getManipulationForComponent(elem, comp_name);
+ assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
+ return manip;
+ }
+
+ private Element getMethodFromName(Element manip, String name) {
+ Element methods[] = manip.getElements("Method");
+ for (int i = 0; i < methods.length; i++) {
+ if (methods[i].containsAttribute("name") && methods[i].getAttribute("name").equals(name)) {
+ return methods[i];
+ }
+ }
+ fail("Method " + name + " not found");
+ return null;
+ }
+
+ private Element getFieldFromName(Element manip, String name) {
+ Element fields[] = manip.getElements("Field");
+ for (int i = 0; i < fields.length; i++) {
+ if (fields[i].containsAttribute("name") && fields[i].getAttribute("name").equals(name)) {
+ return fields[i];
+ }
+ }
+ fail("Field " + name + " not found");
+ return null;
+ }
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManipulationMetadataAPI.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManipulationMetadataAPI.java
new file mode 100644
index 0000000..2ffdb0a
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-metadata-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestManipulationMetadataAPI.java
@@ -0,0 +1,298 @@
+/*
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.*;
+import org.apache.felix.ipojo.runtime.core.services.BarService;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Before;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+public class TestManipulationMetadataAPI extends Common {
+
+ PojoMetadata FooProviderType1, FooBarProviderType1, FooProviderTypeDyn, PrimitiveManipulationTester, SimpleMultipleCheckServiceProvider;
+
+ @Before
+ public void setUp() {
+ String comp_name = "ManipulationMetadata-FooProviderType-1";
+ FooProviderType1 = getManipulationMetadataForComponent(comp_name);
+
+ comp_name = "ManipulationMetadata-FooBarProviderType-1";
+ FooBarProviderType1 = getManipulationMetadataForComponent(comp_name);
+
+ comp_name = "ManipulationMetadata-FooProviderType-Dyn";
+ FooProviderTypeDyn = getManipulationMetadataForComponent(comp_name);
+
+ comp_name = "ManipulationMetadata-PrimitiveManipulationTester";
+ PrimitiveManipulationTester = getManipulationMetadataForComponent(comp_name);
+
+ comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
+ SimpleMultipleCheckServiceProvider = getManipulationMetadataForComponent(comp_name);
+ }
+
+ @Test
+ public void testGetMetadata() {
+ String header = (String) testedBundle.getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parseHeaderMetadata(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+ Element manip = getMetadataForComponent(elem, "ManipulationMetadata-FooProviderType-1");
+ assertNotNull("Check manipulation metadata not null for " + "Manipulation-FooProviderType-1", manip);
+ PojoMetadata mm;
+ try {
+ mm = new PojoMetadata(manip);
+ assertNotNull("Check mm not null", mm);
+ } catch (ConfigurationException e) {
+ fail("The creation of pojo metadata has failed");
+ }
+ }
+
+ @Test
+ public void testInterface() {
+ PojoMetadata manip = FooProviderType1;
+
+ String[] itf = manip.getInterfaces();
+ assertEquals("Check interfaces number", itf.length, 1);
+ assertEquals("Check itf name", itf[0], FooService.class.getName());
+
+ assertTrue("Check Foo Service implementation", manip.isInterfaceImplemented(FooService.class.getName()));
+ assertFalse("Check Bar Service implementation", manip.isInterfaceImplemented(BarService.class.getName()));
+ }
+
+ @Test
+ public void testInterfaces() {
+ PojoMetadata manip = FooBarProviderType1;
+ String[] itf = manip.getInterfaces();
+ assertEquals("Check interfaces number", itf.length, 2);
+ assertEquals("Check itf name", itf[0], FooService.class.getName());
+ assertEquals("Check itf name", itf[1], BarService.class.getName());
+
+ assertTrue("Check Foo Service implementation", manip.isInterfaceImplemented(FooService.class.getName()));
+ assertTrue("Check Bar Service implementation", manip.isInterfaceImplemented(BarService.class.getName()));
+ }
+
+ @Test
+ public void testFields() {
+ PojoMetadata manip = FooProviderTypeDyn;
+
+ FieldMetadata[] fields = manip.getFields();
+ assertEquals("Check field count + " + fields.length, fields.length, 5);
+ /*
+ private int intProp;
+ private String strProp;
+ private String[] strAProp;
+ private int[] intAProp;
+ private boolean boolProp;
+ */
+
+ FieldMetadata field;
+
+ field = manip.getField("intProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
+ assertEquals("Check field reflective type : " + field.getFieldName(), FieldMetadata.getReflectionType(field.getFieldType()), "int");
+
+ field = manip.getField("intProp", "int");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
+
+ field = manip.getField("intProp", "long");
+ assertNull("Check bad field", field);
+
+ field = manip.getField("strProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String");
+ assertEquals("Check field reflective type : " + field.getFieldName(), FieldMetadata.getReflectionType(field.getFieldType()), "java.lang.String");
+
+ field = manip.getField("strProp", "String");
+ assertNull("Check bad field", field);
+
+ field = manip.getField("strProp", "java.lang.String");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String");
+
+ field = manip.getField("strAProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strAProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String[]");
+ assertEquals("Check field reflective type : " + field.getFieldName() + " -> " + FieldMetadata.getReflectionType(field.getFieldType()), FieldMetadata.getReflectionType(field.getFieldType()), "[Ljava.lang.String;");
+
+ field = manip.getField("strAProp", "java.lang.String[]");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "strAProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "java.lang.String[]");
+
+ field = manip.getField("strAProp", "String[]");
+ assertNull("Check bad field", field);
+
+ field = manip.getField("intAProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intAProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
+ assertEquals("Check field reflective type : " + field.getFieldName() + " -> " + FieldMetadata.getReflectionType(field.getFieldType()), FieldMetadata.getReflectionType(field.getFieldType()), "[I");
+
+ field = manip.getField("intAProp", "int[]");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "intAProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
+
+ field = manip.getField("intAProp", "String[]");
+ assertNull("Check bad field", field);
+
+ field = manip.getField("boolProp");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "boolProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
+ assertEquals("Check field reflective type : " + field.getFieldName(), FieldMetadata.getReflectionType(field.getFieldType()), "boolean");
+
+ field = manip.getField("boolProp", "boolean");
+ assertEquals("Check field name : " + field.getFieldName(), field.getFieldName(), "boolProp");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
+
+ field = manip.getField("boolProp", "bool");
+ assertNull("Check bad field", field);
+ }
+
+ @Test
+ public void testPrimitivesFields() {
+ PojoMetadata manip = PrimitiveManipulationTester;
+ FieldMetadata[] fields = manip.getFields();
+ assertEquals("Check field count", fields.length, 16);
+
+ FieldMetadata field;
+
+ field = manip.getField("b");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "byte");
+ field = manip.getField("s");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "short");
+ field = manip.getField("i");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int");
+ field = manip.getField("l");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "long");
+ field = manip.getField("d");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "double");
+ field = manip.getField("f");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "float");
+ field = manip.getField("c");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "char");
+ field = manip.getField("bool");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean");
+
+ field = manip.getField("bs");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "byte[]");
+ field = manip.getField("ss");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "short[]");
+ field = manip.getField("is");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "int[]");
+ field = manip.getField("ls");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "long[]");
+ field = manip.getField("ds");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "double[]");
+ field = manip.getField("fs");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "float[]");
+ field = manip.getField("cs");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "char[]");
+ field = manip.getField("bools");
+ assertEquals("Check field type : " + field.getFieldName(), field.getFieldType(), "boolean[]");
+ }
+
+ @Test
+ public void testNoArgMethod() {
+ PojoMetadata manip = SimpleMultipleCheckServiceProvider;
+ MethodMetadata method = manip.getMethod("check");
+ assertEquals("Check no args", method.getMethodArguments().length, 0);
+ assertEquals("Check return", method.getMethodReturn(), "boolean");
+
+ method = manip.getMethod("check", new String[0]);
+ assertEquals("Check no args", method.getMethodArguments().length, 0);
+ assertEquals("Check return", method.getMethodReturn(), "boolean");
+ }
+
+ @Test
+ public void testOneArgsMethod() {
+ PojoMetadata manip = SimpleMultipleCheckServiceProvider;
+ MethodMetadata method = manip.getMethods("refBind")[0];
+ assertEquals("Check args count", method.getMethodArguments().length, 1);
+ assertEquals("Check args", method.getMethodArguments()[0], "org.osgi.framework.ServiceReference");
+ assertEquals("Check return", method.getMethodReturn(), "void");
+
+ method = manip.getMethod("refBind", new String[]{"org.osgi.framework.ServiceReference"});
+ assertEquals("Check args count", method.getMethodArguments().length, 1);
+ assertEquals("Check args", method.getMethodArguments()[0], "org.osgi.framework.ServiceReference");
+ assertEquals("Check return", method.getMethodReturn(), "void");
+ }
+
+ @Test
+ public void testTwoArgsMethod() {
+ PojoMetadata manip = SimpleMultipleCheckServiceProvider;
+ MethodMetadata method = manip.getMethods("doNothing")[0];
+ assertEquals("Check args count", 2, method.getMethodArguments().length);
+ assertEquals("Check args - 1", method.getMethodArguments()[0], "java.lang.Object");
+ assertEquals("Check args - 2", method.getMethodArguments()[1], "java.lang.String");
+ assertEquals("Check return", method.getMethodReturn(), "java.lang.Object");
+
+ method = manip.getMethod("doNothing", new String[]{"java.lang.Object", "java.lang.String"});
+ assertEquals("Check args count", 2, method.getMethodArguments().length);
+ assertEquals("Check args - 1", method.getMethodArguments()[0], "java.lang.Object");
+ assertEquals("Check args - 2", method.getMethodArguments()[1], "java.lang.String");
+ assertEquals("Check return", method.getMethodReturn(), "java.lang.Object");
+ }
+
+ private Element getMetadataForComponent(Element metadata, String comp_name) {
+ Element[] comps = metadata.getElements("component");
+ for (int i = 0; i < comps.length; i++) {
+ if (comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
+ return comps[i];
+ }
+ if (comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
+ return comps[i];
+ }
+ }
+ return null;
+ }
+
+
+ private PojoMetadata getManipulationMetadataForComponent(String comp_name) {
+ String header = (String) testedBundle.getHeaders().get("iPOJO-Components");
+ Element elem = null;
+ try {
+ elem = ManifestMetadataParser.parseHeaderMetadata(header);
+ } catch (ParseException e) {
+ fail("Parse Exception when parsing iPOJO-Component");
+ }
+
+ assertNotNull("Check elem not null", elem);
+
+ Element manip = getMetadataForComponent(elem, comp_name);
+ assertNotNull("Check manipulation metadata not null for " + comp_name, manip);
+ try {
+ return new PojoMetadata(manip);
+ } catch (ConfigurationException e) {
+ fail("The creation of pojo metadata for " + comp_name + " has failed");
+ return null;
+ }
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/pom.xml b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/pom.xml
new file mode 100644
index 0000000..8715515
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.manipulator.manipulator-it</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ <relativePath>../../../pom.xml</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.felix</groupId>
+ <artifactId>ipojo-manipulator-manipulation-test</artifactId>
+
+ <name>${project.artifactId}</name>
+
+</project>
\ No newline at end of file
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/A123/Manipulation23Tester.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/A123/Manipulation23Tester.java
new file mode 100644
index 0000000..24d51e5
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/A123/Manipulation23Tester.java
@@ -0,0 +1,188 @@
+/*
+ * 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.runtime.core.components.A123;
+
+import org.apache.felix.ipojo.runtime.core.services.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/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Annotation.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Annotation.java
new file mode 100644
index 0000000..c522eba
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Annotation.java
@@ -0,0 +1,44 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+public class Annotation {
+
+ @Marker(name = "marker", type = Marker.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 = Marker.Type.BAR,
+ sub = @SubMarker(subname = "foo"),
+ arrayOfObjects = {"foo", "bar", "baz"},
+ arrayOfAnnotations = {@SubMarker(subname = "foo")}
+ )
+ @SubMarker(subname = "bar")
+ @Invisible
+ public Annotation() {
+
+ }
+
+ public void doSomethingWithParams(@Marker(name = "marker", type = Marker.Type.BAR,
+ sub = @SubMarker(subname = "foo"),
+ arrayOfObjects = {"foo", "bar", "baz"},
+ arrayOfAnnotations = {@SubMarker(subname = "foo")}) String foo,
+ @Invisible String bar,
+ @bla @SubMarker(subname = "baz") String baz) {
+ System.out.println("Foo ...");
+ }
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface bla {
+
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
new file mode 100644
index 0000000..12d4d6a
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
@@ -0,0 +1,128 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.osgi.framework.BundleContext;
+
+import java.util.Properties;
+
+public class FooProviderType1 implements FooService {
+
+ private int m_bar;
+ private String m_foo;
+
+ private BundleContext m_context;
+
+ private static FooProviderType1 singleton;
+ private static int count = 0;
+
+ private static FooProviderType1 singleton(BundleContext bc) {
+ if (singleton == null) {
+ count++;
+ singleton = new FooProviderType1(bc);
+ }
+ return singleton;
+ }
+
+ public static FooProviderType1 several(BundleContext bc) {
+ count++;
+ return new FooProviderType1(bc);
+ }
+
+ public FooProviderType1(BundleContext bc) {
+ if (bc == null) {
+ throw new RuntimeException("Injected bundle context null");
+ }
+ m_context = bc;
+ }
+
+ public boolean foo() {
+ return true;
+ }
+
+ public Properties fooProps() {
+ Properties p = new Properties();
+ p.put("bar", new Integer(m_bar));
+ if (m_foo != null) {
+ p.put("foo", m_foo);
+ }
+ p.put("context", m_context);
+
+ p.put("count", new Integer(count));
+ return p;
+ }
+
+ public void testException() throws Exception {
+ String a = "foobarbaz";
+ throw new Exception("foo" + a);
+ }
+
+ public void testTry() {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ public void testTry2(String s) {
+ String a = "foo";
+ a.charAt(0);
+ }
+
+ private void nexttry(String s) {
+ try {
+ s += "foo";
+ } catch (RuntimeException e) {
+
+ }
+ }
+
+ public boolean getBoolean() {
+ return true;
+ }
+
+ public double getDouble() {
+ return 1.0;
+ }
+
+ public int getInt() {
+ return 1;
+ }
+
+ public long getLong() {
+ return 1;
+ }
+
+ public Boolean getObject() {
+ return new Boolean(true);
+ }
+
+ /**
+ * Custom constructor.
+ *
+ * @param bar
+ * @param foo
+ * @param bc
+ */
+ public FooProviderType1(int bar, String foo, BundleContext bc) {
+ m_bar = bar;
+ m_foo = foo;
+ m_context = bc;
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooServiceImpl.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooServiceImpl.java
new file mode 100644
index 0000000..76dc70e
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooServiceImpl.java
@@ -0,0 +1,44 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.Properties;
+
+public class FooServiceImpl implements FooService {
+
+ public boolean foo() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Properties fooProps() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean getBoolean() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public double getDouble() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int getInt() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long getLong() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Boolean getObject() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/InnerClasses.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/InnerClasses.java
new file mode 100644
index 0000000..8e94123
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/InnerClasses.java
@@ -0,0 +1,168 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+public class InnerClasses implements CheckService {
+
+ private String privateObject;
+ private int privateInt;
+
+ protected String protectedObject;
+ protected int protectedInt;
+
+ String packageObject;
+ int packageInt;
+
+ public String publicObject;
+ public int publicInt;
+
+ private String nonObject = "not-managed";
+ private int nonInt = 5;
+
+ private static int staticint = 6;
+
+ public boolean check() {
+ return true;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("publicInner", new PublicNested().doSomething());
+ props.put("packageInner", new PackageNested().doSomething());
+ props.put("protectedInner", new ProtectedNested().doSomething());
+ props.put("privateInner", new PrivateNested().doSomething());
+ props.put("constructorInner", new ConstructorNested().doSomething());
+ props.put("staticInner", new StaticNested().doSomething());
+
+ Job anonymous = new Job() {
+ public Map doSomething() {
+ Map map = new HashMap();
+ map.put("publicObject", publicObject);
+ map.put("publicInt", new Integer(publicInt));
+ map.put("packageObject", packageObject);
+ map.put("packageInt", new Integer(packageInt));
+ map.put("protectedObject", protectedObject);
+ map.put("protectedInt", new Integer(protectedInt));
+ map.put("privateObject", privateObject);
+ map.put("privateInt", new Integer(privateInt));
+ map.put("nonObject", nonObject);
+ map.put("nonInt", new Integer(nonInt));
+ return map;
+ }
+ };
+
+ props.put("anonymous", anonymous.doSomething());
+ props.put("public", new PublicNested());
+
+
+ return props;
+ }
+
+ private class PrivateNested implements Job {
+ public Map doSomething() {
+ Map map = new HashMap();
+ map.put("publicObject", publicObject);
+ map.put("publicInt", new Integer(publicInt));
+ map.put("packageObject", packageObject);
+ map.put("packageInt", new Integer(packageInt));
+ map.put("protectedObject", protectedObject);
+ map.put("protectedInt", new Integer(protectedInt));
+ map.put("privateObject", privateObject);
+ map.put("privateInt", new Integer(privateInt));
+ map.put("nonObject", nonObject);
+ map.put("nonInt", new Integer(nonInt));
+ return map;
+ }
+ }
+
+ public class PublicNested implements Job {
+ public Map doSomething() {
+ Map map = new HashMap();
+ map.put("publicObject", publicObject);
+ map.put("publicInt", new Integer(publicInt));
+ map.put("packageObject", packageObject);
+ map.put("packageInt", new Integer(packageInt));
+ map.put("protectedObject", protectedObject);
+ map.put("protectedInt", new Integer(protectedInt));
+ map.put("privateObject", privateObject);
+ map.put("privateInt", new Integer(privateInt));
+ map.put("nonObject", nonObject);
+ map.put("nonInt", new Integer(nonInt));
+ return map;
+ }
+ }
+
+ class PackageNested implements Job {
+ public Map doSomething() {
+ Map map = new HashMap();
+ map.put("publicObject", publicObject);
+ map.put("publicInt", new Integer(publicInt));
+ map.put("packageObject", packageObject);
+ map.put("packageInt", new Integer(packageInt));
+ map.put("protectedObject", protectedObject);
+ map.put("protectedInt", new Integer(protectedInt));
+ map.put("privateObject", privateObject);
+ map.put("privateInt", new Integer(privateInt));
+ map.put("nonObject", nonObject);
+ map.put("nonInt", new Integer(nonInt));
+ return map;
+ }
+ }
+
+ protected class ProtectedNested implements Job {
+ public Map doSomething() {
+ Map map = new HashMap();
+ map.put("publicObject", publicObject);
+ map.put("publicInt", new Integer(publicInt));
+ map.put("packageObject", packageObject);
+ map.put("packageInt", new Integer(packageInt));
+ map.put("protectedObject", protectedObject);
+ map.put("protectedInt", new Integer(protectedInt));
+ map.put("privateObject", privateObject);
+ map.put("privateInt", new Integer(privateInt));
+ map.put("nonObject", nonObject);
+ map.put("nonInt", new Integer(nonInt));
+ return map;
+ }
+ }
+
+ protected static class StaticNested implements Job {
+ private Map map = new HashMap();
+
+ public Map doSomething() {
+ map.put("static", new Boolean(true));
+ map.put("staticint", new Integer(staticint));
+ return map;
+ }
+ }
+
+ protected class ConstructorNested implements Job {
+ Map map = new HashMap();
+ public ConstructorNested() {
+ map.put("publicObject", publicObject);
+ map.put("publicInt", new Integer(publicInt));
+ map.put("packageObject", packageObject);
+ map.put("packageInt", new Integer(packageInt));
+ map.put("protectedObject", protectedObject);
+ map.put("protectedInt", new Integer(protectedInt));
+ map.put("privateObject", privateObject);
+ map.put("privateInt", new Integer(privateInt));
+ map.put("nonObject", nonObject);
+ map.put("nonInt", new Integer(nonInt));
+ }
+
+ public Map doSomething() {
+ return map;
+ }
+ }
+
+
+}
+
+interface Job {
+ public Map doSomething();
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Invisible.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Invisible.java
new file mode 100644
index 0000000..125f408
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Invisible.java
@@ -0,0 +1,5 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+public @interface Invisible {
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Manipulation23Tester.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Manipulation23Tester.java
new file mode 100644
index 0000000..828645f
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Manipulation23Tester.java
@@ -0,0 +1,129 @@
+/*
+ * 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.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.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 = new short[ss.length];
+ for (int i = 0; i < ss.length; i++) {
+ this.ss[i] = ss[i];
+ }
+ }
+
+ // 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/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Marker.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Marker.java
new file mode 100644
index 0000000..c6b4643
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Marker.java
@@ -0,0 +1,21 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+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/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/PlopImpl.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/PlopImpl.java
new file mode 100644
index 0000000..4ce78b9
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/PlopImpl.java
@@ -0,0 +1,12 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.Plop;
+
+//TODO this test requires source compatibility 1.5
+public class PlopImpl implements Plop {
+
+ public String getPlop() {
+ return "plop";
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SubMarker.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SubMarker.java
new file mode 100644
index 0000000..0161a13
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/SubMarker.java
@@ -0,0 +1,12 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface SubMarker {
+
+ String subname();
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TestTypedList.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TestTypedList.java
new file mode 100644
index 0000000..23c9bf1
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TestTypedList.java
@@ -0,0 +1,32 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+
+import java.util.List;
+import java.util.Properties;
+
+public class TestTypedList implements CheckService {
+
+ private List<FooService> list;
+
+ public boolean check() {
+ return !list.isEmpty();
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ if (list != null) {
+ props.put("list", list);
+
+ int i = 0;
+ for (FooService fs : list) {
+ props.put(i, fs.foo());
+ i++;
+ }
+ }
+
+ return props;
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
new file mode 100644
index 0000000..e31a24a
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services.A123;
+
+public interface CheckService2 {
+
+ public boolean check();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
new file mode 100644
index 0000000..f704138
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+import java.util.Properties;
+
+public interface BarService {
+
+ public boolean bar();
+
+ public Properties getProps();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
new file mode 100644
index 0000000..eca0faa
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+import java.util.Properties;
+
+public interface CheckService {
+
+ public static final String foo = "foo";
+
+ public boolean check();
+
+ public Properties getProps();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
new file mode 100644
index 0000000..37c1a65
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+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/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java
new file mode 100644
index 0000000..bbe8a7e
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Plop.java
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.runtime.core.services;
+
+public interface Plop {
+
+ Object getPlop();
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/PrimitiveManipulationTestService.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/PrimitiveManipulationTestService.java
new file mode 100644
index 0000000..10a6288
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/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.runtime.core.services;
+
+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/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata-java5.xml b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata-java5.xml
new file mode 100644
index 0000000..d2f027d
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata-java5.xml
@@ -0,0 +1,31 @@
+<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
+ xmlns="org.apache.felix.ipojo">
+
+ <!-- Check duplicate method issue -->
+ <component classname="org.apache.felix.ipojo.runtime.core.components.PlopImpl"
+ name="plopimpl">
+ <provides></provides>
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.Manipulation23Tester"
+ name="ManipulationPrimitives5-PrimitiveManipulationTester"
+ architecture="true">
+ <provides />
+ </component>
+ <component classname="org.apache.felix.ipojo.runtime.core.components.Annotation"
+ name="Manipulation-Annotations" />
+
+
+ <!-- Typed list -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooServiceImpl">
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.TestTypedList" name="TypedList">
+ <provides/>
+ <requires field="list" optional="true"
+ specification="org.apache.felix.ipojo.runtime.core.services.FooService"/>
+ </component>
+</ipojo>
\ No newline at end of file
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata-primitives.xml b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata-primitives.xml
new file mode 100644
index 0000000..6bc2094
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata-primitives.xml
@@ -0,0 +1,22 @@
+<ipojo
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
+ xmlns="org.apache.felix.ipojo"
+>
+
+ <!-- Manipulation -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.Manipulation23Tester"
+ name="ManipulationPrimitives-PrimitiveManipulationTester" architecture="true">
+ <provides />
+ </component>
+
+ <!-- Manipulation with numbers -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.A123.Manipulation23Tester"
+ name="ManipulationPrimitives-PrimitiveManipulationTesterA" architecture="true">
+ <provides />
+ </component>
+
+
+</ipojo>
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata.xml b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata.xml
new file mode 100644
index 0000000..7650c4f
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/main/resources/metadata.xml
@@ -0,0 +1,37 @@
+<ipojo
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
+ xmlns="org.apache.felix.ipojo"
+>
+ <!-- Simple provider used for manipulation analysis -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="Manipulation-FooProviderType-1" architecture="true">
+ <provides />
+ </component>
+
+ <!-- Non lazzy service provider, to check instantiation -->
+ <component
+ classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"
+ name="Manipulation-ImmediateFooProviderType" immediate="true"
+ architecture="true">
+ <provides />
+ </component>
+
+ <!-- Nested & Inner classes -->
+ <component name="inners" classname="org.apache.felix.ipojo.runtime.core.components.InnerClasses">
+ <provides>
+ <property field="privateObject"/>
+ <property field="privateInt"/>
+
+ <property field="protectedObject"/>
+ <property field="protectedInt"/>
+
+ <property field="packageObject"/>
+ <property field="packageInt"/>
+
+ <property field="publicObject"/>
+ <property field="publicInt"/>
+ </provides>
+ </component>
+</ipojo>
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
new file mode 100644
index 0000000..509721c
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -0,0 +1,198 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+ @Inject
+ BundleContext bc;
+
+ OSGiHelper osgiHelper;
+ IPOJOHelper ipojoHelper;
+
+ @Configuration
+ public Option[] config() throws IOException {
+ Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+ root.setLevel(Level.INFO);
+
+ return options(
+ ipojoBundles(),
+ junitBundles(),
+ testedBundle(),
+ systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+ );
+ }
+
+ public static Option junitAndMockitoBundles() {
+ return new DefaultCompositeOption(
+ // Repository required to load harmcrest (OSGi-fied version).
+ repository("http://repository.springsource.com/maven/bundles/external").id(
+ "com.springsource.repository.bundles.external"),
+
+ // Mockito without Hamcrest and Objenesis
+ mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+ // Hamcrest with a version matching the range expected by Mockito
+ mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+ // Objenesis with a version matching the range expected by Mockito
+ wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+ .exports("*;version=1.2"),
+
+ // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+ // 4.9 which does not match the Mockito import.
+ CoreOptions.junitBundles(),
+
+ /*
+ * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+ * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+ * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+ * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+ * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+ * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+ * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+ * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+ * proxy/Callback used in the signature
+ *
+ * So we disable the bootdelegation.
+ */
+ frameworkProperty("felix.bootdelegation.implicit").value("false")
+ );
+ }
+
+
+ @Before
+ public void commonSetUp() {
+ osgiHelper = new OSGiHelper(bc);
+ ipojoHelper = new IPOJOHelper(bc);
+
+ // Dump OSGi Framework information
+ String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+ if (vendor == null) {
+ vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+ }
+ String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+ System.out.println("OSGi Framework : " + vendor + " - " + version);
+ }
+
+ @After
+ public void commonTearDown() {
+ ipojoHelper.dispose();
+ osgiHelper.dispose();
+ }
+
+ public CompositeOption ipojoBundles() {
+ return new DefaultCompositeOption(
+ mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+ mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+ // harmcrest-all
+ //mavenBundle("de.twentyeleven.skysail", "org.hamcrest.hamcrest-all-osgi").versionAsInProject(),
+ // configuration admin
+ mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject()
+ );
+ }
+
+ public Option testedBundle() throws MalformedURLException {
+ File out = new File("target/tested/bundle.jar");
+ if (out.exists()) {
+ return bundle(out.toURI().toURL().toExternalForm());
+ }
+
+ TinyBundle tested = TinyBundles.bundle();
+
+ // We look inside target/classes to find the class and resources
+ File classes = new File("target/classes");
+ Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+ List<File> services = new ArrayList<File>();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ // By convention we export of .services and .service package
+ if (file.getAbsolutePath().contains("/services") || file.getAbsolutePath().contains("/service")) {
+ services.add(file);
+ }
+ } else {
+ // We need to compute the path
+ String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+ tested.add(path, file.toURI().toURL());
+ System.out.println(file.getName() + " added to " + path);
+ }
+ }
+
+ // We export components.
+ String export = "org.apache.felix.ipojo.runtime.core.components";
+ for (File file : services) {
+ if (export.length() > 0) { export += ", "; }
+ String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+ String packageName = path.replace('/', '.');
+ export += packageName;
+ }
+
+ System.out.println("Exported packages : " + export);
+
+ InputStream inputStream = tested
+ .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+ .set(Constants.IMPORT_PACKAGE, "*")
+ .set(Constants.EXPORT_PACKAGE, export)
+ .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+ try {
+ org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+ return bundle(out.toURI().toURL().toExternalForm());
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot write of the manipulated bundle");
+ }
+ }
+
+ public void assertContains(String s, String[] arrays, String object) {
+ for (String suspect : arrays) {
+ if (object.equals(suspect)) {
+ return;
+ }
+ }
+ fail("Assertion failed : " + s);
+ }
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestAnnotationProcessing.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestAnnotationProcessing.java
new file mode 100644
index 0000000..dab6b00
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestAnnotationProcessing.java
@@ -0,0 +1,168 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import org.apache.felix.ipojo.runtime.core.components.Marker;
+import org.apache.felix.ipojo.runtime.core.components.SubMarker;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+public class TestAnnotationProcessing extends Common {
+
+ private Class clazz;
+
+ @Before
+ public void setUp() {
+ try {
+ clazz = bc.getBundle().
+ loadClass("org.apache.felix.ipojo.runtime.core.components.Annotation");
+ } catch (ClassNotFoundException e) {
+ fail("Cannot load the annotation class : " + e.getMessage());
+ }
+ }
+
+
+ @Test
+ 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());
+
+ }
+
+ @Test
+ 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());
+ }
+
+ @Test
+ public void testParameterAnnotations() {
+ Method method = null;
+ try {
+ method = this.clazz.getMethod("doSomethingWithParams", new Class[]{String.class, String.class, String.class});
+ } catch (Exception e) {
+ fail("Cannot find the doSomethingWithParams method : " + e.getMessage());
+ }
+ assertNotNull("Check method existence", method);
+
+ java.lang.annotation.Annotation[][] annotations = method.getParameterAnnotations();
+ assertNotNull("Check annotations size - 1", annotations);
+ assertEquals("Check annotations size - 3", 3, annotations.length);
+
+ // Check internals
+ // First parameter (foo)
+ java.lang.annotation.Annotation[] fooAnns = annotations[0];
+ assertEquals("Check fooAnns length", 1, fooAnns.length);
+ Marker marker = (Marker) fooAnns[0];
+ 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());
+
+ // Second parameter (bar), no annotation (invisible)
+ java.lang.annotation.Annotation[] barAnns = annotations[1];
+ assertEquals("Check barAnns length", 0, barAnns.length);
+
+ // Third parameter (baz), two annotations
+ java.lang.annotation.Annotation[] bazAnns = annotations[2];
+ System.out.println(Arrays.toString(bazAnns));
+ assertEquals("Check bazAnns length", 2, bazAnns.length);
+ }
+
+ 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.runtime.core.components.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.runtime.core.components.SubMarker")) {
+ return (SubMarker) annotations[i];
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDuplicateMethods.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDuplicateMethods.java
new file mode 100644
index 0000000..74dcfa2
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestDuplicateMethods.java
@@ -0,0 +1,23 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import org.apache.felix.ipojo.runtime.core.services.Plop;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class TestDuplicateMethods extends Common {
+
+
+ @Test
+ public void testDuplicateMethod() {
+ ipojoHelper.createComponentInstance("plopimpl", "plop");
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(Plop.class.getName(), "plop");
+ assertNotNull("Check plop", ref);
+ Plop plop = (Plop) osgiHelper.getServiceObject(ref);
+ Object o = plop.getPlop();
+ assertEquals("Check result", "plop", o);
+ ipojoHelper.dispose();
+ }
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestExceptionHandling.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestExceptionHandling.java
new file mode 100644
index 0000000..064b19d
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestExceptionHandling.java
@@ -0,0 +1,90 @@
+/*
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.runtime.core.components.FooProviderType1;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+/**
+ * Test exception handling. POJO exception must be propagated.
+ */
+public class TestExceptionHandling extends Common {
+
+ private ComponentInstance ci_lazzy;
+
+ private ServiceReference lazzyRef;
+ private ServiceReference immRef;
+
+ @Before
+ public void setUp() {
+ String factName = "Manipulation-FooProviderType-1";
+ String compName = "FooProvider-1";
+ ci_lazzy = ipojoHelper.createComponentInstance(factName, compName);
+
+ String factName2 = "Manipulation-ImmediateFooProviderType";
+ String compName2 = "FooProvider-2";
+ ipojoHelper.createComponentInstance(factName2, compName2);
+
+ lazzyRef = osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=" + compName + ")");
+ immRef = osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=" + compName2 + ")");
+
+ assertNotNull("LazzyRef", lazzyRef);
+ assertNotNull("ImmRef", immRef);
+ }
+
+ /**
+ * Check that the exception is correctly propagated.
+ */
+ @Test
+ public void testException() {
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available", ref);
+ FooProviderType1 fs = (FooProviderType1) osgiHelper.getServiceObject(ref);
+ try {
+ fs.testException();
+ fail("The method must returns an exception");
+ } catch (Exception e) {
+ // OK
+ }
+ }
+
+ /**
+ * Check that the exception is correctly catch by the POJO.
+ */
+ @Test
+ public void testTry() {
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), ci_lazzy.getInstanceName());
+ assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available", ref);
+ FooProviderType1 fs = (FooProviderType1) osgiHelper.getServiceObject(ref);
+ try {
+ fs.testTry();
+ } catch (Exception e) {
+ fail("The method has returned an exception");
+ }
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestGenericList.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestGenericList.java
new file mode 100644
index 0000000..7210ef3
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestGenericList.java
@@ -0,0 +1,60 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.List;
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+public class TestGenericList extends Common {
+
+ ComponentInstance foo1, foo2;
+ ComponentInstance checker;
+
+ @Before
+ public void setUp() {
+ foo1 = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.FooServiceImpl", "foo1");
+ foo2 = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.components.FooServiceImpl", "foo2");
+ checker = ipojoHelper.createComponentInstance("TypedList", "checker");
+ foo1.stop();
+ foo2.stop();
+ }
+
+ @Test
+ public void testTypedList() {
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), checker.getInstanceName());
+ CheckService check = (CheckService) osgiHelper.getServiceObject(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());
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestGetComponentInstance.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestGetComponentInstance.java
new file mode 100644
index 0000000..297a3e6
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestGetComponentInstance.java
@@ -0,0 +1,92 @@
+/*
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Pojo;
+import org.apache.felix.ipojo.PrimitiveInstanceDescription;
+import org.apache.felix.ipojo.runtime.core.services.FooService;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+/**
+ * Check the getComponentInstance method on a POJO
+ */
+public class TestGetComponentInstance extends Common {
+
+ /**
+ * Check if a pojo can correctly be cast in POJO.
+ * Check the getComponentInstance method.
+ */
+ @Test
+ public void testGetComponentInstance() {
+ String factName = "Manipulation-FooProviderType-1";
+ String compName = "FooProvider-1";
+ ServiceReference ref = null;
+
+ // Get the factory to create a component instance
+ Factory fact = ipojoHelper.getFactory(factName);
+ assertNotNull("Cannot find the factory FooProvider-1", fact);
+
+ Properties props = new Properties();
+ props.put("instance.name", compName);
+ ComponentInstance ci = null;
+ try {
+ ci = fact.createComponentInstance(props);
+ } catch (Exception e1) {
+ fail(e1.getMessage());
+ }
+
+ assertEquals("Check instance name", compName, ci.getInstanceName());
+
+ // Get a FooService provider
+ ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), compName);
+
+ assertNotNull("FS not available", ref);
+
+ // Get foo object
+ FooService fs = (FooService) osgiHelper.getServiceObject(ref);
+
+ // Cast to POJO
+ Pojo pojo = (Pojo) fs;
+
+ // GetComponentInstance
+ ComponentInstance instance = pojo.getComponentInstance();
+ assertEquals("Check component instance name", instance.getInstanceName(), compName);
+ assertEquals("Check component factory name", instance.getFactory().getName(), factName);
+ assertNotNull("Instance description not null", instance.getInstanceDescription());
+ PrimitiveInstanceDescription id = (PrimitiveInstanceDescription) instance.getInstanceDescription();
+ assertTrue("Check instance state", id.getState() == ComponentInstance.VALID);
+ assertEquals("Check created pojo count", id.getCreatedObjects().length, 1);
+ assertEquals("Check instance description name", id.getName(), compName);
+
+ ci.dispose();
+
+ // Check that there is no more FooService
+ ref = osgiHelper.getServiceReference(FooService.class.getName());
+ assertNull("FS available, but component instance stopped", ref);
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestNestedClasses.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestNestedClasses.java
new file mode 100644
index 0000000..0baa6a7
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestNestedClasses.java
@@ -0,0 +1,186 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.components.InnerClasses;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Map;
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class TestNestedClasses extends Common {
+
+ private ComponentInstance instance;
+ private CheckService service;
+
+ @Before
+ public void setUp() {
+ Properties map = new Properties();
+ map.put("publicObject", "publicObject");
+ map.put("publicInt", new Integer(0));
+ map.put("packageObject", "packageObject");
+ map.put("packageInt", new Integer(1));
+ map.put("protectedObject", "protectedObject");
+ map.put("protectedInt", new Integer(2));
+ map.put("privateObject", "privateObject");
+ map.put("privateInt", new Integer(3));
+ map.put("nonObject", "nonObject");
+ map.put("nonInt", new Integer(4));
+ instance = ipojoHelper.createComponentInstance("inners", map);
+
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check service availability", ref);
+ service = (CheckService) osgiHelper.getServiceObject(ref);
+ }
+
+ @After
+ public void tearDown() {
+ service = null;
+ }
+
+ @Test
+ public void testPrivateInnerClass() {
+ Map data = (Map) service.getProps().get("privateInner");
+ assertNotNull("Check data existence", data);
+
+ assertEquals("Check public object", "publicObject", data.get("publicObject"));
+ assertEquals("Check public int", new Integer(0), data.get("publicInt"));
+ assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
+ assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
+ assertEquals("Check package object", "packageObject", data.get("packageObject"));
+ assertEquals("Check package int", new Integer(1), data.get("packageInt"));
+ assertEquals("Check private object", "privateObject", data.get("privateObject"));
+ assertEquals("Check private int", new Integer(3), data.get("privateInt"));
+ assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
+ assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
+
+ }
+
+ @Test
+ public void testProtectedInnerClass() {
+ Map data = (Map) service.getProps().get("protectedInner");
+ assertNotNull("Check data existence", data);
+
+ assertEquals("Check public object", "publicObject", data.get("publicObject"));
+ assertEquals("Check public int", new Integer(0), data.get("publicInt"));
+ assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
+ assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
+ assertEquals("Check package object", "packageObject", data.get("packageObject"));
+ assertEquals("Check package int", new Integer(1), data.get("packageInt"));
+ assertEquals("Check private object", "privateObject", data.get("privateObject"));
+ assertEquals("Check private int", new Integer(3), data.get("privateInt"));
+ assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
+ assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
+
+ }
+
+ @Test
+ public void testPackageInnerClass() {
+ Map data = (Map) service.getProps().get("packageInner");
+ assertNotNull("Check data existence", data);
+
+ assertEquals("Check public object", "publicObject", data.get("publicObject"));
+ assertEquals("Check public int", new Integer(0), data.get("publicInt"));
+ assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
+ assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
+ assertEquals("Check package object", "packageObject", data.get("packageObject"));
+ assertEquals("Check package int", new Integer(1), data.get("packageInt"));
+ assertEquals("Check private object", "privateObject", data.get("privateObject"));
+ assertEquals("Check private int", new Integer(3), data.get("privateInt"));
+ assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
+ assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
+
+ }
+
+ @Test
+ public void testPublicInnerClass() {
+ Map data = (Map) service.getProps().get("publicInner");
+ assertNotNull("Check data existence", data);
+
+ assertEquals("Check public object", "publicObject", data.get("publicObject"));
+ assertEquals("Check public int", new Integer(0), data.get("publicInt"));
+ assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
+ assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
+ assertEquals("Check package object", "packageObject", data.get("packageObject"));
+ assertEquals("Check package int", new Integer(1), data.get("packageInt"));
+ assertEquals("Check private object", "privateObject", data.get("privateObject"));
+ assertEquals("Check private int", new Integer(3), data.get("privateInt"));
+ assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
+ assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
+
+ }
+
+ @Test
+ public void testConstructorInnerClass() {
+ Map data = (Map) service.getProps().get("constructorInner");
+ assertNotNull("Check data existence", data);
+
+ assertEquals("Check public object", "publicObject", data.get("publicObject"));
+ assertEquals("Check public int", new Integer(0), data.get("publicInt"));
+ assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
+ assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
+ assertEquals("Check package object", "packageObject", data.get("packageObject"));
+ assertEquals("Check package int", new Integer(1), data.get("packageInt"));
+ assertEquals("Check private object", "privateObject", data.get("privateObject"));
+ assertEquals("Check private int", new Integer(3), data.get("privateInt"));
+ assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
+ assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
+
+ }
+
+ @Test
+ public void testStaticInnerClass() {
+ Map data = (Map) service.getProps().get("staticInner");
+ assertNotNull("Check data existence", data);
+
+ assertEquals("Check static", new Boolean(true), data.get("static"));
+ assertEquals("Check static int", new Integer(6), data.get("staticint"));
+
+ }
+
+ @Test
+ public void testAnonymousInnerClass() {
+ Map data = (Map) service.getProps().get("anonymous");
+ assertNotNull("Check data existence", data);
+
+ assertEquals("Check public object", "publicObject", data.get("publicObject"));
+ assertEquals("Check public int", new Integer(0), data.get("publicInt"));
+ assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
+ assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
+ assertEquals("Check package object", "packageObject", data.get("packageObject"));
+ assertEquals("Check package int", new Integer(1), data.get("packageInt"));
+ assertEquals("Check private object", "privateObject", data.get("privateObject"));
+ assertEquals("Check private int", new Integer(3), data.get("privateInt"));
+ assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
+ assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
+
+ }
+
+ @Test
+ public void testInnerAccess() {
+ Map map = (Map) service.getProps();
+ assertNotNull("Check map existence", map);
+
+ InnerClasses.PublicNested p = (InnerClasses.PublicNested) map.get("public");
+ Map data = p.doSomething();
+
+ assertEquals("Check public object", "publicObject", data.get("publicObject"));
+ assertEquals("Check public int", new Integer(0), data.get("publicInt"));
+ assertEquals("Check protected object", "protectedObject", data.get("protectedObject"));
+ assertEquals("Check protected int", new Integer(2), data.get("protectedInt"));
+ assertEquals("Check package object", "packageObject", data.get("packageObject"));
+ assertEquals("Check package int", new Integer(1), data.get("packageInt"));
+ assertEquals("Check private object", "privateObject", data.get("privateObject"));
+ assertEquals("Check private int", new Integer(3), data.get("privateInt"));
+ assertEquals("Check non-managed object", "not-managed", data.get("nonObject"));
+ assertEquals("Check non-managed int", new Integer(5), data.get("nonInt"));
+
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPrimitiveTypes.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPrimitiveTypes.java
new file mode 100644
index 0000000..303175c
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPrimitiveTypes.java
@@ -0,0 +1,107 @@
+/*
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.PrimitiveManipulationTestService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+/**
+ * Check the manipulation of primitive type (boxed and unboxed).
+ */
+public class TestPrimitiveTypes extends Common {
+
+ PrimitiveManipulationTestService prim;
+
+ @Before
+ public void setUp() {
+ ComponentInstance instance = ipojoHelper.createComponentInstance("ManipulationPrimitives-PrimitiveManipulationTester");
+ assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
+ prim = (PrimitiveManipulationTestService) osgiHelper.getServiceObject(PrimitiveManipulationTestService.class.getName(), "(instance.name=" + instance.getInstanceName() + ")");
+ assertNotNull("Check prim availability", prim);
+ }
+
+ @After
+ public void tearDown() {
+ prim = null;
+ }
+
+ @Test
+ public void testByte() {
+ assertEquals("Check - 1", prim.getByte(), 1);
+ prim.setByte((byte) 2);
+ assertEquals("Check - 2", prim.getByte(), 2);
+ }
+
+ @Test
+ public void testShort() {
+ assertEquals("Check - 1", prim.getShort(), 1);
+ prim.setShort((short) 2);
+ assertEquals("Check - 2", prim.getShort(), 2);
+ }
+
+ @Test
+ public void testInt() {
+ assertEquals("Check - 1", prim.getInt(), 1);
+ prim.setInt((int) 2);
+ assertEquals("Check - 2", prim.getInt(), 2);
+ }
+
+ @Test
+ public void testLong() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ prim.setLong((long) 2);
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+ @Test
+ public void testFloat() {
+ assertEquals("Check - 1", prim.getFloat(), 1.1f);
+ prim.setFloat(2.2f);
+ assertEquals("Check - 2", prim.getFloat(), 2.2f);
+ }
+
+ @Test
+ public void testDouble() {
+ assertEquals("Check - 1", prim.getDouble(), 1.1);
+ prim.setDouble(2.2);
+ assertEquals("Check - 2", prim.getDouble(), 2.2);
+ }
+
+ @Test
+ public void testBoolean() {
+ assertFalse("Check - 1", prim.getBoolean());
+ prim.setBoolean(true);
+ assertTrue("Check - 2", prim.getBoolean());
+ }
+
+ @Test
+ public void testChar() {
+ assertEquals("Check - 1", prim.getChar(), 'a');
+ prim.setChar('b');
+ assertEquals("Check - 2", prim.getChar(), 'b');
+ }
+
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPrimitiveTypesWithNumberInNames.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPrimitiveTypesWithNumberInNames.java
new file mode 100644
index 0000000..709cbbe
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestPrimitiveTypesWithNumberInNames.java
@@ -0,0 +1,111 @@
+/*
+ * 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.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.PrimitiveManipulationTestService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.*;
+
+/**
+ * Check the manipulation of primitive type (boxed and unboxed).
+ * The targeted implementation contains numbers in the package and class name.
+ */
+public class TestPrimitiveTypesWithNumberInNames extends Common {
+
+ PrimitiveManipulationTestService prim;
+
+ @Before
+ public void setUp() {
+ ComponentInstance instance =
+ ipojoHelper.createComponentInstance("ManipulationPrimitives-PrimitiveManipulationTesterA");
+ assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(PrimitiveManipulationTestService.class.getName(),
+ instance.getInstanceName());
+ assertNotNull("Check prim availability", ref);
+ prim = (PrimitiveManipulationTestService) osgiHelper.getServiceObject(ref);
+ }
+
+ @After
+ public void tearDown() {
+ prim = null;
+ }
+
+ @Test
+ public void testByte() {
+ assertEquals("Check - 1", prim.getByte(), 1);
+ prim.setByte((byte) 2);
+ assertEquals("Check - 2", prim.getByte(), 2);
+ }
+
+ @Test
+ public void testShort() {
+ assertEquals("Check - 1", prim.getShort(), 1);
+ prim.setShort((short) 2);
+ assertEquals("Check - 2", prim.getShort(), 2);
+ }
+
+ @Test
+ public void testInt() {
+ assertEquals("Check - 1", prim.getInt(), 1);
+ prim.setInt((int) 2);
+ assertEquals("Check - 2", prim.getInt(), 2);
+ }
+
+ @Test
+ public void testLong() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ prim.setLong((long) 2);
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+ @Test
+ public void testFloat() {
+ assertEquals("Check - 1", prim.getFloat(), 1.1f);
+ prim.setFloat(2.2f);
+ assertEquals("Check - 2", prim.getFloat(), 2.2f);
+ }
+
+ @Test
+ public void testDouble() {
+ assertEquals("Check - 1", prim.getDouble(), 1.1);
+ prim.setDouble(2.2);
+ assertEquals("Check - 2", prim.getDouble(), 2.2);
+ }
+
+ @Test
+ public void testBoolean() {
+ assertFalse("Check - 1", prim.getBoolean());
+ prim.setBoolean(true);
+ assertTrue("Check - 2", prim.getBoolean());
+ }
+
+ @Test
+ public void testChar() {
+ assertEquals("Check - 1", prim.getChar(), 'a');
+ prim.setChar('b');
+ assertEquals("Check - 2", prim.getChar(), 'b');
+ }
+
+}
diff --git a/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestTypeBoxing.java b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestTypeBoxing.java
new file mode 100644
index 0000000..e05108c
--- /dev/null
+++ b/ipojo/manipulator/manipulator-it/src/it/ipojo-manipulator-manipulation-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestTypeBoxing.java
@@ -0,0 +1,57 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.runtime.core.services.PrimitiveManipulationTestService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestTypeBoxing extends Common {
+
+ ComponentInstance instance; // Instance under test
+
+ PrimitiveManipulationTestService prim;
+
+ ServiceReference prim_ref;
+
+ @Before
+ public void setUp() {
+ Properties p1 = new Properties();
+ p1.put("instance.name", "primitives");
+ instance = ipojoHelper.createComponentInstance("ManipulationPrimitives5-PrimitiveManipulationTester", p1);
+ assertTrue("check instance state", instance.getState() == ComponentInstance.VALID);
+ prim_ref = ipojoHelper.getServiceReferenceByName(PrimitiveManipulationTestService.class.getName(), instance.getInstanceName());
+ assertNotNull("Check prim availability", prim_ref);
+ prim = (PrimitiveManipulationTestService) osgiHelper.getServiceObject(prim_ref);
+ }
+
+ @After
+ public void tearDown() {
+ prim = null;
+ }
+
+
+ @Test
+ public void testLongFromObject() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ Long l = new Long(2);
+ prim.setLong(l);
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+ @Test
+ public void testLongFromObject2() {
+ assertEquals("Check - 1", prim.getLong(), 1);
+ Long l = new Long(2);
+ prim.setLong(l, "ss");
+ assertEquals("Check - 2", prim.getLong(), 2);
+ }
+
+}