Adapt the dependency handler test suite to fit the change made for FELIX-2472 [iPOJO] Proxies should throw the OSGi service exception.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@963404 13f79535-47bb-0310-9956-ffa450edef68
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 0cbcafb..c660cb6 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
@@ -58,12 +58,19 @@
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()));
- props.put("int", new Integer(fs.getInt()));
- props.put("long", new Long(fs.getLong()));
- props.put("double", new Double(fs.getDouble()));
- if(fs.getObject() != null) { props.put("object", fs.getObject()); }
+ // If nullable = false and proxy, a runtime exception may be launched here
+ // catch the exception and add this to props.
+ try {
+ props.put("exception", Boolean.FALSE); // Set exception to false for checking.
+ props.put("result", new Boolean(fs.foo()));
+ props.put("boolean", new Boolean(fs.getBoolean()));
+ props.put("int", new Integer(fs.getInt()));
+ props.put("long", new Long(fs.getLong()));
+ props.put("double", new Double(fs.getDouble()));
+ if(fs.getObject() != null) { props.put("object", fs.getObject()); }
+ } catch (RuntimeException e) {
+ props.put("exception", Boolean.TRUE);
+ }
}
props.put("static", CheckService.foo);
props.put("class", CheckService.class.getName());
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 0326527..a2d47f1 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
@@ -105,7 +105,9 @@
Properties props = cs.getProps();
//Check properties
- assertNull("check CheckService invocation - 1 (" + props.get("result") + ")", props.get("result")); // Null no provider
+ // no service, no nullable => runtime exception expected
+ assertTrue("check excepted exception", ((Boolean) props.get("exception")).booleanValue());
+ assertNull("check CheckService invocation - 1 (" + props.get("result") + ")", props.get("result")); // Null
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);
@@ -125,6 +127,8 @@
//Check properties
assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, a provider is there
+ // No exception expected
+ assertFalse("check unexcepted exception", ((Boolean) props.get("exception")).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);