Fix issue Felix-801
Dependency callbacks support two new signatures:
- service object, dictionary
- service object, map
Those signatures allow injecting service properties without injecting the service reference.
Update tests checking the correct behavior of the new types of callbacks.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@710054 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
index ad476c6..a27fd69 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
@@ -20,6 +20,10 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
import org.apache.felix.ipojo.util.Callback;
import org.osgi.framework.ServiceReference;
@@ -161,12 +165,14 @@
m_argument = new String[0];
return;
case 1:
+ // The callback receives a ServiceReference
if (clazzes[0].getName().equals(ServiceReference.class.getName())) {
// Callback with a service reference.
m_methodObj = methods[i];
m_argument = new String[] { ServiceReference.class.getName() };
return;
}
+ // The callback receives a Service object
if (clazzes[0].getName().equals(m_dependency.getSpecification().getName())) {
// Callback with the service object.
m_methodObj = methods[i];
@@ -175,12 +181,27 @@
}
break;
case 2:
+ // The callback receives the service object and the service reference
if (clazzes[0].getName().equals(m_dependency.getSpecification().getName()) && clazzes[1].getName().equals(ServiceReference.class.getName())) {
// Callback with two arguments.
m_methodObj = methods[i];
m_argument = new String[] { m_dependency.getSpecification().getName(), ServiceReference.class.getName() };
return;
}
+ // The callback receives the service object and the service properties (in a Map)
+ if (clazzes[0].getName().equals(m_dependency.getSpecification().getName()) && clazzes[1].getName().equals(Map.class.getName())) {
+ // Callback with two arguments.
+ m_methodObj = methods[i];
+ m_argument = new String[] { m_dependency.getSpecification().getName(), Map.class.getName() };
+ return;
+ }
+ // The callback receives the service object and the service properties (in a Dictionary)
+ if (clazzes[0].getName().equals(m_dependency.getSpecification().getName()) && clazzes[1].getName().equals(Dictionary.class.getName())) {
+ // Callback with two arguments.
+ m_methodObj = methods[i];
+ m_argument = new String[] { m_dependency.getSpecification().getName(), Dictionary.class.getName() };
+ return;
+ }
break;
default:
break;
@@ -214,7 +235,13 @@
}
break;
case 2 :
- call(new Object[] {obj, ref});
+ if (m_argument[1].equals(ServiceReference.class.getName())) {
+ call(new Object[] {obj, ref});
+ } else if (m_argument[1].equals(Dictionary.class.getName())) {
+ call(new Object[] {obj, getPropertiesInDictionary(ref)});
+ } else {
+ call(new Object[] {obj, getPropertiesInMap(ref)});
+ }
break;
default :
break;
@@ -222,6 +249,37 @@
}
/**
+ * Creates a {@link Dictionary} containing service properties of the
+ * given service reference.
+ * @param ref the service reference
+ * @return a {@link Dictionary} containing the service properties.
+ */
+ private Dictionary getPropertiesInDictionary(ServiceReference ref) {
+ String[] keys = ref.getPropertyKeys(); // Can't be null
+ Dictionary dict = new Properties();
+ for (int i = 0; i < keys.length; i++) {
+ dict.put(keys[i], ref.getProperty(keys[i]));
+ }
+ return dict;
+ }
+
+ /**
+ * Creates a {@link Map} containing service properties of the
+ * given service reference.
+ * @param ref the service reference
+ * @return a {@link Map} containing the service properties.
+ */
+ private Map getPropertiesInMap(ServiceReference ref) {
+ String[] keys = ref.getPropertyKeys(); // Can't be null
+ Map map = new HashMap();
+ for (int i = 0; i < keys.length; i++) {
+ map.put(keys[i], ref.getProperty(keys[i]));
+ }
+ return map;
+ }
+
+
+ /**
* Call the callback on the given instance with the given argument.
*
* @param instance : the instance on which call the callback
@@ -247,7 +305,13 @@
}
break;
case 2 :
- call(instance, new Object[] {obj, ref});
+ if (m_argument[1].equals(ServiceReference.class.getName())) {
+ call(instance, new Object[] {obj, ref});
+ } else if (m_argument[1].equals(Dictionary.class.getName())) {
+ call(instance, new Object[] {obj, getPropertiesInDictionary(ref)});
+ } else {
+ call(instance, new Object[] {obj, getPropertiesInMap(ref)});
+ }
break;
default :
break;
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
index 56237a3..601238a 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
@@ -22,6 +22,7 @@
import java.util.Comparator;
import java.util.Dictionary;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.Vector;
@@ -197,9 +198,11 @@
}
} else if (mets[0].getMethodArguments().length == 2) {
// The callback receives service object, service reference. Check that the second argument is a service reference
- if (!mets[0].getMethodArguments()[1].equals(ServiceReference.class.getName())) {
+ if (!(mets[0].getMethodArguments()[1].equals(ServiceReference.class.getName()) // callback with (service object, service reference)
+ || mets[0].getMethodArguments()[1].equals(Dictionary.class.getName()) // callback with (service object, service properties in a dictionary)
+ || mets[0].getMethodArguments()[1].equals(Map.class.getName()))) { // callback with (service object, service properties in a map)
String message =
- "The requirement callback " + callbacks[i].getMethodName() + " must have a ServiceReference as the second argument";
+ "The requirement callback " + callbacks[i].getMethodName() + " must have a ServiceReference, a Dictionary or a Map as the second argument";
throw new ConfigurationException(message);
}
setSpecification(dep, mets[0].getMethodArguments()[0], false); // Just warn if a mismatch is discovered.
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
index 72050c3..c1328e6 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckProviderParentClass.java
@@ -18,6 +18,9 @@
*/
package org.apache.felix.ipojo.test.scenarios.component;
+import java.util.Dictionary;
+import java.util.Map;
+
import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
import org.osgi.framework.ServiceReference;
@@ -27,12 +30,23 @@
int objectU = 0;
int refU = 0;
int bothU = 0;
+ int mapU = 0;
+ int dictU = 0;
public void bothUnbind(FooService o, ServiceReference sr) {
if(sr != null && o != null && o instanceof FooService) { bothU++; }
}
+ public void propertiesDictionaryUnbind(FooService o, Dictionary props) {
+ if (props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
+ }
+
+ public void propertiesMapUnbind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
+ }
+
+
public void refUnbind(ServiceReference sr) {
if(sr != null) { refU++; }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
index 5ef4d3f..54af644 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
@@ -18,6 +18,8 @@
*/
package org.apache.felix.ipojo.test.scenarios.component;
+import java.util.Dictionary;
+import java.util.Map;
import java.util.Properties;
import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
@@ -32,6 +34,8 @@
int objectB = 0;
int refB = 0;
int bothB = 0;
+ int mapB = 0;
+ int dictB = 0;
public boolean check() {
return fs.foo();
@@ -47,6 +51,10 @@
props.put("objectU", new Integer(objectU));
props.put("refU", new Integer(refU));
props.put("bothU", new Integer(bothU));
+ props.put("mapB", new Integer(mapB));
+ props.put("dictB", new Integer(dictB));
+ props.put("mapU", new Integer(mapU));
+ props.put("dictU", new Integer(dictU));
if (fs != null) {
props.put("result", new Boolean(fs.foo()));
props.put("boolean", new Boolean(fs.getBoolean()));
@@ -79,5 +87,15 @@
public void bothBind(FooService o, ServiceReference sr) {
if(sr != null && o != null && o instanceof FooService) { bothB++; }
}
+
+ protected void propertiesDictionaryBind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
+ fs = o;
+ }
+
+ protected void propertiesMapBind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
+ fs = o;
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckService.java
index fa429f2..ac465d1 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckService.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CollectionCheckService.java
@@ -19,7 +19,9 @@
package org.apache.felix.ipojo.test.scenarios.component;
import java.util.Collection;
+import java.util.Dictionary;
import java.util.Iterator;
+import java.util.Map;
import java.util.Properties;
import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
@@ -45,6 +47,8 @@
int refU = 0;
int bothU = 0;
+
+ int mapB, mapU, dictB, dictU;
public boolean check() {
boolean r = fs.size() != 0;
@@ -109,6 +113,11 @@
props.put("objectU", new Integer(objectU));
props.put("refU", new Integer(refU));
props.put("bothU", new Integer(bothU));
+ props.put("mapB", new Integer(mapB));
+ props.put("mapU", new Integer(mapU));
+ props.put("dictB", new Integer(dictB));
+ props.put("dictU", new Integer(dictU));
+
props.put("boolean", new Boolean(getBoolean()));
props.put("int", new Integer(getInt()));
props.put("long", new Long(getLong()));
@@ -160,5 +169,19 @@
bothU++;
}
}
+
+ protected void propertiesMapBind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
+ }
+ protected void propertiesMapUnbind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
+ }
+
+ protected void propertiesDictionaryBind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
+ }
+ protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DynCheckServiceProvider.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DynCheckServiceProvider.java
index 151b6dd..d4d5b1d 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DynCheckServiceProvider.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/DynCheckServiceProvider.java
@@ -18,6 +18,8 @@
*/
package org.apache.felix.ipojo.test.scenarios.component;
+import java.util.Dictionary;
+import java.util.Map;
import java.util.Properties;
import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
@@ -32,6 +34,7 @@
int objectB = 0;
int refB = 0;
int bothB = 0;
+ int mapB, mapU, dictB, dictU;
public boolean check() {
return fs.foo();
@@ -47,6 +50,11 @@
props.put("objectU", new Integer(objectU));
props.put("refU", new Integer(refU));
props.put("bothU", new Integer(bothU));
+ props.put("mapB", new Integer(mapB));
+ props.put("mapU", new Integer(mapU));
+ props.put("dictB", new Integer(dictB));
+ props.put("dictU", new Integer(dictU));
+
if (fs != null) {
props.put("int", new Integer(fs.getInt()));
if(fs.getObject() != null) { props.put("object", fs.getObject()); }
@@ -75,5 +83,15 @@
public void bothBind(FooService o, ServiceReference sr) {
if(sr != null && o != null && o instanceof FooService) { bothB++; }
}
+
+ protected void propertiesMapBind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
+ }
+
+
+ protected void propertiesDictionaryBind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
+ }
+
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java
index 52d9f5f..52bccb7 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java
@@ -18,7 +18,9 @@
*/
package org.apache.felix.ipojo.test.scenarios.component;
+import java.util.Dictionary;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
@@ -44,6 +46,9 @@
int refU = 0;
int bothU = 0;
+
+ int mapB, mapU, dictB, dictU;
+
public boolean check() {
boolean r = fs.size() != 0;
@@ -104,6 +109,12 @@
props.put("objectU", new Integer(objectU));
props.put("refU", new Integer(refU));
props.put("bothU", new Integer(bothU));
+
+ props.put("mapB", new Integer(mapB));
+ props.put("mapU", new Integer(mapU));
+ props.put("dictB", new Integer(dictB));
+ props.put("dictU", new Integer(dictU));
+
props.put("boolean", new Boolean(getBoolean()));
props.put("int", new Integer(getInt()));
props.put("long", new Long(getLong()));
@@ -155,5 +166,19 @@
bothU++;
}
}
+
+ protected void propertiesMapBind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
+ }
+ protected void propertiesMapUnbind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
+ }
+
+ protected void propertiesDictionaryBind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
+ }
+ protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodCheckServiceProvider.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodCheckServiceProvider.java
index d48e0c7..d9c04a0 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodCheckServiceProvider.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodCheckServiceProvider.java
@@ -18,13 +18,14 @@
*/
package org.apache.felix.ipojo.test.scenarios.component;
+import java.util.Dictionary;
+import java.util.Map;
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;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
public class MethodCheckServiceProvider implements CheckService {
@@ -36,10 +37,14 @@
int objectB = 0;
int refB = 0;
int bothB = 0;
+ int mapB = 0;
+ int dictB = 0;
int simpleU = 0;
int objectU = 0;
int refU = 0;
int bothU = 0;
+ int mapU = 0;
+ int dictU = 0;
public MethodCheckServiceProvider(BundleContext bc) {
@@ -65,10 +70,14 @@
props.put("objectB", new Integer(objectB));
props.put("refB", new Integer(refB));
props.put("bothB", new Integer(bothB));
+ props.put("mapB", new Integer(mapB));
+ props.put("dictB", new Integer(dictB));
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("mapU", new Integer(mapU));
+ props.put("dictU", new Integer(dictU));
if(fs != null) {
if(fs.getObject() != null) { props.put("object", fs.getObject()); }
@@ -104,4 +113,22 @@
if(ref != null && o != null && o instanceof FooService) { bothU++; }
fs = null;
}
+
+ protected void propertiesMapBind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
+ fs = o;
+ }
+ protected void propertiesMapUnbind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
+ fs = null;
+ }
+
+ protected void propertiesDictionaryBind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
+ fs = o;
+ }
+ protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
+ fs = null;
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodMultipleCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodMultipleCheckService.java
index 18ffacc..74115c0 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodMultipleCheckService.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MethodMultipleCheckService.java
@@ -19,7 +19,9 @@
package org.apache.felix.ipojo.test.scenarios.component;
import java.util.ArrayList;
+import java.util.Dictionary;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.osgi.framework.BundleContext;
@@ -49,6 +51,10 @@
int bothU = 0;
+ int mapB = 0;
+ int mapU = 0;
+ int dictB = 0, dictU=0;
+
public MethodMultipleCheckService(BundleContext bc) {
context = bc;
}
@@ -110,6 +116,10 @@
props.put("objectU", new Integer(objectU));
props.put("refU", new Integer(refU));
props.put("bothU", new Integer(bothU));
+ props.put("mapU", new Integer(mapU));
+ props.put("mapB", new Integer(mapB));
+ props.put("dictU", new Integer(dictU));
+ props.put("dictB", new Integer(dictB));
props.put("boolean", new Boolean(getBoolean()));
props.put("int", new Integer(getInt()));
props.put("long", new Long(getLong()));
@@ -150,5 +160,23 @@
bothU++;
}
}
+
+ protected void propertiesMapBind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
+ fs.add(o);
+ }
+ protected void propertiesMapUnbind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
+ fs.remove(o);
+ }
+
+ protected void propertiesDictionaryBind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
+ fs.add(o);
+ }
+ protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
+ fs.remove(o);
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java
index ca8c966..7c64936 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckService.java
@@ -18,6 +18,8 @@
*/
package org.apache.felix.ipojo.test.scenarios.component;
+import java.util.Dictionary;
+import java.util.Map;
import java.util.Properties;
import org.osgi.framework.ServiceReference;
@@ -44,6 +46,9 @@
int refU = 0;
int bothU = 0;
+
+ int mapB, mapU, dictB, dictU;
+
public boolean check() {
boolean r = fs.length != 0;
@@ -108,6 +113,11 @@
props.put("int", new Integer(getInt()));
props.put("long", new Long(getLong()));
props.put("double", new Double(getDouble()));
+
+ props.put("mapB", new Integer(mapB));
+ props.put("mapU", new Integer(mapU));
+ props.put("dictB", new Integer(dictB));
+ props.put("dictU", new Integer(dictU));
return props;
}
@@ -155,5 +165,20 @@
bothU++;
}
}
+
+ protected void propertiesMapBind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapB++; }
+ }
+ protected void propertiesMapUnbind(FooService o, Map props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { mapU++; }
+ }
+
+ protected void propertiesDictionaryBind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictB++; }
+ }
+ protected void propertiesDictionaryUnbind(FooService o, Dictionary props) {
+ if(props != null && o != null && o instanceof FooService && props.size() > 0) { dictU++; }
+ }
+
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedMultipleDependencies.java
index 31b4965..1f9e102 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedMultipleDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedMultipleDependencies.java
@@ -31,7 +31,7 @@
public class DelayedMultipleDependencies extends OSGiTestCase {
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider1, fooProvider2;
public void setUp() {
@@ -57,9 +57,19 @@
instance4.stop();
Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = Utils.getFactoryByName(context, "BothMultipleCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
+ i5.put("instance.name","Both");
+ instance5 = Utils.getFactoryByName(context, "BothMultipleCheckServiceProvider").createComponentInstance(i5);
+ instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MapMultipleCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dict");
+ instance7 = Utils.getFactoryByName(context, "DictMultipleCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
Properties prov = new Properties();
prov.put("instance.name","FooProvider1");
@@ -77,6 +87,8 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider1.dispose();
fooProvider2.dispose();
instance1 = null;
@@ -84,6 +96,8 @@
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider1 = null;
fooProvider2 = null;
}
@@ -330,6 +344,11 @@
assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 2);
assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+
assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
@@ -349,6 +368,10 @@
assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);
assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
@@ -364,6 +387,132 @@
instance5.stop();
context.ungetService(cs_ref);
}
+
+ public void testMap() {
+ instance6.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance6.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()); // True, a provider is here
+ 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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+
+ assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
+ assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
+
+ fooProvider1.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
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ 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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 1);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
+ assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
+ assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ instance6.stop();
+ context.ungetService(cs_ref);
+ }
+
+ public void testDict() {
+ instance7.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance7.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()); // True, a provider is here
+ 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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+
+ assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
+ assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0, 0);
+
+ fooProvider1.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
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ 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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 1);
+ assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
+ assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
+ assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0, 0);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ instance7.stop();
+ context.ungetService(cs_ref);
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalDependencies.java
index 78c9521..caebfe7 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedOptionalDependencies.java
@@ -31,7 +31,7 @@
public class DelayedOptionalDependencies extends OSGiTestCase {
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider;
@@ -65,6 +65,16 @@
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "BothOptionalCheckServiceProvider").createComponentInstance(i5);
instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MapOptionalCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dict");
+ instance7 = Utils.getFactoryByName(context, "DictOptionalCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
} catch (Exception e) {
fail(e.getMessage());
}
@@ -77,12 +87,16 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider.dispose();
instance1 = null;
instance2 = null;
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider = null;
}
@@ -323,6 +337,10 @@
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);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
fooProvider.stop();
@@ -342,13 +360,133 @@
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(), 1);
assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
+ assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
id = null;
cs = null;
context.ungetService(arch_ref);
context.ungetService(cs_ref);
- instance4.stop();
+ instance5.stop();
+ }
+
+ public void testMap() {
+ instance6.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.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(), instance6.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(), 0);
+ assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+
+ fooProvider.stop();
+
+ 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);
+ assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 1);
+ assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+
+ instance6.stop();
+ }
+
+ public void testDict() {
+ instance7.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.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(), instance7.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(), 0);
+ assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+
+ fooProvider.stop();
+
+ 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);
+ assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 1);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+
+ instance7.stop();
}
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedSimpleDependencies.java
index d26bb5c..a0b4ff0 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedSimpleDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DelayedSimpleDependencies.java
@@ -29,7 +29,7 @@
import org.osgi.framework.ServiceReference;
public class DelayedSimpleDependencies extends OSGiTestCase {
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider;
@@ -63,6 +63,16 @@
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "BothCheckServiceProvider").createComponentInstance(i5);
instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MapCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dict");
+ instance7 = Utils.getFactoryByName(context, "DictCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
} catch(Exception e) { fail(e.getMessage()); }
}
@@ -73,6 +83,9 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider.dispose();
instance1 = null;
instance2 = null;
@@ -80,6 +93,8 @@
instance4 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider = null;
}
@@ -245,6 +260,11 @@
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);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
+
fooProvider.stop();
id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
@@ -257,5 +277,88 @@
instance5.stop();
}
+
+ public void testMap() {
+ instance6.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance6.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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);
+
+ instance6.stop();
+ }
+ public void testDict() {
+ instance7.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance7.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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);
+
+ instance7.stop();
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
index 60e079f..3db7ccc 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
@@ -117,6 +117,7 @@
// Check dependency metadata
assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
+ assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());
assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
@@ -207,6 +208,7 @@
// Check dependency metadata
assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
+ assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), "FooService");
assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());
assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedMultipleDependencies.java
index da71ba9..5997dac 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedMultipleDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedMultipleDependencies.java
@@ -30,7 +30,7 @@
public class MethodDelayedMultipleDependencies extends OSGiTestCase {
- ComponentInstance instance3, instance4, instance5;
+ ComponentInstance instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider1, fooProvider2;
public void setUp() {
@@ -50,6 +50,16 @@
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "MBothMultipleCheckServiceProvider").createComponentInstance(i5);
instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MMapMultipleCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dict");
+ instance7 = Utils.getFactoryByName(context, "MDictMultipleCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
Properties prov = new Properties();
prov.put("instance.name","FooProvider1");
@@ -65,11 +75,15 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider1.dispose();
fooProvider2.dispose();
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider1 = null;
fooProvider2 = null;
}
@@ -205,6 +219,10 @@
assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
assertEquals("check both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 2);
assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0);
@@ -224,6 +242,10 @@
assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);
assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);
+ assertEquals("check map bind callback invocation - 3", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 3", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 3", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 3", ((Integer)props.get("dictU")).intValue(), 0);
assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
@@ -239,6 +261,130 @@
instance5.stop();
context.ungetService(cs_ref);
}
+
+ public void testMap() {
+ instance6.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance6.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()); // True, a provider is here
+ 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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
+ assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0);
+
+ fooProvider1.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
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ 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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 3", ((Integer)props.get("mapB")).intValue(), 2);
+ assertEquals("check map unbind callback invocation - 3", ((Integer)props.get("mapU")).intValue(), 1);
+ assertEquals("check dict bind callback invocation - 3", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 3", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
+ assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
+ assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ instance6.stop();
+ context.ungetService(cs_ref);
+ }
+
+ public void testDict() {
+ instance7.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance7.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()); // True, a provider is here
+ 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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 2);
+ assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 2.0);
+
+ fooProvider1.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
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ 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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 3", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 3", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 3", ((Integer)props.get("dictB")).intValue(), 2);
+ assertEquals("check dict unbind callback invocation - 3", ((Integer)props.get("dictU")).intValue(), 1);
+ assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
+ assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
+ assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ instance7.stop();
+ context.ungetService(cs_ref);
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalDependencies.java
index aa24292..a071c88 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedOptionalDependencies.java
@@ -30,7 +30,7 @@
public class MethodDelayedOptionalDependencies extends OSGiTestCase {
- ComponentInstance instance3, instance4, instance5;
+ ComponentInstance instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider;
@@ -54,6 +54,16 @@
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "MBothOptionalCheckServiceProvider").createComponentInstance(i5);
instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MMapOptionalCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dict");
+ instance7 = Utils.getFactoryByName(context, "MDictOptionalCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
} catch (Exception e) {
fail(e.getMessage());
}
@@ -64,10 +74,14 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider.dispose();
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7= null;
fooProvider = null;
}
@@ -194,6 +208,10 @@
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);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
fooProvider.stop();
@@ -213,13 +231,133 @@
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(), 1);
assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 1);
+ assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
id = null;
cs = null;
context.ungetService(arch_ref);
context.ungetService(cs_ref);
- instance4.stop();
+ instance5.stop();
+ }
+
+ public void testMap() {
+ instance6.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.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(), instance6.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+
+ fooProvider.stop();
+
+ 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);
+ assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 1);
+ assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 0);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+
+ instance6.stop();
+ }
+
+ public void testDict() {
+ instance7.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.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(), instance7.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 0);
+
+ fooProvider.stop();
+
+ 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);
+ assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 1);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+
+ instance7.stop();
}
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedSimpleDependencies.java
index 45a388d..9a3829c 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedSimpleDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodDelayedSimpleDependencies.java
@@ -30,7 +30,7 @@
public class MethodDelayedSimpleDependencies extends OSGiTestCase {
- ComponentInstance instance3, instance4, instance5;
+ ComponentInstance instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider;
@@ -54,6 +54,16 @@
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "MBothCheckServiceProvider").createComponentInstance(i5);
instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MMapCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dictionary");
+ instance7 = Utils.getFactoryByName(context, "MDictCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
} catch(Exception e) { fail(e.getMessage()); }
}
@@ -62,10 +72,14 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider.dispose();
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider = null;
}
@@ -176,7 +190,90 @@
context.ungetService(arch_ref);
context.ungetService(cs_ref);
- instance4.stop();
+ instance5.stop();
}
+
+ public void testMap() {
+ instance6.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance6.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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);
+
+ instance6.stop();
+ }
+
+ public void testDict() {
+ instance7.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance7.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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);
+
+ instance7.stop();
+}
+
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodMultipleDependencies.java
index 9a15f11..93aaef5 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodMultipleDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodMultipleDependencies.java
@@ -30,7 +30,7 @@
public class MethodMultipleDependencies extends OSGiTestCase {
- ComponentInstance instance3, instance4, instance5;
+ ComponentInstance instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider1, fooProvider2;
public void setUp() {
@@ -56,6 +56,14 @@
Properties i5 = new Properties();
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "MBothMultipleCheckServiceProvider").createComponentInstance(i5);
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MMapMultipleCheckServiceProvider").createComponentInstance(i6);
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dictionary");
+ instance7 = Utils.getFactoryByName(context, "MDictMultipleCheckServiceProvider").createComponentInstance(i7);
} catch(Exception e) { fail(e.getMessage()); }
}
@@ -64,11 +72,15 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider1.dispose();
fooProvider2.dispose();
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider1 = null;
fooProvider2 = null;
}
@@ -248,6 +260,10 @@
assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).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);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
@@ -267,6 +283,10 @@
assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
assertEquals("check both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 2);
assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
@@ -286,6 +306,10 @@
assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
assertEquals("check both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);
assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
@@ -300,6 +324,182 @@
context.ungetService(arch_ref);
context.ungetService(cs_ref);
}
+
+ public void testMap() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
+
+ fooProvider1.start();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance6.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()); // True, a provider is here
+ 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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
+ assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
+ assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
+
+ fooProvider2.start();
+
+ 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
+ assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ 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 both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 2);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
+ assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) context.getService(cs_ref);
+ props = cs.getProps();
+ //Check properties
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ 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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 2);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
+ assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
+ assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ }
+
+ public void testDict() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
+
+ fooProvider1.start();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance7.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()); // True, a provider is here
+ 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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
+ assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
+ assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);
+
+ fooProvider2.start();
+
+ 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
+ assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ 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 both bind callback invocation - 2", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 2", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 2);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
+ assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
+ assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) context.getService(cs_ref);
+ props = cs.getProps();
+ //Check properties
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ 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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 2);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
+ assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
+ assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
+ assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalDependencies.java
index f5c6f79..5bc6f10 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalDependencies.java
@@ -30,7 +30,7 @@
public class MethodOptionalDependencies extends OSGiTestCase {
- ComponentInstance instance3, instance4, instance5;
+ ComponentInstance instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider;
@@ -52,6 +52,14 @@
Properties i5 = new Properties();
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "MBothOptionalCheckServiceProvider").createComponentInstance(i5);
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MMapOptionalCheckServiceProvider").createComponentInstance(i6);
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dictionary");
+ instance7 = Utils.getFactoryByName(context, "MDictOptionalCheckServiceProvider").createComponentInstance(i7);
} catch (Exception e) {
fail(e.getMessage());
}
@@ -61,10 +69,14 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider.dispose();
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider = null;
}
@@ -262,5 +274,157 @@
context.ungetService(arch_ref);
context.ungetService(cs_ref);
}
+
+ public void testMap() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.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(), instance6.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);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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
+ assertTrue("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);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).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);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ }
+
+ public void testDict() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.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(), instance7.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);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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
+ assertTrue("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);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).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);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalMultipleDependencies.java
index 29ca739..10c246e 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalMultipleDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodOptionalMultipleDependencies.java
@@ -52,6 +52,7 @@
Properties i4 = new Properties();
i4.put("instance.name","Ref");
instance4 = Utils.getFactoryByName(context, "MRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
+
} catch(Exception e) { fail(e.getMessage()); }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodSimpleDependencies.java
index 395952e..37dcefc 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodSimpleDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/MethodSimpleDependencies.java
@@ -30,7 +30,7 @@
public class MethodSimpleDependencies extends OSGiTestCase {
- ComponentInstance instance3, instance4, instance5;
+ ComponentInstance instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider;
public void setUp() {
@@ -54,6 +54,14 @@
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "MBothCheckServiceProvider").createComponentInstance(i5);
assertNotNull("check instance 5", instance5);
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MMapCheckServiceProvider").createComponentInstance(i6);
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dictionary");
+ instance7 = Utils.getFactoryByName(context, "MDictCheckServiceProvider").createComponentInstance(i7);
} catch(Exception e) { fail(e.getMessage()); }
}
@@ -62,10 +70,14 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
+ instance6.dispose();
+ instance7.dispose();
+ fooProvider.dispose();
+ instance3 = null;
+ instance4 = null;
+ instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider = null;
}
@@ -180,5 +192,88 @@
context.ungetService(arch_ref);
context.ungetService(cs_ref);
}
+
+ public void testMap() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.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(), instance6.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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 testDict() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.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(), instance7.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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);
+ }
+
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalDependencies.java
index d4d2785..7515e5e 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalDependencies.java
@@ -31,7 +31,7 @@
public class OptionalDependencies extends OSGiTestCase {
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider;
public void setUp() {
@@ -60,6 +60,14 @@
Properties i5 = new Properties();
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "BothOptionalCheckServiceProvider").createComponentInstance(i5);
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MapOptionalCheckServiceProvider").createComponentInstance(i6);
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dictionary");
+ instance7 = Utils.getFactoryByName(context, "DictOptionalCheckServiceProvider").createComponentInstance(i7);
} catch(Exception e) { fail(e.getMessage()); }
}
@@ -69,12 +77,16 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider.dispose();
instance1 = null;
instance2 = null;
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider = null;
}
@@ -382,6 +394,154 @@
context.ungetService(arch_ref);
context.ungetService(cs_ref);
}
+
+ public void testMap() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.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(), instance6.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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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
+ assertTrue("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);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).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);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ }
+
+ public void testDict() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.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(), instance7.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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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
+ assertTrue("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);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).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);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalNoNullableDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalNoNullableDependencies.java
index e19a086..e4e3c31a 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalNoNullableDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/OptionalNoNullableDependencies.java
@@ -31,7 +31,7 @@
public class OptionalNoNullableDependencies extends OSGiTestCase {
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
ComponentInstance fooProvider;
public void setUp() {
@@ -60,6 +60,14 @@
Properties i5 = new Properties();
i5.put("instance.name","Both");
instance5 = Utils.getFactoryByName(context, "BothOptionalNoNullableCheckServiceProvider").createComponentInstance(i5);
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(context, "MapOptionalNoNullableCheckServiceProvider").createComponentInstance(i6);
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dictionary");
+ instance7 = Utils.getFactoryByName(context, "DictOptionalNoNullableCheckServiceProvider").createComponentInstance(i7);
} catch(Exception e) {
e.getMessage();
fail(e.getMessage());
@@ -72,12 +80,16 @@
instance3.dispose();
instance4.dispose();
instance5.dispose();
+ instance6.dispose();
+ instance7.dispose();
fooProvider.dispose();
instance1 = null;
instance2 = null;
instance3 = null;
instance4 = null;
instance5 = null;
+ instance6 = null;
+ instance7 = null;
fooProvider = null;
}
@@ -376,6 +388,154 @@
context.ungetService(arch_ref);
context.ungetService(cs_ref);
}
+
+ public void testDict() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.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(), instance7.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(cs_ref);
+ Properties props = cs.getProps();
+ //Check properties
+ assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
+ 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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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
+ assertTrue("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);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).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
+ assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
+ 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);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ }
+
+ public void testMap() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance6.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(), instance6.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) context.getService(cs_ref);
+ Properties props = cs.getProps();
+ //Check properties
+ assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
+ 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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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
+ assertTrue("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);
+ assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).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
+ assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
+ 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);
+ assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
+ assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
+
+ id = null;
+ cs = null;
+ context.ungetService(arch_ref);
+ context.ungetService(cs_ref);
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SimpleDependencies.java
index b800380..aa26400 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SimpleDependencies.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/SimpleDependencies.java
@@ -31,7 +31,7 @@
public class SimpleDependencies extends OSGiTestCase {
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6;
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7, instance8;
ComponentInstance fooProvider;
public void setUp() {
@@ -64,6 +64,14 @@
Properties i6 = new Properties();
i6.put("instance.name","Double");
instance6 = Utils.getFactoryByName(context, "DoubleCheckServiceProvider").createComponentInstance(i6);
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Map");
+ instance7 = Utils.getFactoryByName(context, "MapCheckServiceProvider").createComponentInstance(i7);
+
+ Properties i8 = new Properties();
+ i8.put("instance.name","Dictionary");
+ instance8 = Utils.getFactoryByName(context, "DictCheckServiceProvider").createComponentInstance(i8);
} catch(Exception e) {
e.printStackTrace();
fail(e.getMessage()); }
@@ -77,6 +85,8 @@
instance4.dispose();
instance5.dispose();
instance6.dispose();
+ instance7.dispose();
+ instance8.dispose();
fooProvider.dispose();
instance1 = null;
instance2 = null;
@@ -84,6 +94,8 @@
instance4 = null;
instance5 = null;
instance6 = null;
+ instance7 = null;
+ instance8 = null;
fooProvider = null;
}
@@ -316,5 +328,87 @@
context.ungetService(arch_ref);
context.ungetService(cs_ref);
}
+
+ public void testMap() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance7.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(), instance7.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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 testDict() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance8.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(), instance8.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(), 0);
+ assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
+ assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
+ assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
+ assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
+ assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).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);
+ }
}
diff --git a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
index 6defc2f..13f0dc0 100644
--- a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
@@ -50,6 +50,25 @@
</requires>
<provides />
</component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="MapCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="DictCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
+
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="DoubleCheckServiceProvider" architecture="true">
@@ -89,12 +108,30 @@
</requires>
<provides />
</component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
+ name="MMapCheckServiceProvider" architecture="true">
+ <requires>
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
+ name="MDictCheckServiceProvider" architecture="true">
+ <requires>
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
<!-- Simple & Optional Dependencies -->
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="SimpleOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" />
+ <requires field="fs" optional="true" id="FooService"/>
<provides />
</component>
<component
@@ -168,6 +205,25 @@
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="MapOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="DictOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="BothOptionalNoNullableCheckServiceProvider" architecture="true">
<requires field="fs" optional="true" nullable="false">
<callback type="bind" method="bothBind" />
@@ -175,6 +231,24 @@
</requires>
<provides />
</component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="MapOptionalNoNullableCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true" nullable="false">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="DictOptionalNoNullableCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true" nullable="false">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
@@ -207,6 +281,29 @@
</requires>
<provides />
</component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
+ name="MMapOptionalCheckServiceProvider" architecture="true">
+ <requires
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ optional="true">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
+ name="MDictOptionalCheckServiceProvider" architecture="true">
+ <requires
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ optional="true">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
+
<!-- Simple & Optional Dependencies with default-implementation -->
<component
@@ -256,6 +353,26 @@
</requires>
<provides />
</component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="DIMapOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true"
+ default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="DIDictOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true"
+ default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
@@ -291,6 +408,30 @@
</requires>
<provides />
</component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
+ name="DIMMapOptionalCheckServiceProvider" architecture="true">
+ <requires
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ optional="true"
+ default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MethodCheckServiceProvider"
+ name="DIMDictOptionalCheckServiceProvider" architecture="true">
+ <requires
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"
+ optional="true"
+ default-implementation="org.apache.felix.ipojo.test.scenarios.component.FooServiceDefaultImpl">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
<!-- Multiple Dependencies -->
<component
@@ -336,6 +477,25 @@
<provides />
</component>
<component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="MapMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="DictMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
name="MObjectMultipleCheckServiceProvider" architecture="true">
<requires aggregate="true">
@@ -364,6 +524,24 @@
</requires>
<provides />
</component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
+ name="MMapMultipleCheckServiceProvider" architecture="true">
+ <requires aggregate="true">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
+ name="MDictMultipleCheckServiceProvider" architecture="true">
+ <requires aggregate="true">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
<!-- Multiple & Optional Dependencies -->
<component
@@ -441,7 +619,7 @@
<provides />
</component>
- <!-- Aggregate dependency as Vector -->
+ <!-- Aggregate dependency as Vector -->
<component
classname="org.apache.felix.ipojo.test.scenarios.component.VectorCheckService"
name="SimpleVectorCheckServiceProvider" architecture="true">