FELIX-3093 reduce the size of the dependency handler test suite
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1450120 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
index 74a43b9..d4a3640 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
@@ -57,10 +57,10 @@
root.setLevel(Level.INFO);
return options(
+ cleanCaches(),
ipojoBundles(),
junitBundles(),
testedBundle(),
- eventadmin(),
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
);
}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalDependencies.java
deleted file mode 100644
index 5a0b82e..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-
-public class TestDelayedOptionalDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("SimpleOptionalCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("VoidOptionalCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("ObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("RefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("BothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name", "Map");
- instance6 = ipojoHelper.getFactory("MapOptionalCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name", "Dict");
- instance7 = ipojoHelper.getFactory("DictOptionalCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- 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;
- }
-
- @Test public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- 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, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is 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 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);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- @Test public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- 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, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
- 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);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- @Test public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- @Test public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- @Test public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- @Test public void testMap() {
- instance6.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
-
- @Test public void testDict() {
- instance7.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalMultipleDependencies.java
deleted file mode 100644
index 5ab7238..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestDelayedOptionalMultipleDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("VoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("ObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("RefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test
- public void testSimple() {
- instance1.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance1.stop();
- }
-
- @Test
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 1);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 2);
- assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance2.stop();
- }
-
- @Test
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("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(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- @Test
- public void testRef() {
- instance4.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("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(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance4.stop();
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalDependencies.java
deleted file mode 100644
index 2ef9fe8..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodDelayedOptionalDependencies extends Common {
-
- ComponentInstance instance3, instance4, instance5, instance6, instance7;
-
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("MObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("MRefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("MBothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name", "Map");
- instance6 = ipojoHelper.getFactory("MMapOptionalCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name", "Dict");
- instance7 = ipojoHelper.getFactory("MDictOptionalCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- @Test public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- @Test public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- @Test public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
- 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- @Test public void testMap() {
- instance6.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
-
- @Test public void testDict() {
- instance7.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalMultipleDependencies.java
deleted file mode 100644
index bf68b66..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodDelayedOptionalMultipleDependencies extends Common {
-
- ComponentInstance instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
-
- @Before
- public void setUp() {
- try {
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("MObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("MRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("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(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", (Boolean) props.get("result")); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- @Test public void testRef() {
- instance4.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("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(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance4.stop();
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalDependencies.java
deleted file mode 100644
index 4a7e733..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalDependencies.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodOptionalDependencies extends Common {
-
- ComponentInstance instance3, instance4, instance5, instance6, instance7;
-
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("MObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("MRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("MBothOptionalCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name", "Map");
- instance6 = ipojoHelper.getFactory("MMapOptionalCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name", "Dictionary");
- instance7 = ipojoHelper.getFactory("MDictOptionalCheckServiceProvider").createComponentInstance(i7);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- @Test public void testObject() {
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-
- Properties props = cs.getProps();
-
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testMap() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testDict() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalMultipleDependencies.java
deleted file mode 100644
index 61571e4..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodOptionalMultipleDependencies extends Common {
-
- ComponentInstance instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("MObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("MRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
-
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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(), 1);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check 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, 0);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- 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 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, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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 ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check 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, 0);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).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, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalDependencies.java
deleted file mode 100644
index 7da97bc..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalDependencies.java
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestOptionalDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
- @Before public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = ipojoHelper.getFactory("SimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = ipojoHelper.getFactory("VoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = ipojoHelper.getFactory("ObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = ipojoHelper.getFactory("RefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = ipojoHelper.getFactory("BothOptionalCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Map");
- instance6 = ipojoHelper.getFactory("MapOptionalCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Dictionary");
- instance7 = ipojoHelper.getFactory("DictOptionalCheckServiceProvider").createComponentInstance(i7);
- } catch(Exception e) { fail(e.getMessage()); }
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- 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;
- }
-
- @Test public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
- assertNull("Check FS invocation (object) - 1 ("+props.get("object")+")", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, a provider is there
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testVoid() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check void unbind callback invocation -3 ("+((Integer)props.get("voidU")) + ")", ((Integer)props.get("voidU")).intValue(), 1);
- 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);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
- assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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() + ")", ((Integer)props.get("objectB")).intValue(), 1);
- 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);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue()); // Nullable object.
- 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(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testMap() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testDict() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalMultipleDependencies.java
deleted file mode 100644
index 8c97078..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestOptionalMultipleDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = ipojoHelper.getFactory("SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = ipojoHelper.getFactory("VoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = ipojoHelper.getFactory("ObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = ipojoHelper.getFactory("RefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- } catch(Exception e) { fail(e.getMessage()); }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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 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 FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one 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 FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
-
- fooProvider2.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testVoid() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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(), 1);
- 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 FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- 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 FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 1);
- 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 FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
-
- fooProvider2.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 2);
- assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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(), 1);
- assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- 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 FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
- 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 FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
-
- fooProvider2.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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 ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).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);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).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);
-
- fooProvider2.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalNoNullableDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalNoNullableDependencies.java
deleted file mode 100644
index c851c9b..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalNoNullableDependencies.java
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestOptionalNoNullableDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("SimpleOptionalNoNullableCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("VoidOptionalNoNullableCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("ObjectOptionalNoNullableCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("RefOptionalNoNullableCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("BothOptionalNoNullableCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name", "Map");
- instance6 = ipojoHelper.getFactory("MapOptionalNoNullableCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name", "Dictionary");
- instance7 = ipojoHelper.getFactory("DictOptionalNoNullableCheckServiceProvider").createComponentInstance(i7);
- } catch (Exception e) {
- e.getMessage();
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- 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;
- }
-
- @Test public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- // 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);
- 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);
- assertNull("Check FS invocation (object) - 1 (" + props.get("object") + ")", props.get("object"));
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
-
- //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);
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testVoid() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -3", props.get("result"));
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -3 (" + ((Integer) props.get("voidU")) + ")", ((Integer) props.get("voidU")).intValue(), 1);
- 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);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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() + ")", ((Integer) props.get("objectB")).intValue(), 1);
- 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);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertNull("check CheckService invocation -3", props.get("result")); // 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(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testDict() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testMap() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedCollectionMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedCollectionMultipleDependencies.java
deleted file mode 100644
index 016e958..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedCollectionMultipleDependencies.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedCollectionMultipleDependencies extends Common {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleCollectionCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Optional");
- instance2 = ipojoHelper.getFactory("ProxiedOptionalCollectionCheckServiceProvider").createComponentInstance(i2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider2.start();
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testOptional() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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 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 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, 0);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedMultipleDependencies.java
deleted file mode 100644
index 2613efa..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedMultipleDependencies.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedDelayedMultipleDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleMultipleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("ProxiedVoidMultipleCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("ProxiedObjectMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("ProxiedRefMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("ProxiedBothMultipleCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name", "Map");
- instance6 = ipojoHelper.getFactory("ProxiedMapMultipleCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name", "Dict");
- instance7 = ipojoHelper.getFactory("ProxiedDictMultipleCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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 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 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);
-
- fooProvider2.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- @Test public void testVoid() {
- instance2.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 1);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance2.stop();
- }
-
- @Test public void testObject() {
- instance3.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- @Test public void testRef() {
- instance4.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance4.stop();
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testBoth() {
- instance5.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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(), 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);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 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);
-
- fooProvider2.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance5.stop();
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testMap() {
- instance6.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance6.stop();
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testDict() {
- instance7.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- instance7.stop();
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalDependencies.java
deleted file mode 100644
index d715aee..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-
-public class TestProxiedDelayedOptionalDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name", "Map");
- instance6 = ipojoHelper.getFactory("ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name", "Dict");
- instance7 = ipojoHelper.getFactory("ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- 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;
- }
-
- @Test public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- 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, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is 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 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);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- @Test public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- 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, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
- 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);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- @Test public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- @Test public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- @Test public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
- 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- @Test public void testMap() {
- instance6.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
-
- @Test public void testDict() {
- instance7.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalMultipleDependencies.java
deleted file mode 100644
index 94d1802..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedDelayedOptionalMultipleDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("ProxiedVoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("ProxiedObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("ProxiedRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test public void testSimple() {
- instance1.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance1.stop();
- }
-
- @Test public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 2);
- assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 1);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 2);
- assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 2);
- assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance2.stop();
- }
-
- @Test public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("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(), 2);
- assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
- 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 2);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance3.stop();
- }
-
- @Test public void testRef() {
- instance4.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("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(), 2);
- assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 2);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance4.stop();
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedSimpleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedSimpleDependencies.java
deleted file mode 100644
index 9698300..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedSimpleDependencies.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedDelayedSimpleDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("ProxiedVoidCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("ProxiedObjectCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("ProxiedRefCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("ProxiedBothCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
-
- Properties i6 = new Properties();
- i6.put("instance.name", "Map");
- instance6 = ipojoHelper.getFactory("ProxiedMapCheckServiceProvider").createComponentInstance(i6);
- instance6.stop();
-
- Properties i7 = new Properties();
- i7.put("instance.name", "Dict");
- instance7 = ipojoHelper.getFactory("ProxiedDictCheckServiceProvider").createComponentInstance(i7);
- instance7.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- fooProvider = null;
- }
-
- @Test public void testSimple() {
- instance1.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
- fooProvider.stop();
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
- fooProvider.start();
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
- fooProvider.stop();
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- instance1.stop();
- }
-
- @Test public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- @Test public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- @Test public void testRef() {
- instance4.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- @Test public void testBoth() {
- instance5.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance5.stop();
- }
-
- @Test public void testMap() {
- instance6.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance6.stop();
- }
-
- @Test public void testDict() {
- instance7.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance7.stop();
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedListMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedListMultipleDependencies.java
deleted file mode 100644
index 7707f57..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedListMultipleDependencies.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedListMultipleDependencies extends Common {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleListCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Optional");
- instance2 = ipojoHelper.getFactory("ProxiedOptionalListCheckServiceProvider").createComponentInstance(i2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider2.start();
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testOptional() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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 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 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, 0);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedOptionalDependencies.java
deleted file mode 100644
index c4603a4..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedOptionalDependencies.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedOptionalDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name", "Map");
- instance6 = ipojoHelper.getFactory("ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name", "Dictionary");
- instance7 = ipojoHelper.getFactory("ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- 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;
- }
-
- @Test public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
- assertNull("Check FS invocation (object) - 1 (" + props.get("object") + ")", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is there
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testVoid() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check void unbind callback invocation -3 (" + ((Integer) props.get("voidU")) + ")", ((Integer) props.get("voidU")).intValue(), 1);
- 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);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
- assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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() + ")", ((Integer) props.get("objectB")).intValue(), 1);
- 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);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue()); // Nullable object.
- 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(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testMap() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testDict() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSetMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSetMultipleDependencies.java
deleted file mode 100644
index cb8ec2c..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSetMultipleDependencies.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedSetMultipleDependencies extends Common {
-
- ComponentInstance instance1, instance2;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleSetCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Optional");
- instance2 = ipojoHelper.getFactory("ProxiedOptionalSetCheckServiceProvider").createComponentInstance(i2);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider2.start();
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testOptional() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
- assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- fooProvider1.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- 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 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 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, 0);
-
- fooProvider2.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(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 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 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, 0);
-
- fooProvider1.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one 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 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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
- assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
- assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSimpleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSimpleDependencies.java
deleted file mode 100644
index 0d5b71f..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSimpleDependencies.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedSimpleDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7, instance8;
- ComponentInstance fooProvider;
-
- @Before public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = ipojoHelper.getFactory("ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Void");
- instance2 = ipojoHelper.getFactory("ProxiedVoidCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Object");
- instance3 = ipojoHelper.getFactory("ProxiedObjectCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","Ref");
- instance4 = ipojoHelper.getFactory("ProxiedRefCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name","Both");
- instance5 = ipojoHelper.getFactory("ProxiedBothCheckServiceProvider").createComponentInstance(i5);
-
- Properties i6 = new Properties();
- i6.put("instance.name","Double");
- instance6 = ipojoHelper.getFactory("ProxiedDoubleCheckServiceProvider").createComponentInstance(i6);
-
- Properties i7 = new Properties();
- i7.put("instance.name","Map");
- instance7 = ipojoHelper.getFactory("ProxiedMapCheckServiceProvider").createComponentInstance(i7);
-
- Properties i8 = new Properties();
- i8.put("instance.name","Dictionary");
- instance8 = ipojoHelper.getFactory("ProxiedDictCheckServiceProvider").createComponentInstance(i8);
- } catch(Exception e) {
- e.printStackTrace();
- fail(e.getMessage()); }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- instance6.dispose();
- instance7.dispose();
- instance8.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- instance6 = null;
- instance7 = null;
- instance8 = null;
- fooProvider = null;
- }
-
- @Test public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testVoid() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- Object o = osgiHelper.getServiceObject(cs_ref);
- CheckService cs = (CheckService) o;
- 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()+")", ((Integer)props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testDouble() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
- assertNotNull("Check cs", cs);
- cs.check();
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testMap() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test public void testDict() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance8.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance8.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(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) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxyTest.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxyTest.java
deleted file mode 100644
index 15c3d2f..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxyTest.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.handlers.dependency.DependencyHandler;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.apache.felix.ipojo.runtime.core.test.services.FooService;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxyTest extends Common {
-
-
- @Test
- public void testDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1-Proxy");
- ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Delegator");
- ComponentInstance instance1 = ipojoHelper.getFactory(
- "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
- ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- }
-
- @Test
- public void testDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties i1 = new Properties();
- i1.put("instance.name", "DelegatorNullable");
- ComponentInstance instance1 = ipojoHelper.getFactory(
- "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
- ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
- assertFalse(cs.check()); // Nullable.
-
- instance1.dispose();
- }
-
-
- @Test
- public void testGetAndDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1-Proxy");
- ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Delegator");
- ComponentInstance instance1 = ipojoHelper.getFactory(
- "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
-
-
- ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- }
-
- @Test
- public void testGetAndDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties i1 = new Properties();
- i1.put("instance.name", "DelegatorNullable");
- ComponentInstance instance1 = ipojoHelper.getFactory(
- "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
-
-
- ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
- assertFalse(cs.check()); // Nullable.
-
-
- instance1.dispose();
- }
-
- @Test
- public void testImmediate() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1-Proxy");
- ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Delegator");
- ComponentInstance instance1 = ipojoHelper.getFactory(
- "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
-
- ServiceReference ref = osgiHelper.getServiceReference(CheckService.class.getName(), "(service.pid=Helper)");
- assertNotNull(ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- }
-
- @Test
- public void testImmediateNoService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Properties i1 = new Properties();
- i1.put("instance.name", "Delegator-with-no-service");
- ComponentInstance instance1 = ipojoHelper.getFactory(
- "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
-
- ServiceReference ref = osgiHelper.getServiceReference(CheckService.class.getName(), "(service.pid=Helper)");
- assertNotNull(ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
- try {
- cs.getProps();
- fail("Exception expected");
- } catch (RuntimeException e) {
- //OK
- }
-
- instance1.dispose();
- }
-
- @Test
- public void testProxyDisabled() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Disable proxy
- System.setProperty(DependencyHandler.PROXY_SETTINGS_PROPERTY, DependencyHandler.PROXY_DISABLED);
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1-Proxy");
- ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Delegator");
- ComponentInstance instance1 = ipojoHelper.getFactory(
- "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
- ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertFalse(helper.toString().contains("$$Proxy")); // Not a proxy.
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- System.setProperty(DependencyHandler.PROXY_SETTINGS_PROPERTY, DependencyHandler.PROXY_ENABLED);
-
- }
-
- @Test
- public void testDynamicProxy() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- // Dynamic proxy
- System.setProperty(DependencyHandler.PROXY_TYPE_PROPERTY, DependencyHandler.DYNAMIC_PROXY);
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1-Proxy");
- ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Delegator");
- ComponentInstance instance1 = ipojoHelper.getFactory(
- "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
- ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull(ref);
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
- Properties props = cs.getProps();
- FooService helper = (FooService) props.get("helper.fs");
- assertNotNull(helper);
- assertFalse(helper.toString().contains("$$Proxy")); // Dynamic proxy.
- assertTrue(helper.toString().contains("DynamicProxyFactory"));
- assertTrue(helper.hashCode() > 0);
-
- assertTrue(helper.equals(helper));
- assertFalse(helper.equals(i1)); // This is a quite stupid test...
-
- assertTrue(cs.check());
-
- fooProvider1.dispose();
- instance1.dispose();
- System.setProperty(DependencyHandler.PROXY_TYPE_PROPERTY, DependencyHandler.SMART_PROXY);
-
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/comparator/TestComparator.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/comparator/TestComparator.java
deleted file mode 100644
index e6611e9..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/comparator/TestComparator.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.apache.felix.ipojo.runtime.core.test.dependencies.comparator;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class TestComparator extends Common {
-
- String gradeFactory = "COMPARATOR-gradedFooProvider";
- String dynamic = "COMPARATOR-DynamicCheckService";
- String dynamicpriority = "COMPARATOR-DynamicPriorityCheckService";
-
-
- ComponentInstance dynInstance;
- ComponentInstance dpInstance;
-
- @Before
- public void setUp() {
- dynInstance = ipojoHelper.createComponentInstance(dynamic, (Properties) null);
- dpInstance = ipojoHelper.createComponentInstance(dynamicpriority, (Properties) null);
- }
-
- @After
- public void tearDown() {
- ipojoHelper.dispose();
- }
-
- @Test
- public void testDynamic() {
- createGrade(1);
- ComponentInstance grade2 = createGrade(2);
-
- ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), dynInstance.getInstanceName());
- assertNotNull("CS availability", ref);
-
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
- Properties result = cs.getProps();
- int fsGrade = ((Integer) result.get("fs")).intValue();
- int fs2Grade = ((Integer) result.get("fs2")).intValue();
- int[] fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -1", 2, fsGrade);
- assertEquals("fs2 grade -1", 2, fs2Grade);
- assertEquals("fss grade size -1", 2, fssGrades.length);
-
-
- assertEquals("fss grade[0] -1", 2, fssGrades[0]);
- assertEquals("fss grade[1] -1", 1, fssGrades[1]);
-
- createGrade(3);
- result = cs.getProps();
- fsGrade = ((Integer) result.get("fs")).intValue();
- fs2Grade = ((Integer) result.get("fs2")).intValue();
- fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -2", 2, fsGrade);
- assertEquals("fs2 grade -2", 2, fs2Grade);
- assertEquals("fss grade size -2", 3, fssGrades.length);
- assertEquals("fss grade[0] -2", 2, fssGrades[0]);
- assertEquals("fss grade[1] -2", 1, fssGrades[1]);
- assertEquals("fss grade[2] -2", 3, fssGrades[2]);
-
- grade2.stop();
-
- result = cs.getProps();
- fsGrade = ((Integer) result.get("fs")).intValue();
- fs2Grade = ((Integer) result.get("fs2")).intValue();
- fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -3", 3, fsGrade);
- assertEquals("fs2 grade -3", 3, fs2Grade);
- assertEquals("fss grade size -3", 2, fssGrades.length);
- assertEquals("fss grade[0] -3", 1, fssGrades[0]);
- assertEquals("fss grade[1] -3", 3, fssGrades[1]);
- }
-
- @Test
- public void testDynamicPriority() {
- createGrade(1);
- ComponentInstance grade2 = createGrade(2);
-
- ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), dpInstance.getInstanceName());
- assertNotNull("CS availability", ref);
-
- CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
- Properties result = cs.getProps();
- int fsGrade = ((Integer) result.get("fs")).intValue();
- int fs2Grade = ((Integer) result.get("fs2")).intValue();
- int[] fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -1", 2, fsGrade);
- assertEquals("fs2 grade -1", 2, fs2Grade);
- assertEquals("fss grade size -1", 2, fssGrades.length);
- assertEquals("fss grade[0] -1", 2, fssGrades[0]);
- assertEquals("fss grade[1] -1", 1, fssGrades[1]);
-
- createGrade(3);
- result = cs.getProps();
- fsGrade = ((Integer) result.get("fs")).intValue();
- fs2Grade = ((Integer) result.get("fs2")).intValue();
- fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -2", 3, fsGrade);
- assertEquals("fs2 grade -2", 3, fs2Grade);
- assertEquals("fss grade size -2", 3, fssGrades.length);
- assertEquals("fss grade[0] -2", 3, fssGrades[0]);
- assertEquals("fss grade[1] -2", 2, fssGrades[1]);
- assertEquals("fss grade[2] -2", 1, fssGrades[2]);
-
- grade2.stop();
-
- result = cs.getProps();
- fsGrade = ((Integer) result.get("fs")).intValue();
- fs2Grade = ((Integer) result.get("fs2")).intValue();
- fssGrades = (int[]) result.get("fss");
-
- assertEquals("fs grade -3", 3, fsGrade);
- assertEquals("fs2 grade -3", 3, fs2Grade);
- assertEquals("fss grade size -3", 2, fssGrades.length);
- assertEquals("fss grade[0] -3", 3, fssGrades[0]);
- assertEquals("fss grade[1] -3", 1, fssGrades[1]);
- }
-
- private ComponentInstance createGrade(int grade) {
- Properties props = new Properties();
- props.put("grade", new Integer(grade));
- return ipojoHelper.createComponentInstance(gradeFactory, props);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestDelayedOptionalDependencies.java
deleted file mode 100644
index 93b6291..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.di;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-public class TestDelayedOptionalDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
-
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("DISimpleOptionalCheckServiceProvider").createComponentInstance(i1);
- instance1.stop();
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("DIVoidOptionalCheckServiceProvider").createComponentInstance(i2);
- instance2.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("DIObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("DIRefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("DIBothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- @Test
- public void testSimple() {
- instance1.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- 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);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is 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 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);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 5.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance1.stop();
- }
-
- @Test
- public void testVoid() {
- instance2.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 1", props.get("object"));
- 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);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
- 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);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 5.0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance2.stop();
- }
-
- @Test
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- @Test
- public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- @Test
- public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodDelayedOptionalDependencies.java
deleted file mode 100644
index 1ced9e9..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.di;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-public class TestMethodDelayedOptionalDependencies extends Common {
-
- ComponentInstance instance3, instance4, instance5;
-
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("DIMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
- instance3.stop();
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("DIMRefOptionalCheckServiceProvider").createComponentInstance(i4);
- instance4.stop();
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("DIMBothOptionalCheckServiceProvider").createComponentInstance(i5);
- instance5.stop();
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- @Test
- public void testObject() {
- instance3.start();
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance3.stop();
- }
-
- @Test
- public void testRef() {
- instance4.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
- @Test
- public void testBoth() {
- instance5.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
-
- instance4.stop();
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodOptionalDependencies.java
deleted file mode 100644
index 7aa8423..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodOptionalDependencies.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.di;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodOptionalDependencies extends Common {
-
- ComponentInstance instance3, instance4, instance5;
-
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("DIMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("DIMRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("DIMBothOptionalCheckServiceProvider").createComponentInstance(i5);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- @Test
- public void testObject() {
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- Properties props = cs.getProps();
-
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestOptionalDependencies.java
deleted file mode 100644
index f68b7b5..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestOptionalDependencies.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.di;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestOptionalDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("DISimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("DIVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("DIObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("DIRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("DIBothOptionalCheckServiceProvider").createComponentInstance(i5);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- @Test
- public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 5.0, 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is there
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testVoid() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 5.0, 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check void unbind callback invocation -3 (" + ((Integer) props.get("voidU")) + ")", ((Integer) props.get("voidU")).intValue(), 1);
- 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);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
- assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 5);
- assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 5);
- assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 5.0, 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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() + ")", ((Integer) props.get("objectB")).intValue(), 1);
- 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);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
- 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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/optional/TestNullableTransitiveClassloading.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/optional/TestNullableTransitiveClassloading.java
deleted file mode 100644
index bb1d1a0..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/optional/TestNullableTransitiveClassloading.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.apache.felix.ipojo.runtime.core.test.dependencies.optional;
-
-import org.apache.felix.ipojo.*;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.junit.Test;
-
-
-/**
- * Reproduces FELIX-2093
- * iPOJO doesn't always use the correct class loader to load nullable object.
- */
-public class TestNullableTransitiveClassloading extends Common {
-
-
- @Test
- public void testCreation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- Factory factory = ipojoHelper.getFactory("optional-log-cons");
- ComponentInstance ci = factory.createComponentInstance(null);
- ci.dispose();
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestDynamicPriority.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestDynamicPriority.java
deleted file mode 100644
index 3507c68..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestDynamicPriority.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.apache.felix.ipojo.runtime.core.test.services.FooService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-public class TestDynamicPriority extends Common {
-
- ComponentInstance instance1, instance3;
- ComponentInstance fooProvider;
- ComponentInstance fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider-1");
- prov.put("service.ranking", "1");
- fooProvider = ipojoHelper.getFactory("RankedFooProviderType").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider-2");
- prov2.put("service.ranking", "0");
- fooProvider2 = ipojoHelper.getFactory("RankedFooProviderType").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("DPSimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("DPObjectCheckServiceProvider").createComponentInstance(i3);
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance3.dispose();
- fooProvider.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance3 = null;
- fooProvider = null;
- fooProvider2 = null;
- }
-
- @Test
- public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
- fooProvider2.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- Integer grade = (Integer) cs.getProps().get("int");
- assertEquals("Check first grade", 1, grade.intValue());
-
- fooProvider.stop(); // Turn off the best provider.
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- grade = (Integer) cs.getProps().get("int");
- assertEquals("Check second grade", 0, grade.intValue());
-
- fooProvider.start(); // Turn on the best provider.
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- grade = (Integer) cs.getProps().get("int");
- assertEquals("Check third grade", 1, grade.intValue());
-
-
- // Increase the second provider grade.
- ServiceReference fs_ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check foo service (2) reference", fs_ref);
- FooService fs = (FooService) getContext().getService(fs_ref);
-
- fs.foo(); // Increase the grade (now = 2)
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- grade = (Integer) cs.getProps().get("int");
- assertEquals("Check fourth grade", 2, grade.intValue());
-
- // Increase the other provider grade.
- fs_ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider.getInstanceName());
- assertNotNull("Check foo service (1) reference", fs_ref);
- fs = (FooService) getContext().getService(fs_ref);
- fs.foo(); //(grade = 3)
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- // Check grade
- grade = (Integer) cs.getProps().get("int");
- assertEquals("Check fifth grade", 3, grade.intValue());
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- getContext().ungetService(fs_ref);
- fooProvider.stop();
- fooProvider2.stop();
- }
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodOptionalDependencies.java
deleted file mode 100644
index 6dd432c..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodOptionalDependencies.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestStaticMethodOptionalDependencies extends Common {
-
- ComponentInstance instance3, instance4, instance5;
-
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("StaticMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("StaticMRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("StaticMBothOptionalCheckServiceProvider").createComponentInstance(i5);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- @Test
- public void testObject() {
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
-
- Properties props = cs.getProps();
-
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- // Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodSimpleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodSimpleDependencies.java
deleted file mode 100644
index 1ffc4a1..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodSimpleDependencies.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestStaticMethodSimpleDependencies extends Common {
-
- ComponentInstance instance3, instance4, instance5;
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("StaticMObjectCheckServiceProvider").createComponentInstance(i3);
- assertNotNull("check instance 3", instance3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("StaticMRefCheckServiceProvider").createComponentInstance(i4);
- assertNotNull("check instance 4", instance4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("StaticMBothCheckServiceProvider").createComponentInstance(i5);
- assertNotNull("check instance 5", instance5);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
-
- @Test
- public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMultipleDependencies.java
deleted file mode 100644
index a24591e..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMultipleDependencies.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-public class TestStaticMultipleDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4;
- ComponentInstance fooProvider1, fooProvider2;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider1");
- fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name", "FooProvider2");
- fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("StaticSimpleMultipleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("StaticVoidMultipleCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("StaticObjectMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("StaticRefMultipleCheckServiceProvider").createComponentInstance(i4);
- } catch (Exception e) {
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- fooProvider1.dispose();
- fooProvider2.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- fooProvider1 = null;
- fooProvider2 = null;
- }
-
- @Test
- public void testSimple() {
- instance1.stop();
- fooProvider1.start();
- instance1.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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 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 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();
- ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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 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 FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider1.stop();
- // instance is stopped and then restarted, so bound to fooprovider 2.
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testVoid() {
- instance2.stop();
- fooProvider1.start();
- instance2.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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(), 1);
- 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 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) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- 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 FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider1.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testObject() {
- instance3.stop();
- fooProvider1.start();
- instance3.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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(), 1);
- assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check 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) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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(), 1);
- 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 FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider1.stop();
- // Instance stopped and then restarted, bound to foo provider 2.
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testRef() {
- instance4.stop();
- fooProvider1.start();
- instance4.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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 ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check 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) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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 ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
- assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
- fooProvider1.stop();
- // Stop and then restarted, bound to foo provider 2.
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticOptionalDependencies.java
deleted file mode 100644
index 1ba004d..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticOptionalDependencies.java
+++ /dev/null
@@ -1,521 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestStaticOptionalDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("StaticSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("StaticVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("StaticObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("StaticRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("StaticBothOptionalCheckServiceProvider").createComponentInstance(i5);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- @Test
- public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 0);
-
- fooProvider.start();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
-
- //Check properties
- assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // False, the provider was not bound
- 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);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testDelayedSimple() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- instance1.stop();
- fooProvider.start();
- instance1.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, the provider was bound
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-
- fooProvider.stop();
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID); // Dependency broken,re started with no service.
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testVoid() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
- assertNull("Check FS invocation (object) - 1", props.get("object"));
- assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 0);
-
- fooProvider.start();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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);
- assertNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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")) + ")", ((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);
- assertNull("Check FS invocation (object) - 3", props.get("object"));
- assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 0);
- assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testDelayedVoid() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- instance2.stop();
- fooProvider.start();
- instance2.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, the provider was bound
- assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-
- fooProvider.stop();
- // The instance is restarted.
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3 (" + id.getState() + ")", id.getState() == ComponentInstance.VALID); // Dependency broken and then (no service injected) restarted
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
-
- fooProvider.start();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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() + ")", ((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);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- @Test
- public void testDelayedObject() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
- instance3.stop();
- fooProvider.start();
- instance3.start();
-
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
-
- //Check properties
- assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, the provider was bound
- 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(), 1);
- 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);
- assertNotNull("Check FS invocation (object) - 2", props.get("object"));
- assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
- assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID); // Dependency broken and restarted with no service
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void atestRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().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);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().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);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
- public void atestBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().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);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 3 (" + id.getState() + ")", id.getState() == ComponentInstance.VALID);
-
- cs = (CheckService) getContext().getService(cs_ref);
- props = cs.getProps();
- //Check properties
- assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- getContext().ungetService(cs_ref);
- }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticSimpleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticSimpleDependencies.java
deleted file mode 100644
index 4ab7404..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticSimpleDependencies.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestStaticSimpleDependencies extends Common {
-
- ComponentInstance instance1, instance2, instance3, instance4, instance5;
- ComponentInstance fooProvider;
-
- @Before
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name", "FooProvider");
- fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
- fooProvider.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name", "Simple");
- instance1 = ipojoHelper.getFactory("StaticSimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name", "Void");
- instance2 = ipojoHelper.getFactory("StaticVoidCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name", "Object");
- instance3 = ipojoHelper.getFactory("StaticObjectCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name", "Ref");
- instance4 = ipojoHelper.getFactory("StaticRefCheckServiceProvider").createComponentInstance(i4);
-
- Properties i5 = new Properties();
- i5.put("instance.name", "Both");
- instance5 = ipojoHelper.getFactory("StaticBothCheckServiceProvider").createComponentInstance(i5);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- }
-
- @After
- public void tearDown() {
- instance1.dispose();
- instance2.dispose();
- instance3.dispose();
- instance4.dispose();
- instance5.dispose();
- fooProvider.dispose();
- instance1 = null;
- instance2 = null;
- instance3 = null;
- instance4 = null;
- instance5 = null;
- fooProvider = null;
- }
-
- @Test
- public void testSimple() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
- // instance1 has to be stopped and restarted.
-
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID); // The instance was invalidated and revalidated.
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
- @Test
- public void testVoid() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- Object o = getContext().getService(cs_ref);
- CheckService cs = (CheckService) o;
- 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() + ")", ((Integer) props.get("voidB")).intValue(), 1);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID); // The instance was revalidated.
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability - 2", cs_ref);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
- @Test
- public void testObject() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability - 2", cs_ref);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
- @Test
- public void testRef() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability - 2", cs_ref);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
- @Test
- public void testBoth() {
- ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
- assertNotNull("Check architecture availability", arch_ref);
- InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
- ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- Properties props = cs.getProps();
- //Check properties
- assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
- assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
- assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
- assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
- assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
- assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
- assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
- assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
- assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- fooProvider.start();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
- cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
- assertNotNull("Check CheckService availability - 2", cs_ref);
-
- fooProvider.stop();
-
- arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
- id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
- id = null;
- cs = null;
- getContext().ungetService(arch_ref);
- }
-
-}