You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/04/30 00:25:45 UTC

svn commit: r652169 [6/10] - in /felix/trunk/ipojo/tests: ./ tests.composite.service.import-export/ tests.composite.service.import-export/src/ tests.composite.service.import-export/src/main/ tests.composite.service.import-export/src/main/java/ tests.co...

Propchange: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 29 15:25:39 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Propchange: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/component/A123/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 29 15:25:39 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Propchange: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 29 15:25:39 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Propchange: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 29 15:25:39 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Propchange: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/manipulation/service/A123/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 29 15:25:39 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Propchange: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/java/org/apache/felix/ipojo/test/scenarios/util/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 29 15:25:39 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Propchange: felix/trunk/ipojo/tests/tests.core.manipulation/src/main/resources/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 29 15:25:39 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Propchange: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 29 15:25:39 2008
@@ -0,0 +1,9 @@
+target*
+bin*
+.settings*
+.classpath
+.project
+.checkstyle
+maven-eclipse.xml
+.externalToolBuilders
+

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/pom.xml?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/pom.xml (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/pom.xml Tue Apr 29 15:25:39 2008
@@ -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 (Binding Policy) Test Suite</name>
+	<artifactId>tests.core.service.dependency.bindingpolicy</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.dynamic.priority, org.apache.felix.ipojo.test.scenarios.service.dependency.policies, org.apache.felix.ipojo.test.scenarios.service.dependency.statics, org.apache.felix.ipojo.test.scenarios.util  
+						</Private-Package>
+						<Test-Suite>
+							org.apache.felix.ipojo.test.scenarios.service.dependency.policies.DependencyTestSuite
+						</Test-Suite>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-ipojo-plugin</artifactId>
+				<version>0.7.6-SNAPSHOT</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>ipojo-bundle</goal>
+						</goals>
+						<configuration>
+							<ignoreAnnotations>true</ignoreAnnotations>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.4</source>
+					<target>1.4</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/DynamicPriorityDependencyTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/DynamicPriorityDependencyTestSuite.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/DynamicPriorityDependencyTestSuite.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/DynamicPriorityDependencyTestSuite.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,34 @@
+/* 
+ * 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.dynamic.priority;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class DynamicPriorityDependencyTestSuite {
+
+	public static Test suite(BundleContext bc) {
+		OSGiTestSuite ots = new OSGiTestSuite("Dynamic-Priority Dependency Test Suite", bc);
+		ots.addTestSuite( SimpleDPDependencies.class);
+		return ots;
+	}
+
+}

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/RankedFooProviderType1.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/RankedFooProviderType1.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/RankedFooProviderType1.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/RankedFooProviderType1.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,52 @@
+/* 
+ * 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.dynamic.priority;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+
+public class RankedFooProviderType1 implements FooService {	
+	private int m_grade;
+    
+    
+	public boolean foo() {
+	    m_grade = m_grade + 2;
+		return true;
+	}
+
+	public Properties fooProps() {
+		Properties p = new Properties();
+		p.put("grade", new Integer(m_grade));
+
+		return p;
+	}
+        
+	public boolean getBoolean() { return true; }
+
+	public double getDouble() { return 1.0; }
+
+	public int getInt() { 
+	    return m_grade; }
+
+	public long getLong() { return 1; }
+
+	public Boolean getObject() { return new Boolean(true); }
+	
+}

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/SimpleDPDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/SimpleDPDependencies.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/SimpleDPDependencies.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/dynamic/priority/SimpleDPDependencies.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,157 @@
+/* 
+ * 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.dynamic.priority;
+
+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;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+
+public class SimpleDPDependencies extends OSGiTestCase {
+	
+	ComponentInstance instance1, instance3;
+	ComponentInstance fooProvider;
+    ComponentInstance fooProvider2;
+	
+	public void setUp() {
+		try {
+			Properties prov = new Properties();
+			prov.put("name", "FooProvider-1");
+			prov.put("service.ranking", "1");
+			fooProvider = Utils.getFactoryByName(context, "RankedFooProviderType").createComponentInstance(prov);
+			fooProvider.stop();
+			
+			Properties prov2 = new Properties();
+            prov2.put("name", "FooProvider-2");
+            prov2.put("service.ranking", "0");
+            fooProvider2 = Utils.getFactoryByName(context, "RankedFooProviderType").createComponentInstance(prov2);
+            fooProvider2.stop();
+		
+			Properties i1 = new Properties();
+			i1.put("name", "Simple");
+			instance1 = Utils.getFactoryByName(context, "DPSimpleCheckServiceProvider").createComponentInstance(i1);
+		
+			Properties i3 = new Properties();
+			i3.put("name", "Object");
+			instance3 = Utils.getFactoryByName(context, "DPObjectCheckServiceProvider").createComponentInstance(i3);
+			
+		} catch(Exception e) { 
+		    e.printStackTrace();
+		    fail(e.getMessage()); }
+		
+	}
+	
+	public void tearDown() {
+		instance1.dispose();
+		instance3.dispose();
+		fooProvider.dispose();
+		fooProvider2.dispose();
+		instance1 = null;
+		instance3 = null;
+		fooProvider = null;
+		fooProvider2 = null;
+	}
+	
+	public void testSimple() {
+		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);
+		
+		fooProvider.start();
+		fooProvider2.start();
+		
+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+		assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+		
+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+		assertNotNull("Check CheckService availability", cs_ref);
+		CheckService cs = (CheckService) context.getService(cs_ref);
+		// Check grade
+		Integer grade = (Integer) cs.getProps().get("int");
+		assertEquals("Check first grade", 1, grade.intValue());
+		
+		fooProvider.stop(); // Turn off the best provider.
+		
+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+        
+        cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        // Check grade
+        grade = (Integer) cs.getProps().get("int");
+        assertEquals("Check second grade", 0, grade.intValue());
+        
+		fooProvider.start(); // Turn on the best provider.
+		
+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+        
+        cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        // Check grade
+        grade = (Integer) cs.getProps().get("int");
+        assertEquals("Check third grade", 1, grade.intValue());
+        
+		
+        // Increase the second provider grade.
+        ServiceReference fs_ref = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooProvider2.getInstanceName());
+        assertNotNull("Check foo service (2) reference", fs_ref);
+        FooService fs = (FooService) context.getService(fs_ref);
+        
+        fs.foo(); // Increase the grade (now = 2)
+        
+        cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        // Check grade
+        grade = (Integer) cs.getProps().get("int");
+        assertEquals("Check fourth grade", 2, grade.intValue());
+        
+        // Increase the other provider grade.
+        fs_ref = Utils.getServiceReferenceByName(context, FooService.class.getName(), fooProvider.getInstanceName());
+        assertNotNull("Check foo service (1) reference", fs_ref);
+        fs = (FooService) context.getService(fs_ref);
+        fs.foo(); //(grade = 3)
+        
+        cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        // Check grade
+        grade = (Integer) cs.getProps().get("int");
+        assertEquals("Check fifth grade", 3, grade.intValue());
+        		
+		id = null;
+		cs = null;
+		context.ungetService(arch_ref);
+		context.ungetService(cs_ref);
+		context.ungetService(fs_ref);
+		fooProvider.stop();
+		fooProvider2.stop();
+	}
+}

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

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

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DependencyTestSuite.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DependencyTestSuite.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DependencyTestSuite.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DependencyTestSuite.java Tue Apr 29 15:25:39 2008
@@ -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.policies;
+
+import junit.framework.Test;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.dynamic.priority.DynamicPriorityDependencyTestSuite;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.statics.StaticDependencyTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class DependencyTestSuite {
+
+	public static Test suite(BundleContext bc) {
+		OSGiTestSuite ots = new OSGiTestSuite("Service Dependencies (Binding Policy) Test Suite", bc);
+        ots.addTest(StaticDependencyTestSuite.suite(bc));
+        ots.addTest(DynamicPriorityDependencyTestSuite.suite(bc));
+		return ots;
+	}
+
+}

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DynCheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DynCheckServiceProvider.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DynCheckServiceProvider.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/DynCheckServiceProvider.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,79 @@
+/* 
+ * 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.policies;
+
+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;
+import org.osgi.framework.ServiceReference;
+
+public class DynCheckServiceProvider extends CheckProviderParentClass implements CheckService {
+    
+	FooService fs;
+	
+	int simpleB = 0;
+	int objectB = 0;
+	int refB = 0;
+	int bothB = 0;
+
+	public boolean check() {
+		return fs.foo();
+	}
+
+	public Properties getProps() {
+		Properties props = new Properties();
+		props.put("voidB", new Integer(simpleB));
+		props.put("objectB", new Integer(objectB));
+		props.put("refB", new Integer(refB));
+		props.put("bothB", new Integer(bothB));
+		props.put("voidU", new Integer(simpleU));
+		props.put("objectU", new Integer(objectU));
+		props.put("refU", new Integer(refU));
+		props.put("bothU", new Integer(bothU));
+		if (fs != null) {
+		    props.put("int", new Integer(fs.getInt()));
+		    if(fs.getObject() != null) { props.put("object", fs.getObject()); }
+		}
+        props.put("static", CheckService.foo);
+        props.put("class", CheckService.class.getName());
+		return props;
+	}
+	
+	private void voidBind() {
+		simpleB++;
+	}
+	
+	protected void objectBind(FooService o) {
+	    if (o == null) {
+	        System.err.println("Bind receive null !!! ");
+	        return;
+	    }
+		if(o != null && o instanceof FooService) { objectB++; }
+	}
+	
+	public void refBind(ServiceReference sr) {
+		if(sr != null) { refB++; }
+	}
+	
+    public void bothBind(FooService o, ServiceReference sr) {
+	    if(sr != null && o != null && o instanceof FooService) { bothB++; }
+	}
+
+}

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodCheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodCheckServiceProvider.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodCheckServiceProvider.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodCheckServiceProvider.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,107 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency.policies;
+
+import java.util.Properties;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+
+public class MethodCheckServiceProvider implements CheckService {
+	
+	FooService fs;
+    
+    BundleContext context;
+	
+	int simpleB = 0;
+	int objectB = 0;
+	int refB = 0;
+	int bothB = 0;
+	int simpleU = 0;
+	int objectU = 0;
+	int refU = 0;
+	int bothU = 0;
+	
+    
+    public MethodCheckServiceProvider(BundleContext bc) {
+        context = bc;
+    }
+
+	public boolean check() {
+		return fs.foo();
+	}
+
+	public Properties getProps() {
+		Properties props = new Properties();
+        if(fs != null) {
+            props.put("result", new Boolean(fs.foo()));
+            props.put("boolean", new Boolean(fs.getBoolean()));
+            props.put("int", new Integer(fs.getInt()));
+            props.put("long", new Long(fs.getLong()));
+            props.put("double", new Double(fs.getDouble()));
+        } else {
+            props.put("result", new Boolean(false));
+        }
+		props.put("voidB", new Integer(simpleB));
+		props.put("objectB", new Integer(objectB));
+		props.put("refB", new Integer(refB));
+		props.put("bothB", new Integer(bothB));
+		props.put("voidU", new Integer(simpleU));
+		props.put("objectU", new Integer(objectU));
+		props.put("refU", new Integer(refU));
+		props.put("bothU", new Integer(bothU));
+		
+		if(fs != null) {
+		    if(fs.getObject() != null) { props.put("object", fs.getObject()); }
+        }
+		
+		return props;
+	}
+	
+	protected void objectBind(FooService o) {
+		if(o != null && o instanceof FooService) { objectB++; }
+        fs = o;
+	}
+	protected void objectUnbind(FooService o) {
+		if(o != null && o instanceof FooService) { objectU++; }
+        fs = null;
+	}
+	
+	public void refBind(ServiceReference sr) {
+		if(sr != null) { refB++; }
+        fs = (FooService) context.getService(sr);
+	}
+	public void refUnbind(ServiceReference sr) {
+		if(sr != null) { refU++; }
+        context.ungetService(sr);
+        fs = null;
+	}
+	
+    protected void bothBind(FooService o, ServiceReference ref) {
+	    if(ref != null && o != null && o instanceof FooService) { bothB++; }
+	    fs = o;
+	}	
+    protected void bothUnbind(FooService o, ServiceReference ref) {
+	     if(ref != null && o != null && o instanceof FooService) { bothU++; }
+	     fs = null;
+	}
+}

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodMultipleCheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodMultipleCheckService.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodMultipleCheckService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MethodMultipleCheckService.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,154 @@
+/* 
+ * 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.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+
+public class MethodMultipleCheckService implements CheckService {
+
+	List fs = new ArrayList();
+	BundleContext context;
+
+    int simpleB = 0;
+
+    int objectB = 0;
+
+    int refB = 0;
+
+    int bothB = 0;
+
+    int simpleU = 0;
+
+    int objectU = 0;
+
+    int refU = 0;
+
+    int bothU = 0;
+    
+    public MethodMultipleCheckService(BundleContext bc) {
+        context = bc;
+    }
+
+	public boolean check() {
+            boolean r = fs.size() != 0;
+            for(int i = 0; i < fs.size(); i++) {
+                r = r & ((FooService) fs.get(i)).foo();
+            }
+            return r;
+	}
+	
+	private boolean getBoolean() {
+		return check();
+	}
+	
+	private int getInt() {
+		int r = 0;
+		for(int i = 0; i < fs.size(); i++) {
+			r = r + ((FooService) fs.get(i)).getInt();
+		}
+		return r;
+	}
+	
+	private long getLong() {
+		long r = 0;
+		for(int i = 0; i < fs.size(); i++) {
+			r = r + ((FooService) fs.get(i)).getLong();
+		}
+		return r;
+	}
+	
+	private double getDouble() {
+		double r = 0.0;
+		for(int i = 0; i < fs.size(); i++) {
+			r = r + ((FooService) fs.get(i)).getInt();
+		}
+		return r;
+	}
+	
+	protected Object doNothing(Object o, String s) { return null; }
+	
+//	private Object getObject() {
+//		boolean r = true;
+//		for(int i = 0; i < fs.length; i++) {
+//			r = r && ((Boolean) fs[i].getObject()).booleanValue();
+//		}
+//		return new Boolean(r);
+//	}
+
+	public Properties getProps() {
+		Properties props = new Properties();
+		props.put("result", new Boolean(check()));
+		props.put("voidB", new Integer(simpleB));
+		props.put("objectB", new Integer(objectB));
+		props.put("refB", new Integer(refB));
+        props.put("bothB", new Integer(bothB));
+        props.put("voidU", new Integer(simpleU));
+        props.put("objectU", new Integer(objectU));
+        props.put("refU", new Integer(refU));
+        props.put("bothU", new Integer(bothU));
+		props.put("boolean", new Boolean(getBoolean()));
+		props.put("int", new Integer(getInt()));
+		props.put("long", new Long(getLong()));
+		props.put("double", new Double(getDouble()));
+		
+		return props;
+	}
+	
+	public void objectBind(FooService o) {
+		if(o != null && o instanceof FooService) { objectB++; }
+        fs.add(o);
+	}
+	public void objectUnbind(FooService o) {
+		if(o != null && o instanceof FooService) { objectU++; }
+        fs.remove(o);
+	}
+	
+	public void refBind(ServiceReference sr) {
+		if(sr != null) { refB++; }
+        fs.add(context.getService(sr));
+	}
+	public void refUnbind(ServiceReference sr) {
+		if(sr != null) { refU++; }
+        fs.remove(context.getService(sr));
+        context.ungetService(sr);
+	}
+	
+	public void bothBind(FooService o, ServiceReference sr) {
+        if (o != null && o instanceof FooService && sr != null) {
+            fs.add(o);
+            bothB++;
+        }
+    }
+
+    public void bothUnbind(FooService o, ServiceReference sr) {
+        if (o != null && o instanceof FooService && sr != null) {
+            fs.remove(o);
+            bothU++;
+        }
+    }
+	
+}

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MultipleCheckService.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MultipleCheckService.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MultipleCheckService.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/policies/MultipleCheckService.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,159 @@
+/* 
+ * 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.policies;
+
+import java.util.Properties;
+
+import org.osgi.framework.ServiceReference;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+
+public class MultipleCheckService implements CheckService {
+
+    FooService fs[];
+
+    int simpleB = 0;
+
+    int objectB = 0;
+
+    int refB = 0;
+
+    int bothB = 0;
+
+    int simpleU = 0;
+
+    int objectU = 0;
+
+    int refU = 0;
+
+    int bothU = 0;
+
+    public boolean check() {
+        boolean r = fs.length != 0;
+        for (int i = 0; i < fs.length; i++) {
+            r = r & fs[i].foo();
+        }
+        return r;
+    }
+
+    private boolean getBoolean() {
+        return check();
+    }
+
+    private int getInt() {
+        int r = 0;
+        for (int i = 0; i < fs.length; i++) {
+            r = r + fs[i].getInt();
+        }
+        return r;
+    }
+
+    private long getLong() {
+        long r = 0;
+        for (int i = 0; i < fs.length; i++) {
+            r = r + fs[i].getLong();
+        }
+        return r;
+    }
+
+    private double getDouble() {
+        double r = 0.0;
+        for (int i = 0; i < fs.length; i++) {
+            r = r + fs[i].getInt();
+        }
+        return r;
+    }
+
+    protected Object doNothing(Object o, String s) {
+        return null;
+    }
+
+    // private Object getObject() {
+    // boolean r = true;
+    // for(int i = 0; i < fs.length; i++) {
+    // r = r && ((Boolean) fs[i].getObject()).booleanValue();
+    // }
+    // return new Boolean(r);
+    // }
+
+    public Properties getProps() {
+        Properties props = new Properties();
+        props.put("result", new Boolean(check()));
+        props.put("voidB", new Integer(simpleB));
+        props.put("objectB", new Integer(objectB));
+        props.put("refB", new Integer(refB));
+        props.put("bothB", new Integer(bothB));
+        props.put("voidU", new Integer(simpleU));
+        props.put("objectU", new Integer(objectU));
+        props.put("refU", new Integer(refU));
+        props.put("bothU", new Integer(bothU));
+        props.put("boolean", new Boolean(getBoolean()));
+        props.put("int", new Integer(getInt()));
+        props.put("long", new Long(getLong()));
+        props.put("double", new Double(getDouble()));
+
+        return props;
+    }
+
+    public void voidBind() {
+        simpleB++;
+    }
+
+    public void voidUnbind() {
+        simpleU++;
+    }
+
+    public void objectBind(FooService o) {
+        if (o != null && o instanceof FooService) {
+            objectB++;
+        }
+    }
+
+    public void objectUnbind(FooService o) {
+        if (o != null && o instanceof FooService) {
+            objectU++;
+        }
+    }
+
+    public void refBind(ServiceReference sr) {
+        if (sr != null) {
+            refB++;
+        }
+    }
+
+    public void refUnbind(ServiceReference sr) {
+        if (sr != null) {
+            refU++;
+        }
+    }
+
+    public void bothBind(FooService o, ServiceReference sr) {
+        if (o != null && o instanceof FooService && sr != null) {
+            bothB++;
+        }
+    }
+
+    public void bothUnbind(FooService o, ServiceReference sr) {
+        if (o != null && o instanceof FooService && sr != null) {
+            bothU++;
+        }
+    }
+
+}

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodOptionalDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodOptionalDependencies.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodOptionalDependencies.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodOptionalDependencies.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,267 @@
+/* 
+ * 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.statics;
+
+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 MethodOptionalDependencies extends OSGiTestCase {
+
+    ComponentInstance instance3, instance4, instance5;
+
+    ComponentInstance fooProvider;
+
+    public void setUp() {
+        try {
+            Properties prov = new Properties();
+            prov.put("name", "FooProvider");
+            fooProvider = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov);
+            fooProvider.stop();
+
+            Properties i3 = new Properties();
+            i3.put("name", "Object");
+            instance3 = Utils.getFactoryByName(context, "StaticMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
+
+            Properties i4 = new Properties();
+            i4.put("name", "Ref");
+            instance4 = Utils.getFactoryByName(context, "StaticMRefOptionalCheckServiceProvider").createComponentInstance(i4);
+
+            Properties i5 = new Properties();
+            i5.put("name", "Both");
+            instance5 = Utils.getFactoryByName(context, "StaticMBothOptionalCheckServiceProvider").createComponentInstance(i5);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void tearDown() {
+        instance3.dispose();
+        instance4.dispose();
+        instance5.dispose();
+        fooProvider.dispose();
+        instance3 = null;
+        instance4 = null;
+        instance5 = null;
+        fooProvider = null;
+    }
+
+    public void testObject() {
+
+        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_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+
+        Properties props = cs.getProps();
+
+        // Check properties
+        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.start();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
+
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+    }
+
+    public void testRef() {
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance4.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_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance4.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.start();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
+
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+    }
+    
+    public void testBoth() {
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance5.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_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
+        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.start();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+        assertNotNull("Check CheckService availability", cs_ref);
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
+
+        fooProvider.stop();
+
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
+
+        cs = (CheckService) context.getService(cs_ref);
+        props = cs.getProps();
+        // Check properties
+        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
+
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+    }
+
+}

Added: felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java?rev=652169&view=auto
==============================================================================
--- felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java (added)
+++ felix/trunk/ipojo/tests/tests.core.service.dependency.bindingpolicy/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/statics/MethodSimpleDependencies.java Tue Apr 29 15:25:39 2008
@@ -0,0 +1,185 @@
+/* 
+ * 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.statics;
+
+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 MethodSimpleDependencies extends OSGiTestCase {
+	
+	ComponentInstance instance3, instance4, instance5;
+	ComponentInstance fooProvider;
+	
+	public void setUp() {
+		try {
+			Properties prov = new Properties();
+			prov.put("name", "FooProvider");
+			fooProvider = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov);
+			fooProvider.stop();
+		
+			Properties i3 = new Properties();
+			i3.put("name", "Object");
+			instance3 = Utils.getFactoryByName(context, "StaticMObjectCheckServiceProvider").createComponentInstance(i3);
+            assertNotNull("check instance 3", instance3);
+		
+			Properties i4 = new Properties();
+			i4.put("name", "Ref");
+			instance4 = Utils.getFactoryByName(context, "StaticMRefCheckServiceProvider").createComponentInstance(i4);
+            assertNotNull("check instance 4", instance4);
+            
+            Properties i5 = new Properties();
+            i5.put("name", "Both");
+            instance5 = Utils.getFactoryByName(context, "StaticMBothCheckServiceProvider").createComponentInstance(i5);
+            assertNotNull("check instance 5", instance5);
+		} catch(Exception e) { fail(e.getMessage()); }
+		
+	}
+	
+	public void tearDown() {
+		instance3.dispose();
+		instance4.dispose();
+		instance5.dispose();
+		fooProvider.dispose();
+		instance3 = null;
+		instance4 = null;
+		instance5 = null;
+		fooProvider = null;
+	}
+
+	
+	public void testObject() {
+		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);
+		
+		fooProvider.start();
+		
+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+		assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+		
+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance3.getInstanceName());
+		assertNotNull("Check CheckService availability", cs_ref);
+		CheckService cs = (CheckService) context.getService(cs_ref);
+		Properties props = cs.getProps();
+		//Check properties
+		assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
+		assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
+		assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
+		assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
+		assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
+		assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
+		assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
+		assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+		
+		fooProvider.stop();
+		
+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
+		
+		id = null;
+		cs = null;
+		context.ungetService(arch_ref);
+		context.ungetService(cs_ref);		
+	}
+	
+	public void testRef() {
+		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance4.getInstanceName());
+		assertNotNull("Check architecture availability", arch_ref);
+		InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
+		
+		fooProvider.start();
+		
+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+		assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+		
+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance4.getInstanceName());
+		assertNotNull("Check CheckService availability", cs_ref);
+		CheckService cs = (CheckService) context.getService(cs_ref);
+		Properties props = cs.getProps();
+		//Check properties
+		assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
+		assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
+		assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
+		assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
+		assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
+		assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
+		assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
+		assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
+        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+		
+		fooProvider.stop();
+		
+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+		assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
+		
+		id = null;
+		cs = null;
+		context.ungetService(arch_ref);
+		context.ungetService(cs_ref);
+	}
+	
+	public void testBoth() {
+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check architecture availability", arch_ref);
+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
+        
+        fooProvider.start();
+        
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+        
+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance5.getInstanceName());
+        assertNotNull("Check CheckService availability", cs_ref);
+        CheckService cs = (CheckService) context.getService(cs_ref);
+        Properties props = cs.getProps();
+        //Check properties
+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
+        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
+        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
+        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
+        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
+        assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
+        assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
+        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
+        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+        
+        fooProvider.stop();
+        
+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
+        
+        id = null;
+        cs = null;
+        context.ungetService(arch_ref);
+        context.ungetService(cs_ref);
+    }
+
+}