Split the composite test suite
Add the annotation test suite (checking annotations processing)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@652169 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/tests.core.service.dependency.filter/pom.xml b/ipojo/tests/tests.core.service.dependency.filter/pom.xml
new file mode 100644
index 0000000..c0b144a
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/pom.xml
@@ -0,0 +1,104 @@
+<!--

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

+	or more contributor license agreements.  See the NOTICE file

+	distributed with this work for additional information

+	regarding copyright ownership.  The ASF licenses this file

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

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

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

+	

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

+	

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

+	software distributed under the License is distributed on an

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

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

+	specific language governing permissions and limitations

+	under the License.

+-->

+<project>

+	<modelVersion>4.0.0</modelVersion>

+	<packaging>bundle</packaging>

+	<name>iPOJO Service Dependency (Filter) Test Suite</name>

+	<artifactId>tests.core.service.dependency.filter</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>

+		<dependency>

+			<groupId>ipojo.tests</groupId>

+			<artifactId>tests.core.service.dependency</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>

+						<Bundle-SymbolicName>

+							${pom.artifactId}

+						</Bundle-SymbolicName>

+						<Private-Package>

+							org.apache.felix.ipojo.test.scenarios.service.dependency.filter, org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component, org.apache.felix.ipojo.test.scenarios.util  

+						</Private-Package>

+						<Test-Suite>

+							org.apache.felix.ipojo.test.scenarios.service.dependency.filter.FilteredDependencyTestSuite

+						</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.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FilteredDependencyTestSuite.java b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FilteredDependencyTestSuite.java
new file mode 100644
index 0000000..182f526
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/FilteredDependencyTestSuite.java
@@ -0,0 +1,37 @@
+/* 

+ * 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.service.dependency.filter;

+

+import junit.framework.Test;

+

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

+import org.osgi.framework.BundleContext;

+

+public class FilteredDependencyTestSuite {

+

+	public static Test suite(BundleContext bc) {

+		OSGiTestSuite ots = new OSGiTestSuite("iPOJO Filtered Service Dependency Test Suite", bc);

+		 ots.addTestSuite(SimpleFilterDependencies.class);

+	        ots.addTestSuite(OptionalSimpleFilterDependencies.class);

+	        ots.addTestSuite(MultipleFilterDependencies.class);

+	        ots.addTestSuite(OptionalMultipleFilterDependencies.class);

+		return ots;

+	}

+

+}

diff --git a/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java
new file mode 100644
index 0000000..c784e0c
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java
@@ -0,0 +1,571 @@
+/* 

+ * 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.service.dependency.filter;

+

+import java.util.Properties;

+

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

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

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

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

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

+import org.osgi.framework.ServiceReference;

+

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

+

+public class MultipleFilterDependencies extends OSGiTestCase {

+	

+	ComponentInstance instance1, instance2, instance3;

+	ComponentInstance fooProvider1, fooProvider2;

+	

+	public void setUp() {

+		try {

+			Properties prov = new Properties();

+			prov.put("name", "FooProvider1");

+			fooProvider1 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

+			fooProvider1.stop();

+			

+			prov = new Properties();

+            prov.put("name", "FooProvider2");

+            fooProvider2 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

+            fooProvider2.stop();

+		

+			Properties i1 = new Properties();

+			i1.put("name", "Subscriber1");

+			instance1 = Utils.getFactoryByName(context, "MultipleFilterCheckServiceSubscriber").createComponentInstance(i1);

+			

+			Properties i2 = new Properties();

+            i2.put("name", "Subscriber2");

+            Properties ii2 = new Properties();

+            ii2.put("id2", "(toto=A)");

+            i2.put("requires.filters", ii2);

+            instance2 = Utils.getFactoryByName(context, "MultipleFilterCheckServiceSubscriber2").createComponentInstance(i2);

+            

+            Properties i3 = new Properties();

+            i3.put("name", "Subscriber3");

+            Properties ii3 = new Properties();

+            ii3.put("id1", "(toto=A)");

+            i3.put("requires.filters", ii3);

+            instance3 = Utils.getFactoryByName(context, "MultipleFilterCheckServiceSubscriber").createComponentInstance(i3);

+		

+		} catch(Exception e) { 

+		    e.printStackTrace();

+		    fail(e.getMessage()); }

+		

+	}

+	

+	public void tearDown() {

+		instance1.dispose();

+		instance2.dispose();

+		instance3.dispose();

+		fooProvider1.dispose();

+		fooProvider2.dispose();

+		instance1 = null;

+		instance2 = null;

+		instance3 = null;

+		fooProvider1 = null;

+		fooProvider2 = null;

+	}

+	

+	public void testMultipleNotMatch() {

+	    instance1.start();

+	    

+		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check architecture availability", arch_ref);

+		InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+

+        

+		fooProvider1.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+		

+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+		assertNotNull("Check CheckService availability", cs_ref);

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

+		// change the value of the property toto

+		cs.check();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        fooProvider2.start();

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        CheckService cs2 = (CheckService) context.getService(cs_ref2);

+        // change the value of the property toto

+        cs2.check();

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+		fooProvider2.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 7", id.getState() == ComponentInstance.INVALID);

+		

+		

+		fooProvider2.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+		

+		fooProvider2.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 9", id.getState() == ComponentInstance.INVALID);

+		

+        id = null;

+        cs = null;

+        cs2 = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);		

+	}

+	

+	public void testMultipleMatch() {

+	    

+	    fooProvider1.start();

+	    fooProvider2.start();

+	    

+	    ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        CheckService cs2 = (CheckService) context.getService(cs_ref2);

+        // change the value of the property toto

+        cs2.check();

+	    

+        instance1.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        id = null;

+        cs = null;

+        cs2 = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);      

+    }

+	

+	public void testMultipleNotMatchInstance() {

+        instance3.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+        

+        

+        fooProvider1.start();

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+        

+        

+        cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.start();

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        CheckService cs2 = (CheckService) context.getService(cs_ref2);

+        // change the value of the property toto

+        cs2.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        // change the value of the property toto

+        cs2.check();

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 7", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 9", id.getState() == ComponentInstance.INVALID);

+        

+        id = null;

+        cs = null;

+        cs2 = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);

+    }

+    

+    public void testMultipleMatchInstance() {

+        

+        fooProvider1.start();

+        fooProvider2.start();

+        instance3.start();

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+       

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);        

+    }

+	

+    public void testMultipleNotMatchInstanceWithoutFilter() {

+        instance2.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+        

+        

+        fooProvider1.start();

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+        

+        

+        cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.start();

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        CheckService cs2 = (CheckService) context.getService(cs_ref2);

+        // change the value of the property toto

+        cs2.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        // change the value of the property toto

+        cs2.check();

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 7", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 9", id.getState() == ComponentInstance.INVALID);

+        

+        id = null;

+        cs = null;

+        cs2 = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);

+    }

+    

+    public void testMultipleMatchInstanceWithoutFilter() {

+        fooProvider1.start();

+        fooProvider2.start();

+        instance2.start();

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+       

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);        

+    }

+

+}

diff --git a/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java
new file mode 100644
index 0000000..5616931
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java
@@ -0,0 +1,593 @@
+/* 

+ * 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.service.dependency.filter;

+

+import java.util.Properties;

+

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

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

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

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

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

+import org.osgi.framework.ServiceReference;

+

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

+

+public class OptionalMultipleFilterDependencies extends OSGiTestCase {

+	

+	ComponentInstance instance1, instance2, instance3;

+	ComponentInstance fooProvider1, fooProvider2;

+	

+	public void setUp() {

+		try {

+			Properties prov = new Properties();

+			prov.put("name", "FooProvider1");

+			fooProvider1 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

+			fooProvider1.stop();

+			

+			prov = new Properties();

+            prov.put("name", "FooProvider2");

+            fooProvider2 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

+            fooProvider2.stop();

+		

+			Properties i1 = new Properties();

+			i1.put("name", "Subscriber1");

+			instance1 = Utils.getFactoryByName(context, "OptionalMultipleFilterCheckServiceSubscriber").createComponentInstance(i1);

+			

+			Properties i2 = new Properties();

+            i2.put("name", "Subscriber2");

+            Properties ii2 = new Properties();

+            ii2.put("id2", "(toto=A)");

+            i2.put("requires.filters", ii2);

+            instance2 = Utils.getFactoryByName(context, "OptionalMultipleFilterCheckServiceSubscriber2").createComponentInstance(i2);

+            

+            Properties i3 = new Properties();

+            i3.put("name", "Subscriber3");

+            Properties ii3 = new Properties();

+            ii3.put("id1", "(toto=A)");

+            i3.put("requires.filters", ii3);

+            instance3 = Utils.getFactoryByName(context, "OptionalMultipleFilterCheckServiceSubscriber").createComponentInstance(i3);

+		

+		} catch(Exception e) { 

+		    e.printStackTrace();

+		    fail(e.getMessage()); }

+		

+	}

+	

+	public void tearDown() {

+		instance1.dispose();

+		instance2.dispose();

+		instance3.dispose();

+		fooProvider1.dispose();

+		fooProvider2.dispose();

+		instance1 = null;

+		instance2 = null;

+		instance3 = null;

+		fooProvider1 = null;

+		fooProvider2 = null;

+	}

+	

+	public void testMultipleNotMatch() {

+	    instance1.start();

+	    

+		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check architecture availability", arch_ref);

+		InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+		ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+		fooProvider1.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+		assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+		

+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+		assertNotNull("Check CheckService availability", cs_ref);

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

+		// change the value of the property toto

+		cs.check();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        fooProvider2.start();

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        CheckService cs2 = (CheckService) context.getService(cs_ref2);

+        // change the value of the property toto

+        cs2.check();

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+		fooProvider2.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);

+		assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+		assertTrue("Check Array size - 7", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+		

+		fooProvider2.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+		

+		fooProvider2.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 9", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 9", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 9", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+		

+        id = null;

+        cs = null;

+        cs2 = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);		

+	}

+	

+	public void testMultipleMatch() {

+	    

+	    fooProvider1.start();

+	    fooProvider2.start();

+	    

+	    ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        CheckService cs2 = (CheckService) context.getService(cs_ref2);

+        // change the value of the property toto

+        cs2.check();

+	    

+        instance1.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        id = null;

+        cs = null;

+        cs2 = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);      

+    }

+	

+	public void testMultipleNotMatchInstance() {

+        instance3.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        fooProvider1.start();

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        fooProvider2.start();

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        CheckService cs2 = (CheckService) context.getService(cs_ref2);

+        // change the value of the property toto

+        cs2.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        // change the value of the property toto

+        cs2.check();

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 7", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 9", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 9", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 9", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        id = null;

+        cs = null;

+        cs2 = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);

+    }

+    

+    public void testMultipleMatchInstance() {

+        

+        fooProvider1.start();

+        fooProvider2.start();

+        instance3.start();

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);        

+    }

+	

+    public void testMultipleNotMatchInstanceWithoutFilter() {

+        instance2.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        fooProvider1.start();

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        fooProvider2.start();

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        CheckService cs2 = (CheckService) context.getService(cs_ref2);

+        // change the value of the property toto

+        cs2.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        

+        // change the value of the property toto

+        cs2.check();

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 6", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 7", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 8", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 9", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 9", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 9", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        id = null;

+        cs = null;

+        cs2 = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);   

+    }

+    

+    public void testMultipleMatchInstanceWithoutFilter() {

+

+        

+        fooProvider1.start();

+        fooProvider2.start();

+        instance2.start();

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        

+        ServiceReference cs_ref2 = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref2);

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 1", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 2", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Array size - 3", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(0)));

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertTrue("Check Array size - 4", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(1)));

+        

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(2)));

+        assertTrue("Check Array size - 5", ((Integer)cs_instance.getProps().get("Size")).equals(new Integer(2)));

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);

+        context.ungetService(cs_ref2);      

+    }

+

+}

diff --git a/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java
new file mode 100644
index 0000000..57db4ec
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java
@@ -0,0 +1,559 @@
+/* 

+ * 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.service.dependency.filter;

+

+import java.util.Properties;

+

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

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

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

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

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

+import org.osgi.framework.ServiceReference;

+

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

+

+public class OptionalSimpleFilterDependencies extends OSGiTestCase {

+	

+	ComponentInstance instance1, instance2, instance3;

+	ComponentInstance fooProvider1, fooProvider2;

+	

+	public void setUp() {

+		try {

+			Properties prov = new Properties();

+			prov.put("name", "FooProvider1");

+			fooProvider1 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

+			fooProvider1.stop();

+			

+			prov = new Properties();

+            prov.put("name", "FooProvider2");

+            fooProvider2 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

+            fooProvider2.stop();

+		

+			Properties i1 = new Properties();

+			i1.put("name", "Subscriber1");

+			instance1 = Utils.getFactoryByName(context, "OptionalSimpleFilterCheckServiceSubscriber").createComponentInstance(i1);

+			

+			Properties i2 = new Properties();

+            i2.put("name", "Subscriber2");

+            Properties ii2 = new Properties();

+            ii2.put("id2", "(toto=A)");

+            i2.put("requires.filters", ii2);

+            instance2 = Utils.getFactoryByName(context, "OptionalSimpleFilterCheckServiceSubscriber2").createComponentInstance(i2);

+            

+            Properties i3 = new Properties();

+            i3.put("name", "Subscriber3");

+            Properties ii3 = new Properties();

+            ii3.put("id1", "(toto=A)");

+            i3.put("requires.filters", ii3);

+            instance3 = Utils.getFactoryByName(context, "OptionalSimpleFilterCheckServiceSubscriber").createComponentInstance(i3);

+		

+		} catch(Exception e) { 

+		    e.printStackTrace();

+		    fail(e.getMessage()); }

+		

+	}

+	

+	public void tearDown() {

+		instance1.dispose();

+		instance2.dispose();

+		instance3.dispose();

+		fooProvider1.dispose();

+		fooProvider2.dispose();

+		instance1 = null;

+		instance2 = null;

+		instance3 = null;

+		fooProvider1 = null;

+		fooProvider2 = null;

+	}

+	

+	public void testSimpleNotMatch() {

+	    instance1.start();

+	    

+		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check architecture availability", arch_ref);

+		InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+		ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+		fooProvider1.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+		assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+		

+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+		assertNotNull("Check CheckService availability", cs_ref);

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

+		// change the value of the property toto

+		cs.check();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+		

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+		fooProvider1.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+		assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+		assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+		fooProvider1.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+		

+		cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check CheckService availability", cs_instance_ref);

+		cs_instance = (CheckService) context.getService(cs_instance_ref);

+		assertTrue("check CheckService invocation", cs_instance.check());

+		assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+		assertFalse("Check Nullable - 7", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+		

+		fooProvider1.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+		assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+		assertTrue("Check Nullable - 8", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+		

+		id = null;

+		cs = null;

+		cs_instance = null;

+		context.ungetService(cs_instance_ref);

+		context.ungetService(arch_ref);

+		context.ungetService(cs_ref);		

+	}

+	

+	public void testSimpleMatch() {

+	    

+	    fooProvider1.start();

+	    

+	    ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+	    

+        instance1.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+	

+	public void testSimpleNotMatchInstance() {

+        instance3.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.start();

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 7", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 8", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+    

+    public void testSimpleMatchInstance() {

+        

+        fooProvider1.start();

+        instance3.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+	

+    public void testSimpleNotMatchInstanceWithoutFilter() {

+        instance2.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.start();

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 7", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 7", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 7", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 8", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 8", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 8", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);      

+    }

+    

+    public void testSimpleMatchInstanceWithoutFilter() {

+

+        fooProvider1.start();

+        instance2.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 1", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 1", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 2", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 2", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 3", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 3", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 4", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 4", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 5", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(1)));

+        assertFalse("Check Nullable - 5", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 6", id.getState() == ComponentInstance.VALID);

+        assertTrue("Check service invocation", cs_instance.check());

+        assertTrue("Check service Binding - 6", ((Integer)cs_instance.getProps().get("Bind")).equals(new Integer(0)));

+        assertTrue("Check Nullable - 6", ((Boolean)cs_instance.getProps().get("Nullable")).booleanValue());

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+

+}

diff --git a/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java
new file mode 100644
index 0000000..d836312
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java
@@ -0,0 +1,499 @@
+/* 

+ * 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.service.dependency.filter;

+

+import java.util.Properties;

+

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

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

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

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

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

+import org.osgi.framework.ServiceReference;

+

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

+

+public class SimpleFilterDependencies extends OSGiTestCase {

+	

+	ComponentInstance instance1, instance2, instance3;

+	ComponentInstance fooProvider1, fooProvider2;

+	

+	public void setUp() {

+		try {

+			Properties prov = new Properties();

+			prov.put("name", "FooProvider1");

+			fooProvider1 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

+			fooProvider1.stop();

+			

+			prov = new Properties();

+            prov.put("name", "FooProvider2");

+            fooProvider2 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

+            fooProvider2.stop();

+		

+			Properties i1 = new Properties();

+			i1.put("name", "Subscriber1");

+			instance1 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceSubscriber").createComponentInstance(i1);

+			

+			Properties i2 = new Properties();

+            i2.put("name", "Subscriber2");

+            Properties ii2 = new Properties();

+            ii2.put("id2", "(toto=A)");

+            i2.put("requires.filters", ii2);

+            instance2 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceSubscriber2").createComponentInstance(i2);

+            

+            Properties i3 = new Properties();

+            i3.put("name", "Subscriber3");

+            Properties ii3 = new Properties();

+            ii3.put("id1", "(toto=A)");

+            i3.put("requires.filters", ii3);

+            instance3 = Utils.getFactoryByName(context, "SimpleFilterCheckServiceSubscriber").createComponentInstance(i3);

+		

+		} catch(Exception e) { 

+		    e.printStackTrace();

+		    fail(e.getMessage()); }

+		

+	}

+	

+	public void tearDown() {

+		instance1.dispose();

+		instance2.dispose();

+		instance3.dispose();

+		fooProvider1.dispose();

+		fooProvider2.dispose();

+		instance1 = null;

+		instance2 = null;

+		instance3 = null;

+		fooProvider1 = null;

+		fooProvider2 = null;

+	}

+	

+	public void testSimpleNotMatch() {

+	    instance1.start();

+	    

+		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check architecture availability", arch_ref);

+		InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+		

+		fooProvider1.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+		

+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+		assertNotNull("Check CheckService availability", cs_ref);

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

+		// change the value of the property toto

+		cs.check();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+		

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+		fooProvider1.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);

+		

+		fooProvider1.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+		

+		cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check CheckService availability", cs_instance_ref);

+		cs_instance = (CheckService) context.getService(cs_instance_ref);

+		assertTrue("check CheckService invocation", cs_instance.check());

+		

+		fooProvider1.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);

+		

+		id = null;

+		cs = null;

+		cs_instance = null;

+		context.ungetService(cs_instance_ref);

+		context.ungetService(arch_ref);

+		context.ungetService(cs_ref);		

+	}

+	

+	public void testSimpleMatch() {

+	    

+	    fooProvider1.start();

+	    

+	    ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+	    

+        instance1.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+	

+	public void testSimpleNotMatchInstance() {

+        instance3.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider1.start();

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+    

+    public void testSimpleMatchInstance() {

+        

+        fooProvider1.start();

+        instance3.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+	

+    public void testSimpleNotMatchInstanceWithoutFilter() {

+        instance2.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider1.start();

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 4", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 5", id.getState() == ComponentInstance.INVALID);

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+    

+    public void testSimpleMatchInstanceWithoutFilter() {

+        

+        fooProvider1.start();

+        instance2.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        CheckService cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("Check service invocation", cs_instance.check());

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), fooProvider1.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

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

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+        

+        // change the value of the property toto

+        cs.check();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        

+        cs_instance_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_instance_ref);

+        cs_instance = (CheckService) context.getService(cs_instance_ref);

+        assertTrue("check CheckService invocation", cs_instance.check());

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        context.ungetService(cs_instance_ref);

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+

+}

diff --git a/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java
new file mode 100644
index 0000000..2a81c23
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java
@@ -0,0 +1,95 @@
+/* 

+ * 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.service.dependency.filter.component;

+

+import java.util.Properties;

+

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

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;

+

+public class FilterCheckProvider implements CheckService, FooService {

+

+    private String m_toto;

+    

+    private int bind;

+    

+    private int unbind;

+    

+    public FilterCheckProvider(){

+        m_toto = "A";

+    }

+    

+    public boolean check() {

+        if (m_toto.equals("A")){

+            m_toto="B";

+            return true;

+        } else {

+            m_toto="A";

+            return false;

+        }

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

+        props.put("Bind", new Integer(bind-unbind));

+        return null;

+    }

+    

+    private void Bind() {

+        bind++;

+    }

+    private void Unbind() {

+        unbind++;

+    }

+

+    public boolean foo() {

+        return true;

+    }

+

+    public Properties fooProps() {

+        // TODO Auto-generated method stub

+        return null;

+    }

+

+    public boolean getBoolean() {

+        // TODO Auto-generated method stub

+        return false;

+    }

+

+    public double getDouble() {

+        // TODO Auto-generated method stub

+        return 0;

+    }

+

+    public int getInt() {

+        // TODO Auto-generated method stub

+        return 0;

+    }

+

+    public long getLong() {

+        // TODO Auto-generated method stub

+        return 0;

+    }

+

+    public Boolean getObject() {

+        // TODO Auto-generated method stub

+        return null;

+    }

+

+}

diff --git a/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java
new file mode 100644
index 0000000..cfd1be8
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java
@@ -0,0 +1,56 @@
+/* 

+ * 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.service.dependency.filter.component;

+

+import java.util.Properties;

+

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

+

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

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;

+

+public class FilterCheckSubscriber implements CheckService {

+    

+    private FooService m_foo;

+    

+    private int binded;

+    

+    public FilterCheckSubscriber(){

+    }

+    

+    public boolean check() {

+        m_foo.foo();

+        return true;

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

+        props.put("Bind", new Integer(binded));

+        props.put("Nullable", new Boolean(m_foo instanceof Nullable));

+        return props;

+    }

+    

+    private void Bind() {

+        binded++;

+    }

+    private void Unbind() {

+        binded--;

+    }

+

+}

diff --git a/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/MultipleFilterCheckSubscriber.java b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/MultipleFilterCheckSubscriber.java
new file mode 100644
index 0000000..ca4b3ff
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/MultipleFilterCheckSubscriber.java
@@ -0,0 +1,56 @@
+/* 

+ * 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.service.dependency.filter.component;

+

+import java.util.Properties;

+

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

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;

+

+public class MultipleFilterCheckSubscriber implements CheckService {

+    

+    private FooService[] m_foo;

+    

+    private int binded;

+    

+    public MultipleFilterCheckSubscriber(){

+    }

+    

+    public boolean check() {

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

+            m_foo[i].foo();

+        }

+        return true;

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

+        props.put("Bind", new Integer(binded));

+        props.put("Size",  new Integer(m_foo.length));

+        return props;

+    }

+    

+    private void Bind() {

+        binded++;

+    }

+    private void Unbind() {

+        binded--;

+    }

+

+}

diff --git a/ipojo/tests/tests.core.service.dependency.filter/src/main/resources/metadata.xml b/ipojo/tests/tests.core.service.dependency.filter/src/main/resources/metadata.xml
new file mode 100644
index 0000000..f1a8254
--- /dev/null
+++ b/ipojo/tests/tests.core.service.dependency.filter/src/main/resources/metadata.xml
@@ -0,0 +1,100 @@
+<ipojo>

+	<!--  Simple Filter Dependencies -->

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"

+		factory="SimpleFilterCheckServiceProvider" architecture="true">

+		<provides>

+			<property field="m_toto" name="toto" value="A" />

+		</provides>

+	</component>

+

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+		factory="SimpleFilterCheckServiceSubscriber" architecture="true">

+		<requires field="m_foo" filter="(toto=B)" id="id1">

+			<callback type="bind" method="Bind" />

+			<callback type="unbind" method="Unbind" />

+		</requires>

+		<provides />

+	</component>

+

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+		factory="SimpleFilterCheckServiceSubscriber2" architecture="true">

+		<requires field="m_foo" id="id2">

+			<callback type="bind" method="Bind" />

+			<callback type="unbind" method="Unbind" />

+		</requires>

+		<provides />

+	</component>

+

+	<!--  Optional Simple Filter Dependencies -->

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+		factory="OptionalSimpleFilterCheckServiceSubscriber"

+		architecture="true">

+		<requires field="m_foo" filter="(toto=B)" id="id1"

+			optional="true">

+			<callback type="bind" method="Bind" />

+			<callback type="unbind" method="Unbind" />

+		</requires>

+		<provides />

+	</component>

+

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+		factory="OptionalSimpleFilterCheckServiceSubscriber2"

+		architecture="true">

+		<requires field="m_foo" id="id2" optional="true">

+			<callback type="bind" method="Bind" />

+			<callback type="unbind" method="Unbind" />

+		</requires>

+		<provides />

+	</component>

+

+	<!-- Aggregate filter Dependencies-->

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

+		factory="MultipleFilterCheckServiceSubscriber" architecture="true">

+		<requires field="m_foo" filter="(toto=B)" id="id1">

+			<callback type="bind" method="Bind" />

+			<callback type="unbind" method="Unbind" />

+		</requires>

+		<provides />

+	</component>

+

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

+		factory="MultipleFilterCheckServiceSubscriber2" architecture="true">

+		<requires field="m_foo" id="id2">

+			<callback type="bind" method="Bind" />

+			<callback type="unbind" method="Unbind" />

+		</requires>

+		<provides />

+	</component>

+

+	<!--  Optional Aggregate Filter Dependencies -->

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

+		factory="OptionalMultipleFilterCheckServiceSubscriber"

+		architecture="true">

+		<requires field="m_foo" filter="(toto=B)" id="id1"

+			optional="true">

+			<callback type="bind" method="Bind" />

+			<callback type="unbind" method="Unbind" />

+		</requires>

+		<provides />

+	</component>

+

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

+		factory="OptionalMultipleFilterCheckServiceSubscriber2"

+		architecture="true">

+		<requires field="m_foo" id="id2" optional="true">

+			<callback type="bind" method="Bind" />

+			<callback type="unbind" method="Unbind" />

+		</requires>

+		<provides />

+	</component>

+

+</ipojo>