Split the iPOJO test suite in several bundles.


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

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

+	or more contributor license agreements.  See the NOTICE file

+	distributed with this work for additional information

+	regarding copyright ownership.  The ASF licenses this file

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

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

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

+	

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

+	

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

+	software distributed under the License is distributed on an

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

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

+	specific language governing permissions and limitations

+	under the License.

+-->

+<project>

+	<modelVersion>4.0.0</modelVersion>

+	<packaging>bundle</packaging>

+	<name>iPOJO External Handler Mechanism Test Suite</name>

+	<artifactId>tests.core.external.handlers</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.eh.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.eh.ExternalHandlerTestSuite

+						</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>

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandler.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandler.java
new file mode 100644
index 0000000..efd79d6
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandler.java
@@ -0,0 +1,100 @@
+/* 

+ * 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.Dictionary;

+import java.util.Properties;

+

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

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

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

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

+import org.apache.felix.ipojo.metadata.Element;

+import org.apache.felix.ipojo.test.scenarios.eh.service.CheckService;

+import org.osgi.framework.ServiceRegistration;

+

+public class CheckServiceHandler extends PrimitiveHandler implements CheckService {

+	

+	ServiceRegistration sr;

+	boolean isValid;

+	int changes = 0;

+	static final String NAMESPACE = "org.apache.felix.ipojo.test.handler.checkservice";

+	

+	Properties props = new Properties();

+

+	public void configure(Element metadata, Dictionary configuration) {

+		Element[] meta = metadata.getElements("check", NAMESPACE);

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

+		// Get handler props 

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

+		if(configuration.get("csh.simple") != null) { props.put("Simple", configuration.get("csh.simple")); }

+		if(configuration.get("csh.map") != null) { 

+			Dictionary m = (Dictionary) configuration.get("csh.map");

+			props.put("Map1", m.get("a"));

+			props.put("Map2", m.get("b"));

+			props.put("Map3", m.get("c"));

+		}

+		props.put("changes", new Integer(changes));

+		

+	}

+	

+	public void initializeComponentFactory(ComponentTypeDescription cd, Element metadata) {

+	    cd.addProperty(new PropertyDescription("csh.simple", "java.lang.String", null));

+        cd.addProperty(new PropertyDescription("csh.map", "java.util.Dictionary", null));

+	}

+	

+	public void start() {

+		if(sr == null) {

+			sr = getInstanceManager().getContext().registerService(CheckService.class.getName(), this, props);

+		}

+		isValid = true;

+	}

+	

+	public void stop() {

+		isValid = false;

+		synchronized(this) {

+			if(sr != null) { sr.unregister(); }

+		}

+	}

+	

+	public boolean check() {

+		if(isValid) { isValid = false;}

+		else { isValid = true; }

+		return isValid;

+	}

+

+	public Properties getProps() {

+		return props;

+	}

+	

+	public void stateChanged(int state) {

+		changes++;

+		props.put("changes", new Integer(changes));

+		sr.setProperties(props);

+	}

+

+	public String getName() {

+		return NAMESPACE;

+	}

+	

+	public HandlerDescription getDescription() {

+		return new CheckServiceHandlerDescription(this);

+	}

+

+}

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandlerDescription.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandlerDescription.java
new file mode 100644
index 0000000..ade2474
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceHandlerDescription.java
@@ -0,0 +1,38 @@
+/* 

+ * 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.Handler;

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

+import org.apache.felix.ipojo.metadata.Attribute;

+import org.apache.felix.ipojo.metadata.Element;

+

+public class CheckServiceHandlerDescription extends HandlerDescription {

+

+	public CheckServiceHandlerDescription(Handler h) {

+		super(h);

+	}

+	

+	public Element getHandlerInfo() {

+		Element elem = super.getHandlerInfo();

+		elem.addAttribute(new Attribute("isValid", isValid()+""));

+		return elem;

+	}

+

+}

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProviderType1.java
new file mode 100644
index 0000000..e7040e7
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/component/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.test.scenarios.component;

+

+import java.util.Properties;

+

+import org.apache.felix.ipojo.test.scenarios.eh.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;

+	}

+

+}

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/ExternalHandlerTestSuite.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/ExternalHandlerTestSuite.java
new file mode 100644
index 0000000..9965643
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/ExternalHandlerTestSuite.java
@@ -0,0 +1,35 @@
+/* 

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

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

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

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

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

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

+ *

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

+ *

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

+ * software distributed under the License is distributed on an

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

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

+ * specific language governing permissions and limitations

+ * under the License.

+ */

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

+

+import junit.framework.Test;

+import junit.framework.TestSuite;

+

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

+import org.osgi.framework.BundleContext;

+

+public class ExternalHandlerTestSuite extends TestSuite {

+

+	public static Test suite(BundleContext bc) {

+		OSGiTestSuite ots = new OSGiTestSuite("External Handler Test Suite", bc);

+		ots.addTestSuite(HandlerTest.class);

+		return ots;

+	}

+

+}

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java
new file mode 100644
index 0000000..82c404a
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/HandlerTest.java
@@ -0,0 +1,191 @@
+/* 

+ * 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.eh;

+

+import java.util.Properties;

+

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

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

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

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

+import org.apache.felix.ipojo.test.scenarios.eh.service.CheckService;

+import org.apache.felix.ipojo.test.scenarios.util.Utils;

+import org.osgi.framework.InvalidSyntaxException;

+import org.osgi.framework.ServiceReference;

+

+public class HandlerTest extends OSGiTestCase {

+

+	ComponentInstance instance;

+

+	public void setUp() {

+		Properties props = new Properties();

+		props.put("name", "HandlerTest-1");

+		props.put("csh.simple", "simple");

+		Properties p = new Properties();

+		p.put("a", "a");

+		p.put("b", "b");

+		p.put("c", "c");

+		props.put("csh.map", p);

+		instance = Utils.getComponentInstance(context, "HANDLER-HandlerTester", props);

+	}

+	

+	public void tearDown() {

+		instance.dispose();

+		instance = null;

+	}

+	

+	public void testConfiguration1() {

+		// Check the availability of CheckService

+	    String name = "HandlerTest-1";

+		ServiceReference sr = null;

+		ServiceReference[] refs = null;

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

+        try {

+            refs = context.getServiceReferences(CheckService.class.getName(), filter);

+        } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}

+        if(refs != null) { sr = refs[0]; }

+        

+		assertNotNull("Check the check service availability", sr);

+		

+		CheckService cs = (CheckService) context.getService(sr);

+		Properties p = cs.getProps();

+		assertEquals("Assert 'simple' equality", p.get("Simple"), "simple");

+		assertEquals("Assert 'a' equality", p.get("Map1"), "a");

+		assertEquals("Assert 'b' equality", p.get("Map2"), "b");

+		assertEquals("Assert 'c' equality", p.get("Map3"), "c");

+		

+		cs = null;

+		context.ungetService(sr);

+	}

+	

+	public void testConfiguration2() {

+		// Check the availability of CheckService

+	    String name = "HandlerTest-2";

+        ServiceReference sr = null;

+        ServiceReference[] refs = null;

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

+        try {

+            refs = context.getServiceReferences(CheckService.class.getName(), filter);

+        } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}

+        if(refs != null) { sr = refs[0]; }

+		assertNotNull("Check the check service availability", sr);

+		

+		CheckService cs = (CheckService) context.getService(sr);

+		Properties p = cs.getProps();

+		assertEquals("Assert 'simple' equality", p.get("Simple"), "Simple");

+		assertEquals("Assert 'a' equality", p.get("Map1"), "a");

+		assertEquals("Assert 'b' equality", p.get("Map2"), "b");

+		assertEquals("Assert 'c' equality", p.get("Map3"), "c");

+		

+		cs = null;

+		context.ungetService(sr);

+	}

+	

+	public void testLifecycle() {

+		// Check the availability of CheckService

+	    String name = "HandlerTest-1";

+        ServiceReference sr = null;

+        ServiceReference[] refs = null;

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

+        try {

+            refs = context.getServiceReferences(CheckService.class.getName(), filter);

+        } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}

+        if(refs != null) { sr = refs[0]; }

+		assertNotNull("Check the check service availability", sr);

+		

+		ServiceReference sr_arch = Utils.getServiceReferenceByName(context, Architecture.class.getName(), "HandlerTest-1");

+		Architecture arch = (Architecture) context.getService(sr_arch);

+		

+		assertEquals("Check instance validity - 0", arch.getInstanceDescription().getState(), ComponentInstance.VALID);

+		

+		CheckService cs = (CheckService) context.getService(sr);

+		Properties p = cs.getProps();

+		Integer changes = (Integer) p.get("changes");

+		assertNotNull("Check changes no null", changes);

+		assertEquals("Changes changes 1 ("+changes+")", changes.intValue(), 1);

+		assertEquals("Check instance validity - 1", arch.getInstanceDescription().getState(), ComponentInstance.VALID);

+		cs.check();

+		p = cs.getProps();

+		changes = (Integer) p.get("changes");

+		assertEquals("Changes changes 2 ("+changes+")", changes.intValue(), 2);

+		assertEquals("Check instance validity - 2", arch.getInstanceDescription().getState(), ComponentInstance.INVALID);

+		cs.check();

+		p = cs.getProps();

+		changes = (Integer) p.get("changes");

+		assertEquals("Changes changes 3 ("+changes+")", changes.intValue(), 3);

+		assertEquals("Check instance validity - 3", arch.getInstanceDescription().getState(), ComponentInstance.VALID);

+		cs.check();

+		p = cs.getProps();

+		changes = (Integer) p.get("changes");

+		assertEquals("Changes changes 4 ("+changes+")", changes.intValue(), 4);

+		assertEquals("Check instance validity - 4", arch.getInstanceDescription().getState(), ComponentInstance.INVALID);

+		

+		cs = null;

+		arch = null;

+		context.ungetService(sr_arch);

+		context.ungetService(sr);

+	}

+	

+	public void testAvailability() {

+	    String name = "HandlerTest-1";

+        ServiceReference sr = null;

+        ServiceReference[] refs = null;

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

+        try {

+            refs = context.getServiceReferences(CheckService.class.getName(), filter);

+        } catch (InvalidSyntaxException e) { System.err.println("Invalid Filter : " + filter);}

+        if(refs != null) { sr = refs[0]; }

+        assertNotNull("Check the check service availability", sr);

+        

+        ServiceReference sr_arch = Utils.getServiceReferenceByName(context, Architecture.class.getName(), "HandlerTest-1");

+        Architecture arch = (Architecture) context.getService(sr_arch);

+        assertEquals("Check validity", arch.getInstanceDescription().getState(), ComponentInstance.VALID);

+        

+        // Kill the handler factory

+        HandlerFactory f = (HandlerFactory) Utils.getHandlerFactoryByName(context, "check");

+        f.stop();

+        

+        sr = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "HandlerTest-1");

+        assertNull("Check the check service unavailability", sr);

+        

+        sr_arch = Utils.getServiceReferenceByName(context, Architecture.class.getName(), "HandlerTest-1");

+        assertNull("Check the architecture unavailability", sr_arch);

+        

+        // The instance is disposed, restart the handler

+        f.start();

+        

+        Properties props = new Properties();

+        props.put("name", "HandlerTest-1");

+        props.put("csh.simple", "simple");

+        Properties p = new Properties();

+        p.put("a", "a");

+        p.put("b", "b");

+        p.put("c", "c");

+        props.put("csh.map", p);

+        instance = Utils.getComponentInstance(context, "HANDLER-HandlerTester", props);

+        

+        sr = Utils.getServiceReferenceByName(context, CheckService.class.getName(), "HandlerTest-1");

+        assertNotNull("Check the check service availability - 2", sr);

+        

+        sr_arch = Utils.getServiceReferenceByName(context, Architecture.class.getName(), "HandlerTest-1");

+        arch = (Architecture) context.getService(sr_arch);

+        assertEquals("Check validity - 2", arch.getInstanceDescription().getState(), ComponentInstance.VALID);

+	}

+

+}

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/CheckService.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/CheckService.java
new file mode 100644
index 0000000..9239759
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/CheckService.java
@@ -0,0 +1,31 @@
+/* 

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

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

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

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

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

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

+ *

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

+ *

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

+ * software distributed under the License is distributed on an

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

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

+ * specific language governing permissions and limitations

+ * under the License.

+ */

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

+

+import java.util.Properties;

+

+public interface CheckService {

+    

+    public static final String foo = "foo";

+	

+	public boolean check();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/FooService.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/FooService.java
new file mode 100644
index 0000000..38d66ff
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/eh/service/FooService.java
@@ -0,0 +1,39 @@
+/* 

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

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

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

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

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

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

+ *

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

+ *

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

+ * software distributed under the License is distributed on an

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

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

+ * specific language governing permissions and limitations

+ * under the License.

+ */

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

+

+import java.util.Properties;

+

+public interface FooService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
new file mode 100644
index 0000000..cb87c86
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
@@ -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;

+    }

+

+}

diff --git a/ipojo/tests/tests.core.external.handlers/src/main/resources/metadata.xml b/ipojo/tests/tests.core.external.handlers/src/main/resources/metadata.xml
new file mode 100644
index 0000000..134c5a7
--- /dev/null
+++ b/ipojo/tests/tests.core.external.handlers/src/main/resources/metadata.xml
@@ -0,0 +1,24 @@
+<ipojo

+	xmlns:cs="org.apache.felix.ipojo.test.handler.checkservice">

+	<handler

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

+		name="check"

+		namespace="org.apache.felix.ipojo.test.handler.checkservice"

+		architecture="false">

+		<controller field="isValid" />

+	</handler>

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

+		factory="HANDLER-HandlerTester" architecture="true">

+		<cs:check />

+	</component>

+	<instance name="HandlerTest-2" component="HANDLER-HandlerTester">

+		<property name="csh.simple" value="Simple" />

+		<property name="csh.map">

+			<property name="a" value="a" />

+			<property name="b" value="b" />

+			<property name="c" value="c" />

+		</property>

+	</instance>

+	

+</ipojo>