Really execute the Instantiate annotation test suite
Improve @Instantiate annotation processing

Fix a race condition when service properties are modified during the service object constructor.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@894154 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
index c2cc372..6152eff 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
@@ -106,6 +106,11 @@
      * Service Object creation policy.
      */
     private CreationStrategy m_strategy;
+    
+    /**
+     * Were the properties updated during the processing.
+     */
+    private volatile boolean m_wasUpdated;
 
     /**
      * Creates a provided service object.
@@ -305,6 +310,11 @@
             Properties serviceProperties = getServiceProperties();
             m_strategy.onPublication(getInstanceManager(), m_serviceSpecification, serviceProperties);
             m_serviceRegistration = m_handler.getInstanceManager().getContext().registerService(m_serviceSpecification, this, serviceProperties);
+            // An update may happen during the registration, re-check and apply.
+            if (m_wasUpdated) {
+                m_serviceRegistration.setProperties(getServiceProperties());
+                m_wasUpdated = false;
+            }      
         }
     }
 
@@ -371,6 +381,9 @@
         // Update the service registration
         if (m_serviceRegistration != null) {
             m_serviceRegistration.setProperties(getServiceProperties());
+        } else {
+            // Need to be updated later.
+            m_wasUpdated = true;
         }
     }
 
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
index ff0e073..2b2861a 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
@@ -70,11 +70,11 @@
      */
     private void addProvidedService(ProvidedService svc) {
         // Verify that the provided service is not already in the array.
-        for (int i = 0; (m_providedServices != null) && (i < m_providedServices.length); i++) {
+        for (int i = 0; i < m_providedServices.length; i++) {
             if (m_providedServices[i] == svc) { return; }
         }
 
-        if (m_providedServices != null && m_providedServices.length > 0) { //TODO check here if we can avoid one test
+        if (m_providedServices.length > 0) {
             ProvidedService[] newPS = new ProvidedService[m_providedServices.length + 1];
             System.arraycopy(m_providedServices, 0, newPS, 0, m_providedServices.length);
             newPS[m_providedServices.length] = svc;
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java
index 2726a05..90b268d 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Tracker.java
@@ -672,7 +672,8 @@
         }

 

         /**

-         * Common logic to add a service to the tracker used by track and trackInitialServices. The specified reference must have been placed in the adding list before calling this method.

+         * Common logic to add a service to the tracker used by track and trackInitialServices. 

+         * The specified reference must have been placed in the adding list before calling this method.

          * @param reference the Reference to a service to be tracked.

          */

         private void trackAdding(ServiceReference reference) {

diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
index 0355084..a35627a 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MetadataCollector.java
@@ -370,7 +370,7 @@
         public void visitEnd() {
             m_instance = new Element("instance", "");
             if (m_className != null) { // Should not be null.
-                m_instance.addAttribute(new Attribute("component", m_className));
+                m_instance.addAttribute(new Attribute("component", m_className.replace('/', '.')));
             }
             if (m_name != null) {
                 m_instance.addAttribute(new Attribute("name", m_name));
diff --git a/ipojo/tests/core/annotations/pom.xml b/ipojo/tests/core/annotations/pom.xml
index 1a1b0e1..d54fe9b 100644
--- a/ipojo/tests/core/annotations/pom.xml
+++ b/ipojo/tests/core/annotations/pom.xml
@@ -60,6 +60,14 @@
       <artifactId>org.apache.felix.ipojo.handler.eventadmin</artifactId>

       <version>${pom.version}</version>

     </dependency>

+    

+     <dependency>

+      <groupId>org.apache.felix</groupId>

+      <artifactId>org.apache.felix.eventadmin</artifactId>

+      <version>1.0.0</version>

+      <scope>test</scope>

+    </dependency>

+    

   </dependencies>

 

   <build>

@@ -106,6 +114,25 @@
           </execution>

         </executions>

       </plugin>

+      

+      

+       <!-- <plugin>

+        <groupId>org.apache.felix</groupId>

+        <artifactId>maven-junit4osgi-plugin</artifactId>

+        <version>1.1.0-SNAPSHOT</version>

+        <executions>

+          <execution>

+            <goals>

+              <goal>test</goal>

+            </goals>

+            <configuration>

+              <configuration>

+              <org.osgi.http.port>8083</org.osgi.http.port>

+              </configuration>

+            </configuration>

+          </execution>

+        </executions>

+      </plugin>-->

     </plugins>

   </build>

 </project>

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
index dc7d880..c768413 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/AnnotationsTestSuite.java
@@ -48,6 +48,8 @@
         ots.addTestSuite(Extender.class);

         ots.addTestSuite(EventAdmin.class);

 

+        // Instantiate

+        ots.addTestSuite(Instantiate.class);

 

         return ots;

     }

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java
index 67c2d55..67c2e8f 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Instantiate.java
@@ -9,6 +9,7 @@
 import org.apache.felix.ipojo.parser.ManifestMetadataParser;

 import org.apache.felix.ipojo.parser.ParseException;

 import org.osgi.framework.Bundle;

+import org.osgi.framework.InvalidSyntaxException;

 import org.osgi.framework.ServiceReference;

 

 public class Instantiate extends OSGiTestCase {

@@ -20,7 +21,7 @@
     }

 

     public void testInstantiateSimple() {

-        Element[] meta = getInstanceMetadata(context.getBundle(), "org.apache.felix.ipojo.test.scenarios.component.Instantiate");

+        Element[] meta = getInstanceMetadata(context.getBundle(), "org.apache.felix.ipojo.test.scenarios.component.InstantiateSimple");

         assertNotNull(meta);

         assertEquals(1, meta.length);

         assertNull(meta[0].getAttribute("name"));

@@ -32,19 +33,22 @@
         Element[] meta = getInstanceMetadata(context.getBundle(), "org.apache.felix.ipojo.test.scenarios.component.InstantiateWithName");

         assertNotNull(meta);

         assertEquals(1, meta.length);

-        assertNull(meta[0].getAttribute("name"));

+        assertNotNull(meta[0].getAttribute("name"));

+        assertEquals("myInstantiatedInstance", meta[0].getAttribute("name"));

         assertEquals(0, meta[0].getElements().length);

     }

     

-    public void testInstanceCreation() {

-        String in = "org.apache.felix.ipojo.test.scenarios.component.Instantiate-0";

-        ServiceReference ref = helper.getServiceReferenceByName(Architecture.class.getName(), in);

+    public void testInstanceCreation() throws InvalidSyntaxException {

+        String in = "org.apache.felix.ipojo.test.scenarios.component.InstantiateSimple-0";

+        ServiceReference ref = helper.getServiceReferenceByName(org.apache.felix.ipojo.architecture.Architecture.class.getName(), 

+                in);

         assertNotNull(ref);

     }

     

     public void testInstanceCreationWithName() {

         String in = "myInstantiatedInstance";

-        ServiceReference ref = helper.getServiceReferenceByName(Architecture.class.getName(), in);

+        ServiceReference ref = helper.getServiceReferenceByName(org.apache.felix.ipojo.architecture.Architecture.class.getName(), 

+                in);

         assertNotNull(ref);

     }

 

@@ -70,7 +74,7 @@
 

         // Parses the retrieved description and find the component with the

         // given name.

-        List list = new ArrayList();

+        List<Element> list = new ArrayList<Element>();

         try {

             Element element = ManifestMetadataParser.parseHeaderMetadata(elem);

             Element[] childs = element.getElements("instance");

diff --git a/ipojo/tests/core/service-dependency-filter/pom.xml b/ipojo/tests/core/service-dependency-filter/pom.xml
index 46a28ba..2b9e8e9 100644
--- a/ipojo/tests/core/service-dependency-filter/pom.xml
+++ b/ipojo/tests/core/service-dependency-filter/pom.xml
@@ -1,104 +1,122 @@
 <!--

-	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

+  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

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

+  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>1.5.0-SNAPSHOT</version>

-	<dependencies>

-		<dependency>

-			<groupId>org.apache.felix</groupId>

-			<artifactId>org.apache.felix.ipojo</artifactId>

-			<version>${pom.version}</version>

-		</dependency>

-		<dependency>

-			<groupId>org.apache.felix</groupId>

-			<artifactId>org.apache.felix.ipojo.metadata</artifactId>

-			<version>${pom.version}</version>

-		</dependency>

-		<dependency>

-			<groupId>org.apache.felix</groupId>

-			<artifactId>org.osgi.core</artifactId>

-			<version>1.0.1</version>

-		</dependency>

-		<dependency>

-			<groupId>junit</groupId>

-			<artifactId>junit</artifactId>

-			<version>3.8.1</version>

-		</dependency>

-		<dependency>

-			<groupId>org.apache.felix</groupId>

-			<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>

-			<version>1.1.0-SNAPSHOT</version>

-		</dependency>

-		<dependency>

-			<groupId>ipojo.tests</groupId>

-			<artifactId>tests.core.service.dependency</artifactId>

-			<version>${pom.version}</version>

-		</dependency>

-	</dependencies>

-	<build>

-		<plugins>

-			<plugin>

-				<groupId>org.apache.felix</groupId>

-				<artifactId>maven-bundle-plugin</artifactId>

-				<version>1.4.3</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>${pom.version}</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>

+  <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>1.5.0-SNAPSHOT</version>

+  <dependencies>

+    <dependency>

+      <groupId>org.apache.felix</groupId>

+      <artifactId>org.apache.felix.ipojo</artifactId>

+      <version>${pom.version}</version>

+    </dependency>

+    <dependency>

+      <groupId>org.apache.felix</groupId>

+      <artifactId>org.apache.felix.ipojo.metadata</artifactId>

+      <version>${pom.version}</version>

+    </dependency>

+    <dependency>

+      <groupId>org.apache.felix</groupId>

+      <artifactId>org.osgi.core</artifactId>

+      <version>1.0.1</version>

+    </dependency>

+    <dependency>

+      <groupId>junit</groupId>

+      <artifactId>junit</artifactId>

+      <version>3.8.1</version>

+    </dependency>

+    <dependency>

+      <groupId>org.apache.felix</groupId>

+      <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>

+      <version>1.1.0-SNAPSHOT</version>

+    </dependency>

+    <dependency>

+      <groupId>ipojo.tests</groupId>

+      <artifactId>tests.core.service.dependency</artifactId>

+      <version>${pom.version}</version>

+    </dependency>

+  </dependencies>

+  <build>

+    <plugins>

+      <plugin>

+        <groupId>org.apache.felix</groupId>

+        <artifactId>maven-bundle-plugin</artifactId>

+        <version>1.4.3</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>${pom.version}</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>

+      

+       <plugin>

+        <groupId>org.apache.felix</groupId>

+        <artifactId>maven-junit4osgi-plugin</artifactId>

+        <version>1.1.0-SNAPSHOT</version>

+        <executions>

+          <execution>

+            <goals>

+              <goal>test</goal>

+            </goals>

+            <configuration>

+              <configuration>

+              <org.osgi.http.port>8083</org.osgi.http.port>

+              </configuration>

+            </configuration>

+          </execution>

+        </executions>

+      </plugin>

+    </plugins>

+  </build>

 </project>

diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java
index 6334c5c..71349d1 100644
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java
+++ b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/MultipleFilterDependencies.java
@@ -30,27 +30,27 @@
 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("instance.name","FooProvider1");

-			fooProvider1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

-			fooProvider1.stop();

-			

-			prov = new Properties();

+    

+    ComponentInstance instance1, instance2, instance3;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

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

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

+            fooProvider1.stop();

+            

+            prov = new Properties();

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

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

             fooProvider2.stop();

-		

-			Properties i1 = new Properties();

-			i1.put("instance.name","Subscriber1");

-			instance1 = Utils.getFactoryByName(getContext(), "MultipleFilterCheckServiceSubscriber").createComponentInstance(i1);

-			

-			Properties i2 = new Properties();

+        

+            Properties i1 = new Properties();

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

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

+            

+            Properties i2 = new Properties();

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

             Properties ii2 = new Properties();

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

@@ -63,47 +63,47 @@
             ii3.put("id1", "(toto=A)");

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

             instance3 = Utils.getFactoryByName(getContext(), "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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

-		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        } 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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

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

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

 

         

-		fooProvider1.start();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

-		

-		ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());

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

-		CheckService cs = (CheckService) getContext().getService(cs_ref);

-		// change the value of the property toto

-		cs.check();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+        fooProvider1.start();

+        

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

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

+        

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

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

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

+        // change the value of the property toto

+        cs.check();

+        

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

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

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

         assertNotNull("Check CheckService availability", cs_instance_ref);

@@ -138,27 +138,32 @@
         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) getContext().getService(arch_ref)).getInstanceDescription();

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

-		

-		

-		fooProvider2.start();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+        fooProvider2.stop();

+        

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

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

+        

+        

+        fooProvider2.start();

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

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

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

+        // change the value of the property toto

+        cs2.check();

+        

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

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

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

         assertNotNull("Check CheckService availability", cs_instance_ref);

         cs_instance = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

+        

+        fooProvider2.stop();

+        

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

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

-		

+        

         id = null;

         cs = null;

         cs2 = null;

@@ -167,14 +172,14 @@
         getContext().ungetService(arch_ref);

         getContext().ungetService(cs_ref);

         getContext().ungetService(cs_ref2);		

-	}

-	

-	public void testMultipleMatch() {

-	    

-	    fooProvider1.start();

-	    fooProvider2.start();

-	    

-	    ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());

+    }

+    

+    public void testMultipleMatch() {

+        

+        fooProvider1.start();

+        fooProvider2.start();

+        

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

         assertNotNull("Check CheckService availability", cs_ref);

         CheckService cs = (CheckService) getContext().getService(cs_ref);

         // change the value of the property toto

@@ -185,7 +190,7 @@
         CheckService cs2 = (CheckService) getContext().getService(cs_ref2);

         // change the value of the property toto

         cs2.check();

-	    

+        

         instance1.start();

         

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

@@ -215,6 +220,11 @@
         assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);

         

         fooProvider2.start();

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

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

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

+        // change the value of the property toto

+        cs2.check();

         

         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

@@ -242,8 +252,8 @@
         getContext().ungetService(cs_ref);

         getContext().ungetService(cs_ref2);      

     }

-	

-	public void testMultipleNotMatchInstance() {

+    

+    public void testMultipleNotMatchInstance() {

         instance3.start();

         

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

@@ -405,7 +415,7 @@
         getContext().ungetService(cs_ref);

         getContext().ungetService(cs_ref2);        

     }

-	

+    

     public void testMultipleNotMatchInstanceWithoutFilter() {

         instance2.start();

         

diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java
index 61bba51..3427003 100644
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java
+++ b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalMultipleFilterDependencies.java
@@ -30,27 +30,27 @@
 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("instance.name","FooProvider1");

-			fooProvider1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

-			fooProvider1.stop();

-			

-			prov = new Properties();

+    

+    ComponentInstance instance1, instance2, instance3;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

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

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

+            fooProvider1.stop();

+            

+            prov = new Properties();

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

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

             fooProvider2.stop();

-		

-			Properties i1 = new Properties();

-			i1.put("instance.name","Subscriber1");

-			instance1 = Utils.getFactoryByName(getContext(), "OptionalMultipleFilterCheckServiceSubscriber").createComponentInstance(i1);

-			

-			Properties i2 = new Properties();

+        

+            Properties i1 = new Properties();

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

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

+            

+            Properties i2 = new Properties();

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

             Properties ii2 = new Properties();

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

@@ -63,55 +63,55 @@
             ii3.put("id1", "(toto=A)");

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

             instance3 = Utils.getFactoryByName(getContext(), "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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

-		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

-		ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());

+        

+        } 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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

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

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

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

         assertNotNull("Check CheckService availability", cs_instance_ref);

         CheckService cs_instance = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

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

+        fooProvider1.start();

+        

+        id = ((Architecture) getContext().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(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());

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

-		CheckService cs = (CheckService) getContext().getService(cs_ref);

-		// change the value of the property toto

-		cs.check();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+        

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

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

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

+        // change the value of the property toto

+        cs.check();

+        

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

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

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

         assertNotNull("Check CheckService availability", cs_instance_ref);

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

         

         fooProvider2.start();

+        

         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

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

@@ -146,27 +147,33 @@
         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) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

+        fooProvider2.stop();

+        

+        id = ((Architecture) getContext().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();  

+        

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

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

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

+        // change the value of the property toto

+        cs2.check();

+        

+        id = ((Architecture) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) getContext().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;

@@ -175,14 +182,14 @@
         getContext().ungetService(arch_ref);

         getContext().ungetService(cs_ref);

         getContext().ungetService(cs_ref2);		

-	}

-	

-	public void testMultipleMatch() {

-	    

-	    fooProvider1.start();

-	    fooProvider2.start();

-	    

-	    ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());

+    }

+    

+    public void testMultipleMatch() {

+        

+        fooProvider1.start();

+        fooProvider2.start();

+        

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

         assertNotNull("Check CheckService availability", cs_ref);

         CheckService cs = (CheckService) getContext().getService(cs_ref);

         // change the value of the property toto

@@ -193,7 +200,7 @@
         CheckService cs2 = (CheckService) getContext().getService(cs_ref2);

         // change the value of the property toto

         cs2.check();

-	    

+        

         instance1.start();

         

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

@@ -227,6 +234,12 @@
         

         fooProvider2.start();

         

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

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

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

+        // change the value of the property toto

+        cs2.check();

+        

         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

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

@@ -250,8 +263,8 @@
         getContext().ungetService(cs_ref);

         getContext().ungetService(cs_ref2);      

     }

-	

-	public void testMultipleNotMatchInstance() {

+    

+    public void testMultipleNotMatchInstance() {

         instance3.start();

         

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

@@ -419,7 +432,7 @@
         getContext().ungetService(cs_ref);

         getContext().ungetService(cs_ref2);        

     }

-	

+    

     public void testMultipleNotMatchInstanceWithoutFilter() {

         instance2.start();

         

diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java
index 628dbef..fb13882 100644
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java
+++ b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/OptionalSimpleFilterDependencies.java
@@ -30,27 +30,27 @@
 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("instance.name","FooProvider1");

-			fooProvider1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

-			fooProvider1.stop();

-			

-			prov = new Properties();

+    

+    ComponentInstance instance1, instance2, instance3;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

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

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

+            fooProvider1.stop();

+            

+            prov = new Properties();

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

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

             fooProvider2.stop();

-		

-			Properties i1 = new Properties();

-			i1.put("instance.name","Subscriber1");

-			instance1 = Utils.getFactoryByName(getContext(), "OptionalSimpleFilterCheckServiceSubscriber").createComponentInstance(i1);

-			

-			Properties i2 = new Properties();

+        

+            Properties i1 = new Properties();

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

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

+            

+            Properties i2 = new Properties();

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

             Properties ii2 = new Properties();

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

@@ -63,57 +63,57 @@
             ii3.put("id1", "(toto=A)");

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

             instance3 = Utils.getFactoryByName(getContext(), "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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

-		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

-		ServiceReference cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());

+        

+        } 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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

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

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

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

         assertNotNull("Check CheckService availability", cs_instance_ref);

         CheckService cs_instance = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

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

+        fooProvider1.start();

+        

+        id = ((Architecture) getContext().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(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());

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

-		CheckService cs = (CheckService) getContext().getService(cs_ref);

-		// change the value of the property toto

-		cs.check();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+        

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

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

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

+        // change the value of the property toto

+        cs.check();

+        

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

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

-		

+        

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

         assertNotNull("Check CheckService availability", cs_instance_ref);

         cs_instance = (CheckService) getContext().getService(cs_instance_ref);

@@ -140,49 +140,62 @@
         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) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

-		

-		cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());

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

-		cs_instance = (CheckService) getContext().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) getContext().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;

-		getContext().ungetService(cs_instance_ref);

-		getContext().ungetService(arch_ref);

-		getContext().ungetService(cs_ref);		

-	}

-	

-	public void testSimpleMatch() {

-	    

-	    fooProvider1.start();

-	    

-	    ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());

+        fooProvider1.stop();

+        

+        id = ((Architecture) getContext().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(); // Registered with toto = A

+        

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

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

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

+

+        

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

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

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

+        // change the value of the property toto

+        cs.check(); // Update toto to B

+        

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

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

+        

+        

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

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

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

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

+        assertTrue("Check service Binding - 7.1 (" + (Integer)cs_instance.getProps().get("Bind") +")", ((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) getContext().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;

+        getContext().ungetService(cs_instance_ref);

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+    }

+    

+    public void testSimpleMatch() {

+        

+        fooProvider1.start();

+        

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

         assertNotNull("Check CheckService availability", cs_ref);

         CheckService cs = (CheckService) getContext().getService(cs_ref);

         // change the value of the property toto

         cs.check();

-	    

+        

         instance1.start();

         

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

@@ -224,8 +237,15 @@
         

         fooProvider1.start();

         

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

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

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

+        // change the value of the property toto

+        cs.check(); // Update toto to B

+        

         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

+        assertTrue("Check instance validity - 5.1", 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());

@@ -245,8 +265,8 @@
         getContext().ungetService(arch_ref);

         getContext().ungetService(cs_ref);       

     }

-	

-	public void testSimpleNotMatchInstance() {

+    

+    public void testSimpleNotMatchInstance() {

         instance3.start();

         

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

@@ -400,7 +420,7 @@
         getContext().ungetService(arch_ref);

         getContext().ungetService(cs_ref);       

     }

-	

+    

     public void testSimpleNotMatchInstanceWithoutFilter() {

         instance2.start();

         

diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java
index 409e279..ebc147b 100644
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java
+++ b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/SimpleFilterDependencies.java
@@ -30,27 +30,27 @@
 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("instance.name","FooProvider1");

-			fooProvider1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceProvider").createComponentInstance(prov);

-			fooProvider1.stop();

-			

-			prov = new Properties();

+    

+    ComponentInstance instance1, instance2, instance3;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

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

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

+            fooProvider1.stop();

+            

+            prov = new Properties();

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

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

             fooProvider2.stop();

-		

-			Properties i1 = new Properties();

-			i1.put("instance.name","Subscriber1");

-			instance1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceSubscriber").createComponentInstance(i1);

-			

-			Properties i2 = new Properties();

+        

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "SimpleFilterCheckServiceSubscriber").createComponentInstance(i1);

+            

+            Properties i2 = new Properties();

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

             Properties ii2 = new Properties();

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

@@ -63,48 +63,48 @@
             ii3.put("id1", "(toto=A)");

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

             instance3 = Utils.getFactoryByName(getContext(), "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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

-		InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

-		

-		fooProvider1.start();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

-		

-		ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());

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

-		CheckService cs = (CheckService) getContext().getService(cs_ref);

-		// change the value of the property toto

-		cs.check();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+        

+        } 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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

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

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

+        

+        fooProvider1.start();

+        

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

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

+        

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

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

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

+        // change the value of the property toto

+        cs.check();

+        

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

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

-		

+        

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

         assertNotNull("Check CheckService availability", cs_instance_ref);

         CheckService cs_instance = (CheckService) getContext().getService(cs_instance_ref);

@@ -127,44 +127,52 @@
         cs_instance = (CheckService) getContext().getService(cs_instance_ref);

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

         

-		fooProvider1.stop();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

-		

-		fooProvider1.start();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

-		

-		cs_instance_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());

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

-		cs_instance = (CheckService) getContext().getService(cs_instance_ref);

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

-		

-		fooProvider1.stop();

-		

-		id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

-		

-		id = null;

-		cs = null;

-		cs_instance = null;

-		getContext().ungetService(cs_instance_ref);

-		getContext().ungetService(arch_ref);

-		getContext().ungetService(cs_ref);		

-	}

-	

-	public void testSimpleMatch() {

-	    

-	    fooProvider1.start();

-	    

-	    ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), fooProvider1.getInstanceName());

+        fooProvider1.stop();

+        

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

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

+        

+        fooProvider1.start();

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

+

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

+        

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

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

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

+        cs.check();

+        

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

+

+        

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

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

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        cs_instance = null;

+        getContext().ungetService(cs_instance_ref);

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+    }

+    

+    public void testSimpleMatch() {

+        

+        fooProvider1.start();

+        

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

         assertNotNull("Check CheckService availability", cs_ref);

         CheckService cs = (CheckService) getContext().getService(cs_ref);

         // change the value of the property toto

         cs.check();

-	    

+        

         instance1.start();

         

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

@@ -202,7 +210,14 @@
         fooProvider1.start();

         

         id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

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

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

+        

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

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

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

+        cs.check();

+        

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

         

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

         assertNotNull("Check CheckService availability", cs_instance_ref);

@@ -221,8 +236,8 @@
         getContext().ungetService(arch_ref);

         getContext().ungetService(cs_ref);       

     }

-	

-	public void testSimpleNotMatchInstance() {

+    

+    public void testSimpleNotMatchInstance() {

         instance3.start();

         

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

@@ -358,7 +373,7 @@
         getContext().ungetService(arch_ref);

         getContext().ungetService(cs_ref);       

     }

-	

+    

     public void testSimpleNotMatchInstanceWithoutFilter() {

         instance2.start();

         

diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java
index 2a81c23..af7cc7a 100644
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java
+++ b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckProvider.java
@@ -31,7 +31,7 @@
     

     private int unbind;

     

-    public FilterCheckProvider(){

+    public FilterCheckProvider() {

         m_toto = "A";

     }

     

diff --git a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java
index cfd1be8..5d1bc0d 100644
--- a/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java
+++ b/ipojo/tests/core/service-dependency-filter/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/filter/component/FilterCheckSubscriber.java
@@ -29,7 +29,7 @@
     

     private FooService m_foo;

     

-    private int binded;

+    private int bound;

     

     public FilterCheckSubscriber(){

     }

@@ -41,16 +41,16 @@
 

     public Properties getProps() {

         Properties props = new Properties();

-        props.put("Bind", new Integer(binded));

+        props.put("Bind", new Integer(bound));

         props.put("Nullable", new Boolean(m_foo instanceof Nullable));

         return props;

     }

     

     private void Bind() {

-        binded++;

+        bound++;

     }

     private void Unbind() {

-        binded--;

+        bound--;

     }

 

 }