felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r651646 [9/22] - in /felix/trunk/ipojo/tests: ./ tests.composite/ tests.composite/src/ tests.composite/src/main/ tests.composite/src/main/java/ tests.composite/src/main/java/org/ tests.composite/src/main/java/org/apache/ tests.composite/src...
Date Fri, 25 Apr 2008 16:50:22 GMT
Added: felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,326 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.util;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import junit.framework.Assert;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.HandlerFactory;
+import org.apache.felix.ipojo.ServiceContext;
+//import org.apache.felix.ipojo.composite.CompositeManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ManagedServiceFactory;
+
+public class Utils {
+
+    public static Factory getFactoryByName(BundleContext bc, String factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
+            if (refs == null) {
+                System.err.println("Cannot get the factory " + factoryName);
+                return null;
+            }
+            return ((Factory) bc.getService(refs[0]));
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+            return null;
+        }
+    }
+
+    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
+            if (refs == null) {
+                System.err.println("Cannot get the factory " + factoryName);
+                return null;
+            }
+            return (HandlerFactory) bc.getService(refs[0]);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+            return null;
+        }
+    }
+
+    public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) {
+            System.err.println("Factory " + factoryName + " not found");
+            return null;
+        }
+
+        // if(fact.isAcceptable(configuration)) {
+        try {
+            return fact.createComponentInstance(configuration);
+        } catch (Exception e) {
+            e.printStackTrace();
+            Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
+            return null;
+        }
+        // }
+        // else {
+        // System.err.println("Configuration not accepted by : " + factoryName);
+        // return null;
+        // }
+    }
+
+    public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) {
+            System.err.println("Factory " + factoryName + " not found");
+            return null;
+        }
+
+        try {
+            Properties props = new Properties();
+            props.put("name", name);
+            return fact.createComponentInstance(props);
+        } catch (Exception e) {
+            System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return new ServiceReference[0];
+        } else {
+            return refs;
+        }
+    }
+
+    public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
+        ServiceReference[] refs = null;
+        String filter = null;
+        if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
+            filter = "(" + "factory.name" + "=" + name + ")";
+        } else {
+            filter = "(" + "instance.name" + "=" + name + ")";
+        }
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+    
+    public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
+        ServiceReference[] refs = null;
+        String filter = "(" + "service.pid" + "=" + pid + ")";
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else if (refs.length == 1) {
+            return refs[0];
+        } else {
+            Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
+            return null;
+        }
+    }
+
+    public static Object getServiceObject(BundleContext bc, String itf, String filter) {
+        ServiceReference ref = getServiceReference(bc, itf, filter);
+        if (ref != null) {
+            return bc.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
+        ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                list[i] = bc.getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+
+//    public static ServiceContext getServiceContext(ComponentInstance ci) {
+//        if (ci instanceof CompositeManager) {
+//            return ((CompositeManager) ci).getServiceContext();
+//        } else {
+//            throw new RuntimeException("Cannot get the service context form an non composite instance");
+//        }
+//    }
+
+    public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
+            if (refs == null) { return null; }
+            return ((Factory) bc.getService(refs[0]));
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+            return null;
+        }
+    }
+
+    public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) { return null; }
+
+        if (fact.isAcceptable(configuration)) {
+            try {
+                return fact.createComponentInstance(configuration);
+            } catch (Exception e) {
+                System.err.println(e.getMessage());
+                e.printStackTrace();
+                return null;
+            }
+        } else {
+            System.err.println("Configuration not accepted by : " + factoryName);
+            return null;
+        }
+    }
+
+    public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return new ServiceReference[0];
+        } else {
+            return refs;
+        }
+    }
+
+    public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
+        ServiceReference[] refs = null;
+        String filter = null;
+        if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
+            filter = "(" + "factory.name" + "=" + name + ")";
+        } else {
+            filter = "(" + "instance.name" + "=" + name + ")";
+        }
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
+        ServiceReference ref = getServiceReference(bc, itf, filter);
+        if (ref != null) {
+            return bc.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
+        ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                list[i] = bc.getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+    
+    public static boolean contains(String string, String[] array) {
+        for (int i = 0; array != null && i < array.length; i++) {
+            if (array[i] != null  && array[i].equals(string)) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public static boolean contains(int value, int[] array) {
+        for (int i = 0; array != null && i < array.length; i++) {
+            if (array[i] == value) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

Added: felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/resources/metadata.xml?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/resources/metadata.xml (added)
+++ felix/trunk/ipojo/tests/tests.core.lifecycle.controller/src/main/resources/metadata.xml Fri Apr 25 09:49:43 2008
@@ -0,0 +1,21 @@
+<ipojo>
+	<component
+		classname="org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"
+		name="LFC-Test">
+		<provides />
+		<controller field="m_state" />
+		<properties>
+			<property name="conf" field="m_conf" method="setConf" />
+		</properties>
+	</component>
+
+	<component
+		classname="org.apache.felix.ipojo.test.scenarios.component.LifecycleControllerTest"
+		name="LFC-Test-Immediate" immediate="true" architecture="true">
+		<provides />
+		<controller field="m_state" />
+		<properties>
+			<property name="conf" field="m_conf" method="setConf" />
+		</properties>
+	</component>
+</ipojo>

Propchange: felix/trunk/ipojo/tests/tests.core.manipulation/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr 25 09:49:43 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Added: felix/trunk/ipojo/tests/tests.core.manipulation/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/pom.xml?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/pom.xml (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/pom.xml Fri Apr 25 09:49:43 2008
@@ -0,0 +1,102 @@
+<!--
+	Licensed to the Apache Software Foundation (ASF) under one
+	or more contributor license agreements.  See the NOTICE file
+	distributed with this work for additional information
+	regarding copyright ownership.  The ASF licenses this file
+	to you under the Apache License, Version 2.0 (the
+	"License"); you may not use this file except in compliance
+	with the License.  You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing,
+	software distributed under the License is distributed on an
+	"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+	KIND, either express or implied.  See the License for the
+	specific language governing permissions and limitations
+	under the License.
+-->
+<project>
+	<modelVersion>4.0.0</modelVersion>
+	<packaging>bundle</packaging>
+	<name>iPOJO Manipulation Test Suite</name>
+	<artifactId>tests.core.manipulation</artifactId>
+	<groupId>ipojo.tests</groupId>
+	<version>0.7.6-SNAPSHOT</version>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.ipojo</artifactId>
+			<version>0.7.6-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.ipojo.metadata</artifactId>
+			<version>0.7.6-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+		</dependency>
+		<dependency>
+			<groupId>ipojo.examples</groupId>
+			<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+			<version>0.7.6-SNAPSHOT</version>
+		</dependency>
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<version>1.4.0</version>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Export-Package>
+							org.apache.felix.ipojo.test.scenarios.manipulation.service
+						</Export-Package>
+						<Bundle-SymbolicName>
+							${pom.artifactId}
+						</Bundle-SymbolicName>
+						<Private-Package>
+							org.apache.felix.ipojo.test*
+						</Private-Package>
+						<Test-Suite>
+							org.apache.felix.ipojo.test.scenarios.manipulation.ManipulationTestSuite
+						</Test-Suite>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-ipojo-plugin</artifactId>
+				<version>0.7.6-SNAPSHOT</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>ipojo-bundle</goal>
+						</goals>
+						<configuration>
+							<ignoreAnnotations>true</ignoreAnnotations>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.4</source>
+					<target>1.4</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/Manipulation23Tester.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,124 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component.A123;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
+
+
+public class Manipulation23Tester implements PrimitiveManipulationTestService {
+
+    
+    // Integer types
+	byte b = 1;
+	short s = 1;
+	int i = 1;
+	long l = 1;
+	
+	// Floatting types
+	double d = 1.1;
+	float f = 1.1f;
+	
+	// Character
+	char c = 'a';
+	
+	// Boolean
+	boolean bool = false;
+	
+	// Integer arrays 
+	byte[] bs = new byte[] {0,1,2};
+	short[] ss = new short[] {0,1,2};
+	int[] is = new int[] {0,1,2};
+	long[] ls = new long[] {0,1,2};
+	
+	double[] ds = new double[] {0.0, 1.1, 2.2};
+	float[] fs = new float[] {0.0f, 1.1f, 2.2f};
+	
+	char[] cs = new char[] {'a', 'b', 'c'};
+	
+	boolean[] bools = new boolean[] {false, true, false};
+
+	public boolean getBoolean() { return bool; }
+
+	public boolean[] getBooleans() { return bools; }
+
+	public byte getByte() { return b; }
+
+	public byte[] getBytes() { return bs; }
+
+	public char getChar() { return c; }
+
+	public char[] getChars() { return cs; }
+
+	public double getDouble() { return d; }
+
+	public double[] getDoubles() { return ds; }
+
+	public float getFloat() { return f; }
+
+	public float[] getFloats() { return fs; }
+
+	public int getInt() { return i; }
+
+	public int[] getInts() { return is; }
+
+	public long getLong() { return l; }
+
+	public long[] getLongs() { return ls; }
+
+	public short getShort() { return s; }
+
+	public short[] getShorts() { return ss; }
+
+	public void setBoolean(boolean b) { this.bool = b; }
+
+	public void setBooleans(boolean[] bs) { this.bools = bs; }
+
+	public void setByte(byte b) { this.b = b; }
+
+	public void setBytes(byte[] bs) { this.bs = bs; }
+
+	public void setChar(char c) { this.c = c; }
+
+	public void setChars(char[] cs) { this.cs = cs; }
+
+	public void setDouble(double d) { this.d = d; }
+
+	public void setDoubles(double[] ds) { this.ds = ds; }
+
+	public void setFloat(float f) { this.f = f; }
+
+	public void setFloats(float[] fs) { this.fs = fs; }
+
+	public void setInt(int i) { this.i = i; }
+
+	public void setInts(int[] is) { this.is = is; }
+
+	public void setLong(long l) { this.l = l; }
+
+	public void setLongs(long[] ls) { this.ls = ls; }
+
+ 	public void setShort(short s) { this.s = s; }
+
+	public void setShorts(short[] ss) { this.ss = ss; }	
+	
+	public void setLong(long l, String s) {
+	    this.l = l;
+	}
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,51 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public abstract class CheckProviderParentClass {
+    
+    int simpleU = 0;
+    int objectU = 0;
+    int refU = 0;
+    int bothU = 0;
+    
+    
+    public void bothUnbind(FooService o, ServiceReference sr) {
+        if(sr != null && o != null && o instanceof FooService) { bothU++; }
+    }
+    
+    public void refUnbind(ServiceReference sr) {
+        if(sr != null) { refU++; }
+    }
+    
+    public void objectUnbind(FooService o) {
+        if(o != null && o instanceof FooService) { objectU++; }
+        else {
+            System.err.println("Unbind null : " + o);
+        }
+    }
+    
+    public void voidUnbind() {
+        simpleU++;
+    }
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,83 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {
+    
+	FooService fs;
+	
+	int simpleB = 0;
+	int objectB = 0;
+	int refB = 0;
+	int bothB = 0;
+
+	public boolean check() {
+		return fs.foo();
+	}
+
+	public Properties getProps() {
+		Properties props = new Properties();
+		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));
+		if (fs != null) {
+		    props.put("result", new Boolean(fs.foo()));
+		    props.put("boolean", new Boolean(fs.getBoolean()));
+		    props.put("int", new Integer(fs.getInt()));
+		    props.put("long", new Long(fs.getLong()));
+		    props.put("double", new Double(fs.getDouble()));
+		    if(fs.getObject() != null) { props.put("object", fs.getObject()); }
+		}
+        props.put("static", CheckService.foo);
+        props.put("class", CheckService.class.getName());
+		return props;
+	}
+	
+	private void voidBind() {
+		simpleB++;
+	}
+	
+	protected void objectBind(FooService o) {
+	    if (o == null) {
+	        System.err.println("Bind receive null !!! ");
+	        return;
+	    }
+		if(o != null && o instanceof FooService) { objectB++; }
+	}
+	
+	public void refBind(ServiceReference sr) {
+		if(sr != null) { refB++; }
+	}
+	
+    public void bothBind(FooService o, ServiceReference sr) {
+	    if(sr != null && o != null && o instanceof FooService) { bothB++; }
+	}
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooBarProviderType1.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,54 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.BarService;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+
+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); }
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.osgi.framework.BundleContext;
+
+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;
+	}
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderTypeDyn.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,63 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+
+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); }
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Manipulation23Tester.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,124 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.PrimitiveManipulationTestService;
+
+
+public class Manipulation23Tester implements PrimitiveManipulationTestService {
+	
+	// Integer types
+	byte b = 1;
+	short s = 1;
+	int i = 1;
+	long l = 1;
+	
+	// Floatting types
+	double d = 1.1;
+	float f = 1.1f;
+	
+	// Character
+	char c = 'a';
+	
+	// Boolean
+	boolean bool = false;
+	
+	// Integer arrays 
+	byte[] bs = new byte[] {0,1,2};
+	short[] ss = new short[] {0,1,2};
+	int[] is = new int[] {0,1,2};
+	long[] ls = new long[] {0,1,2};
+	
+	double[] ds = new double[] {0.0, 1.1, 2.2};
+	float[] fs = new float[] {0.0f, 1.1f, 2.2f};
+	
+	char[] cs = new char[] {'a', 'b', 'c'};
+	
+	boolean[] bools = new boolean[] {false, true, false};
+
+	public boolean getBoolean() { return bool; }
+
+	public boolean[] getBooleans() { return bools; }
+
+	public byte getByte() { return b; }
+
+	public byte[] getBytes() { return bs; }
+
+	public char getChar() { return c; }
+
+	public char[] getChars() { return cs; }
+
+	public double getDouble() { return d; }
+
+	public double[] getDoubles() { return ds; }
+
+	public float getFloat() { return f; }
+
+	public float[] getFloats() { return fs; }
+
+	public int getInt() { return i; }
+
+	public int[] getInts() { return is; }
+
+	public long getLong() { return l; }
+
+	public long[] getLongs() { return ls; }
+
+	public short getShort() { return s; }
+
+	public short[] getShorts() { return ss; }
+
+	public void setBoolean(boolean b) { this.bool = b; }
+
+	public void setBooleans(boolean[] bs) { this.bools = bs; }
+
+	public void setByte(byte b) { this.b = b; }
+
+	public void setBytes(byte[] bs) { this.bs = bs; }
+
+	public void setChar(char c) { this.c = c; }
+
+	public void setChars(char[] cs) { this.cs = cs; }
+
+	public void setDouble(double d) { this.d = d; }
+
+	public void setDoubles(double[] ds) { this.ds = ds; }
+
+	public void setFloat(float f) { this.f = f; }
+
+	public void setFloats(float[] fs) { this.fs = fs; }
+
+	public void setInt(int i) { this.i = i; }
+
+	public void setInts(int[] is) { this.is = is; }
+
+	public void setLong(long l) { this.l = l; }
+
+	public void setLongs(long[] ls) { this.ls = ls; }
+
+ 	public void setShort(short s) { this.s = s; }
+
+	public void setShorts(short[] ss) { this.ss = ss; }	
+	
+	// This method has been added to test an issue when autoboxing.
+	public void setLong(long l, String s) {
+	    this.l = l;
+	}
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java Fri Apr 25 09:49:43 2008
@@ -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.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.osgi.framework.ServiceReference;
+
+public class 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++;
+        }
+    }
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ExceptionTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,110 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.component.FooProviderType1;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Test execption handling. POJO exception must be propagated.
+ */
+public class ExceptionTest extends OSGiTestCase {
+	
+	private ComponentInstance ci_lazzy;
+	private ComponentInstance ci_immediate;
+	
+	private ServiceReference lazzyRef;
+	private ServiceReference immRef;	
+
+	public void setUp() {
+		String factName = "Manipulation-FooProviderType-1";
+		String compName = "FooProvider-1";
+		
+		Properties p = new Properties();
+		p.put("name", compName);
+		ci_lazzy = Utils.getComponentInstance(context, factName, p);
+		
+		String factName2 = "Manipulation-ImmediateFooProviderType";
+		String compName2 = "FooProvider-2";
+		
+		Properties p2 = new Properties();
+		p2.put("name", compName2);
+		ci_immediate = Utils.getComponentInstance(context, factName2, p2);
+		
+		lazzyRef = Utils.getServiceReference(context, Architecture.class.getName(), "(instance.name="+compName+")");
+		immRef =   Utils.getServiceReference(context, Architecture.class.getName(), "(instance.name="+compName2+")");
+		assertNotNull("LazzyRef", lazzyRef);
+		assertNotNull("ImmRef", immRef);
+	}
+	
+	public void tearDown() {
+		context.ungetService(lazzyRef);
+		context.ungetService(immRef);
+		ci_lazzy.dispose();
+		ci_immediate.dispose();
+	}
+	
+    
+    /**
+     * Check that the exception is correctly propagated.
+     */
+    public void testException() {
+        ServiceReference[] refs = null;
+        try {
+            refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy.getInstanceName()+")");
+        } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+        assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",refs);
+        FooProviderType1 fs = (FooProviderType1) context.getService(refs[0]);
+        try {
+            fs.testException();
+            context.ungetService(refs[0]);
+            fail("The method must returns an exception");
+        } catch(Exception e) {
+            context.ungetService(refs[0]);
+        }
+    }
+    
+    /**
+     * Check that the exception is correctly catch by the POJO.
+     */
+    public void testTry() {
+        ServiceReference[] refs = null;
+        try {
+            refs = context.getServiceReferences(FooService.class.getName(), "(instance.name="+ci_lazzy.getInstanceName()+")");
+        } catch (InvalidSyntaxException e) { e.printStackTrace(); }
+        assertNotNull("Check that a FooService from " + ci_lazzy.getInstanceName() + " is available",refs);
+        FooProviderType1 fs = (FooProviderType1) context.getService(refs[0]);
+        try {
+            fs.testTry();
+            context.ungetService(refs[0]);
+        } catch(Exception e) {
+            context.ungetService(refs[0]);
+            fail("The method has returned an exception");
+        }
+    }
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/GetComponentInstanceTest.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,94 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Pojo;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Check the getComponentInstance method on a POJO
+ */
+public class GetComponentInstanceTest extends OSGiTestCase {
+    
+	/**
+	 * Check if a pojo can correctly be cast in POJO.
+	 * Check the getComponentInstance method. 
+	 */
+	public void testGetComponentInstance() {
+		String factName = "Manipulation-FooProviderType-1";
+		String compName = "FooProvider-1";
+		ServiceReference[] refs = null;
+		
+		// Get the factory to create a component instance
+		Factory fact = Utils.getFactoryByName(context, factName);
+		assertNotNull("Cannot find the factory FooProvider-1", fact);
+		
+		Properties props = new Properties();
+		props.put("name", compName);
+		ComponentInstance ci = null;
+		try {
+			ci = fact.createComponentInstance(props);
+		} catch (Exception e1) { fail(e1.getMessage()); }		
+		
+		// Get a FooService provider
+		try {
+			refs = context.getServiceReferences(FooService.class.getName(), "(instance.name=" + compName + ")");
+		} catch (InvalidSyntaxException e) { fail("Service query failed (2) " + e); }
+		
+		assertNotNull("FS not available", refs);
+		
+		// Get foo object
+		FooService fs = (FooService) context.getService(refs[0]);
+		
+		// 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());
+		InstanceDescription id = 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); 
+		
+		// Unget the service
+		context.ungetService(refs[0]);
+		
+		ci.dispose();
+		
+		// Check that there is no more FooService
+		try {
+			refs = context.getServiceReferences(FooService.class.getName(), null);
+		} catch (InvalidSyntaxException e) { fail("Service query failed (3) : " + e.getMessage()); }
+		
+		assertNull("FS available, but component instance stopped", refs);
+	}
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadata.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,239 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+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.test.scenarios.manipulation.service.BarService;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+
+/**
+ * Check manipulation metadata written in the manifest.
+ */
+public class ManipulationMetadata extends OSGiTestCase {
+
+	public void testGetMetadata() {
+		String header = (String) context.getBundle().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, "Manipulation-FooProviderType-1");
+		assertNotNull("Check manipulation metadata not null for " + "FooProviderType-1", manip);
+	}
+	
+	public void testInterface() {
+		String comp_name = "Manipulation-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());
+	}
+	
+	public void testInterfaces() {
+		String comp_name = "Manipulation-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());
+	}
+	
+	public void testFields() {
+		String comp_name = "Manipulation-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");
+	}
+	
+	public void testPrimitivesFields() {
+		String comp_name = "Manipulation-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[]");		
+	}
+	
+	public void testNoArgMethod() {
+		String comp_name = "Manipulation-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");
+	}
+	
+	public void testOneArgsMethod() {
+		String comp_name = "Manipulation-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"));
+	}
+	
+	public void testTwoArgsMethod() {
+		String comp_name = "Manipulation-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(int i = 0; i < comps.length; i++) {
+			if(comps[i].containsAttribute("factory") && comps[i].getAttribute("factory").equals(comp_name)) {
+				return comps[i].getElements("manipulation")[0];
+			}
+            if(comps[i].containsAttribute("name") && comps[i].getAttribute("name").equals(comp_name)) {
+                return comps[i].getElements("manipulation")[0];
+            }
+		}
+		return null;
+	}
+	
+	private Element getManipulationForComponent(String comp_name) {
+		String header = (String) context.getBundle().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;
+	}
+	
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationMetadataAPI.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,278 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.FieldMetadata;
+import org.apache.felix.ipojo.parser.ManifestMetadataParser;
+import org.apache.felix.ipojo.parser.MethodMetadata;
+import org.apache.felix.ipojo.parser.ParseException;
+import org.apache.felix.ipojo.parser.PojoMetadata;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.BarService;
+import org.apache.felix.ipojo.test.scenarios.manipulation.service.FooService;
+
+public class ManipulationMetadataAPI extends OSGiTestCase {
+    
+    PojoMetadata FooProviderType1, FooBarProviderType1, FooProviderTypeDyn, PrimitiveManipulationTester, SimpleMultipleCheckServiceProvider;
+
+	public void setUp() {
+        String comp_name = "Manipulation-FooProviderType-1";
+        FooProviderType1 = getManipulationMetadataForComponent(comp_name);
+        
+        comp_name = "Manipulation-FooBarProviderType-1";
+        FooBarProviderType1 = getManipulationMetadataForComponent(comp_name);
+        
+        comp_name = "Manipulation-FooProviderType-Dyn";
+        FooProviderTypeDyn = getManipulationMetadataForComponent(comp_name);
+        
+        comp_name = "Manipulation-PrimitiveManipulationTester";
+        PrimitiveManipulationTester = getManipulationMetadataForComponent(comp_name);
+        
+        comp_name = "Manipulation-SimpleMultipleCheckServiceProvider";
+        SimpleMultipleCheckServiceProvider = getManipulationMetadataForComponent(comp_name);
+	}
+	
+	public void testGetMetadata() {
+		String header = (String) context.getBundle().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, "Manipulation-FooProviderType-1");
+        assertNotNull("Check manipulation metadata not null for " + "Manipulation-FooProviderType-1", manip);
+        PojoMetadata mm = new PojoMetadata(manip);
+        assertNotNull("Check mm not null", mm);
+	}
+	
+	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()));
+	}
+	
+	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()));
+	}
+	
+	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);
+	}
+	
+	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[]");		
+	}
+	
+	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");
+	}
+	
+	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");
+	}
+	
+	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) context.getBundle().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);
+        return new PojoMetadata(manip);
+    }	
+
+}

Added: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java?rev=651646&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java (added)
+++ felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/ManipulationTestSuite.java Fri Apr 25 09:49:43 2008
@@ -0,0 +1,40 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.manipulation;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class ManipulationTestSuite {
+
+	public static Test suite(BundleContext bc) {
+		OSGiTestSuite ots = new OSGiTestSuite("Manipulation Test Suite", bc);
+		ots.addTestSuite(ManipulationMetadata.class);
+		ots.addTestSuite(PrimitiveTypeTest.class);
+		ots.addTestSuite(PrimitiveTypeTest2.class);
+		ots.addTestSuite(GetComponentInstanceTest.class);
+        ots.addTestSuite(ManipulationMetadataAPI.class);
+        ots.addTestSuite(ExceptionTest.class);
+        ots.addTestSuite(POJOCreation.class);
+		return ots;
+	}
+
+}



Mime
View raw message