* Fix FELIX-1427
Service dependencies are not able to be injected as smart proxies (generated in bytecode). However the proxies ensure the service object set synchronization.
By default fields now receive proxies (default behavior can be set with the ipojo.depednency.proxy-enabled|disabled system property).
* Fix an interception bug on constructors
* Fix import / package packages of composites and temporal handler as now the core embeds ASM
* Add a classloading issue in the temporal dependencies (Bad classloader)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@893960 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/bundleAsiPOJO/helpers/pom.xml b/ipojo/tests/bundleAsiPOJO/helpers/pom.xml
index 906263f..647d632 100644
--- a/ipojo/tests/bundleAsiPOJO/helpers/pom.xml
+++ b/ipojo/tests/bundleAsiPOJO/helpers/pom.xml
@@ -7,11 +7,13 @@
<version>1.5.0-SNAPSHOT</version>
<name>iPOJO Test Helpers</name>
+
+
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo</artifactId>
- <version>${pom.version}</version>
+ <version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
@@ -26,6 +28,11 @@
<scope>compile</scope>
</dependency>
</dependencies>
+ <parent>
+ <artifactId>felix-parent</artifactId>
+ <groupId>org.apache.felix</groupId>
+ <version>1.2.0</version>
+ </parent>
<build>
<plugins>
diff --git a/ipojo/tests/bundleAsiPOJO/helpers/src/main/java/org/apache/felix/ipojo/test/helpers/IPOJOHelper.java b/ipojo/tests/bundleAsiPOJO/helpers/src/main/java/org/apache/felix/ipojo/test/helpers/IPOJOHelper.java
index bb1cd4d..e723f9f 100644
--- a/ipojo/tests/bundleAsiPOJO/helpers/src/main/java/org/apache/felix/ipojo/test/helpers/IPOJOHelper.java
+++ b/ipojo/tests/bundleAsiPOJO/helpers/src/main/java/org/apache/felix/ipojo/test/helpers/IPOJOHelper.java
@@ -347,6 +347,17 @@
public Element getMetadata(String component) {
return getMetadata(m_context.getBundle(), component);
}
+
+ /**
+ * Returns the instance metadata of a component defined in this bundle.
+ *
+ * @param component the name of the locally defined component.
+ * @return the list of instance metadata of the component with the given name,
+ * defined in this given bundle, or {@code null} if not found.
+ */
+ public Element[] getInstanceMetadata(String component) {
+ return getInstanceMetadata(m_context.getBundle(), component);
+ }
/**
* Returns the component factory with the given name in the given bundle.
@@ -483,6 +494,53 @@
+ bundle.getSymbolicName() + "): " + e.getMessage());
}
}
+
+ /**
+ * Returns the instance metadatas of the component with the given name,
+ * defined in the given bundle.
+ *
+ * @param bundle the bundle from which the component is defined.
+ * @param component the name of the defined component.
+ * @return the list of instance metadata of the component with the given name,
+ * defined in the given bundle, or {@code null} if not found.
+ */
+ public static Element[] getInstanceMetadata(Bundle bundle, String component) {
+
+ // Retrieves the component description from the bundle's manifest.
+ String elem = (String) bundle.getHeaders().get("iPOJO-Components");
+ if (elem == null) {
+ throw new IllegalArgumentException(
+ "Cannot find iPOJO-Components descriptor in the specified bundle ("
+ + bundle.getSymbolicName()
+ + "). Not an iPOJO bundle.");
+ }
+
+ // Parses the retrieved description and find the component with the
+ // given name.
+ List list = new ArrayList();
+ try {
+ Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
+ Element[] childs = element.getElements("instance");
+ for (int i = 0; i < childs.length; i++) {
+ String name = childs[i].getAttribute("component");
+ if (name != null && name.equalsIgnoreCase(component)) {
+ list.add(childs[i]);
+ }
+ }
+
+ if (list.isEmpty()) {
+ // Component not found...
+ return null;
+ } else {
+ return (Element[]) list.toArray(new Element[list.size()]);
+ }
+
+ } catch (ParseException e) {
+ throw new IllegalStateException(
+ "Cannot parse the components from specified bundle ("
+ + bundle.getSymbolicName() + "): " + e.getMessage());
+ }
+ }
/**
* Returns the service object of a service registered in the specified
diff --git a/ipojo/tests/bundleAsiPOJO/pom.xml b/ipojo/tests/bundleAsiPOJO/pom.xml
index f2ddfac..f9b0f10 100644
--- a/ipojo/tests/bundleAsiPOJO/pom.xml
+++ b/ipojo/tests/bundleAsiPOJO/pom.xml
@@ -24,7 +24,7 @@
<name>Apache Felix iPOJO TinyBundles Extension</name>
<packaging>pom</packaging>
- <profiles>
+ <profiles>
<profile>
<id>java5</id>
<activation>
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java
index f69e76d..2bd64dc 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java
@@ -83,6 +83,10 @@
assertEquals("Check mod unbind", "unbindMod", unbind);
assertEquals("Check mod modified", "modifiedMod", mod);
assertEquals("Check mod id", "mod", id);
+
+ // Check not proxied
+ dep = getDependencyById(deps, "notproxied");
+ assertEquals("Check not proxied", "false", dep.getAttribute("proxy"));
}
private Element getDependencyById(Element[] deps, String name) {
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java
index 906fa4f..17d8d19 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java
@@ -76,5 +76,8 @@
}
+ @Requires(proxy=false, id="notproxied")
+ FooService myFoo;
+
}
diff --git a/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml
index 9918326..5cdf205 100644
--- a/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml
@@ -3,120 +3,120 @@
xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
xmlns="org.apache.felix.ipojo">
- <!-- Simple Filter Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"
- name="SimpleFilterCheckServiceProvider" architecture="true">
- <provides>
- <property field="m_toto" name="toto" value="A" />
- </provides>
- </component>
+ <!-- Simple Filter Dependencies -->
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"
+ name="SimpleFilterCheckServiceProvider" architecture="true">
+ <provides>
+ <property field="m_toto" name="toto" value="A" />
+ </provides>
+ </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="SimpleFilterCheckServiceSubscriber" architecture="true">
- <requires field="m_foo" filter="(toto=B)" id="id1">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="SimpleFromCheckServiceSubscriber" architecture="true">
- <requires field="m_foo" from="A" id="id1">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"
- name="SimplePIDCheckServiceProvider" architecture="true">
- <provides>
- <property type="String" name="service.pid" />
- </provides>
- </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
+ name="SimpleFilterCheckServiceSubscriber" architecture="true">
+ <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
+ name="SimpleFromCheckServiceSubscriber" architecture="true">
+ <requires field="m_foo" from="A" id="id1" proxy="false">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"
+ name="SimplePIDCheckServiceProvider" architecture="true">
+ <provides>
+ <property type="String" name="service.pid" />
+ </provides>
+ </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="SimpleFilterCheckServiceSubscriber2" architecture="true">
- <requires field="m_foo" id="id2">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
+ name="SimpleFilterCheckServiceSubscriber2" architecture="true">
+ <requires field="m_foo" id="id2" proxy="false">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
- <!-- Optional Simple Filter Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="OptionalSimpleFilterCheckServiceSubscriber"
- architecture="true">
- <requires field="m_foo" filter="(toto=B)" id="id1"
- optional="true">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
+ <!-- Optional Simple Filter Dependencies -->
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
+ name="OptionalSimpleFilterCheckServiceSubscriber"
+ architecture="true">
+ <requires field="m_foo" filter="(toto=B)" id="id1"
+ optional="true" proxy="false">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
- name="OptionalSimpleFilterCheckServiceSubscriber2"
- architecture="true">
- <requires field="m_foo" id="id2" optional="true">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"
+ name="OptionalSimpleFilterCheckServiceSubscriber2"
+ architecture="true">
+ <requires field="m_foo" id="id2" optional="true" proxy="false">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
- <!-- Aggregate filter Dependencies-->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
- name="MultipleFilterCheckServiceSubscriber" architecture="true">
- <requires field="m_foo" filter="(toto=B)" id="id1">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
+ <!-- Aggregate filter Dependencies-->
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
+ name="MultipleFilterCheckServiceSubscriber" architecture="true">
+ <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
- name="MultipleFilterCheckServiceSubscriber2" architecture="true">
- <requires field="m_foo" id="id2">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
+ name="MultipleFilterCheckServiceSubscriber2" architecture="true">
+ <requires field="m_foo" id="id2" proxy="false">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
- <!-- Optional Aggregate Filter Dependencies -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
- name="OptionalMultipleFilterCheckServiceSubscriber"
- architecture="true">
- <requires field="m_foo" filter="(toto=B)" id="id1"
- optional="true">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
+ <!-- Optional Aggregate Filter Dependencies -->
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
+ name="OptionalMultipleFilterCheckServiceSubscriber"
+ architecture="true">
+ <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false"
+ optional="true">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
- <component
- classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
- name="OptionalMultipleFilterCheckServiceSubscriber2"
- architecture="true">
- <requires field="m_foo" id="id2" optional="true">
- <callback type="bind" method="Bind" />
- <callback type="unbind" method="Unbind" />
- </requires>
- <provides />
- </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"
+ name="OptionalMultipleFilterCheckServiceSubscriber2"
+ architecture="true">
+ <requires field="m_foo" id="id2" optional="true" proxy="false">
+ <callback type="bind" method="Bind" />
+ <callback type="unbind" method="Unbind" />
+ </requires>
+ <provides />
+ </component>
</ipojo>
diff --git a/ipojo/tests/core/service-dependency/pom.xml b/ipojo/tests/core/service-dependency/pom.xml
index 3b112f9..ce5a943 100644
--- a/ipojo/tests/core/service-dependency/pom.xml
+++ b/ipojo/tests/core/service-dependency/pom.xml
@@ -35,9 +35,9 @@
<version>${pom.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.0.1</version>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -98,7 +98,6 @@
</configuration>
</plugin>
- <!--
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-junit4osgi-plugin</artifactId>
@@ -116,7 +115,6 @@
</execution>
</executions>
</plugin>
- -->
</plugins>
</build>
</project>
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
index 8ace55d..4130ea0 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
@@ -35,586 +35,686 @@
import org.osgi.framework.ServiceReference;
public class DependencyArchitectureTest extends OSGiTestCase {
-
- ComponentInstance fooProvider1, fooProvider2;
-
- ComponentInstance instance1, instance2, instance3, instance4;
-
- public void setUp() {
- try {
- Properties prov = new Properties();
- prov.put("instance.name","FooProvider");
- fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
- fooProvider1.stop();
-
- Properties prov2 = new Properties();
- prov2.put("instance.name","FooProvider2");
- fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
- fooProvider2.stop();
-
- Properties i1 = new Properties();
- i1.put("instance.name","Simple");
- instance1 = Utils.getFactoryByName(getContext(), "SimpleCheckServiceProvider").createComponentInstance(i1);
-
- Properties i2 = new Properties();
- i2.put("instance.name","Optional");
- instance2 = Utils.getFactoryByName(getContext(), "SimpleOptionalCheckServiceProvider").createComponentInstance(i2);
-
- Properties i3 = new Properties();
- i3.put("instance.name","Multiple");
- instance3 = Utils.getFactoryByName(getContext(), "SimpleMultipleCheckServiceProvider").createComponentInstance(i3);
-
- Properties i4 = new Properties();
- i4.put("instance.name","OptionalMultiple");
- instance4 = Utils.getFactoryByName(getContext(), "SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
- } catch(Exception e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- 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;
- }
-
- private DependencyHandlerDescription getDependencyDesc(InstanceDescription id) {
- DependencyHandlerDescription handler = (DependencyHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:requires");
- if (handler == null) {
- fail("Dependency Handler not found");
- return null;
- } else {
- return handler;
- }
- }
-
- private DependencyDescription getDependencyDescBySpecification(
+
+ ComponentInstance fooProvider1, fooProvider2;
+
+ ComponentInstance instance1, instance2, instance3, instance4, instance5;
+
+ public void setUp() {
+ try {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider");
+ fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+ fooProvider1.stop();
+
+ Properties prov2 = new Properties();
+ prov2.put("instance.name","FooProvider2");
+ fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
+ fooProvider2.stop();
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "SimpleCheckServiceProvider").createComponentInstance(i1);
+
+ Properties i5 = new Properties();
+ i5.put("instance.name","ProxiedSimple");
+ instance5 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i5);
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Optional");
+ instance2 = Utils.getFactoryByName(getContext(), "SimpleOptionalCheckServiceProvider").createComponentInstance(i2);
+
+ Properties i3 = new Properties();
+ i3.put("instance.name","Multiple");
+ instance3 = Utils.getFactoryByName(getContext(), "SimpleMultipleCheckServiceProvider").createComponentInstance(i3);
+
+ Properties i4 = new Properties();
+ i4.put("instance.name","OptionalMultiple");
+ instance4 = Utils.getFactoryByName(getContext(), "SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
+ } catch(Exception e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ public void tearDown() {
+ instance1.dispose();
+ instance2.dispose();
+ instance3.dispose();
+ instance4.dispose();
+ instance5.dispose();
+ fooProvider1.dispose();
+ fooProvider2.dispose();
+ instance1 = null;
+ instance2 = null;
+ instance3 = null;
+ instance4 = null;
+ instance5 = null;
+ fooProvider1 = null;
+ fooProvider2 = null;
+ }
+
+ private DependencyHandlerDescription getDependencyDesc(InstanceDescription id) {
+ DependencyHandlerDescription handler = (DependencyHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:requires");
+ if (handler == null) {
+ fail("Dependency Handler not found");
+ return null;
+ } else {
+ return handler;
+ }
+ }
+
+ private DependencyDescription getDependencyDescBySpecification(
PrimitiveInstanceDescription id, String spec) {
return id.getDependency(spec);
}
-
- private ProvidedServiceHandlerDescription getPSDesc(InstanceDescription id) {
- ProvidedServiceHandlerDescription handler = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");
+
+ private ProvidedServiceHandlerDescription getPSDesc(InstanceDescription id) {
+ ProvidedServiceHandlerDescription handler = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");
if (handler == null) {
fail("Provided Service Handler not found");
return null;
} else {
return handler;
}
- }
-
- public void testSimpleDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());
- assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
-
- fooProvider1.start();
-
- ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider1.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
- psh = getPSDesc(id_ps);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
- public void testOptionalDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), "FooService");
- assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
-
- fooProvider1.start();
-
- ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider1.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
- psh = getPSDesc(id_ps);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
- psh = getPSDesc(id_ps);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
- public void testMultipleDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- DependencyDescription dd = getDependencyDescBySpecification(id_dep, FooService.class.getName());
- assertFalse("Check dependency handler invalidity", dhd.isValid());
- assertTrue("Check dependency invalidity", dd.getState() == Dependency.UNRESOLVED);
+ }
+
+ public void testSimpleDependency() {
+ ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_dep);
+ PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+
+ // Check dependency handler invalidity
+ DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+
+ // Check dependency metadata
+ assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
+ assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());
+ assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
+ assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
+ assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
+ assertFalse("Check dependency proxy", dhd.getDependencies()[0].isProxy());
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
-
- assertEquals("Check dependency interface", dd.getSpecification(), FooService.class.getName());
+ fooProvider1.start();
+
+ ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps);
+ PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ fooProvider1.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+ dhd = getDependencyDesc(id_dep);
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+
+ fooProvider1.start();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
+ psh = getPSDesc(id_ps);
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+
+ assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ psh = getPSDesc(id_ps);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ fooProvider1.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+ dhd = getDependencyDesc(id_dep);
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+
+ id_dep = null;
+ cs = null;
+ getContext().ungetService(arch_dep);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testProxiedSimpleDependency() {
+ ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
+ assertNotNull("Check architecture availability", arch_dep);
+ PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+
+ // Check dependency handler invalidity
+ DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+
+ // Check dependency metadata
+ assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
+ assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());
+ assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
+ assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
+ assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
+ assertTrue("Check dependency proxy", dhd.getDependencies()[0].isProxy());
+
+ fooProvider1.start();
+
+ ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps);
+ PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ fooProvider1.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+ dhd = getDependencyDesc(id_dep);
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+
+ fooProvider1.start();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
+ psh = getPSDesc(id_ps);
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+
+ assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ psh = getPSDesc(id_ps);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ fooProvider1.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);
+ dhd = getDependencyDesc(id_dep);
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+
+ id_dep = null;
+ cs = null;
+ getContext().ungetService(arch_dep);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testOptionalDependency() {
+ ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
+ assertNotNull("Check architecture availability", arch_dep);
+ PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check dependency handler invalidity
+ DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler invalidity", dhd.isValid());
+
+ // Check dependency metadata
+ assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
+ assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), "FooService");
+ assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
+ assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());
+ assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
+
+ fooProvider1.start();
+
+ ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps);
+ PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ fooProvider1.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler invalidity", dhd.isValid());
+
+ fooProvider1.start();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);
+ psh = getPSDesc(id_ps);
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+
+ assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();
+ psh = getPSDesc(id_ps);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ fooProvider1.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler invalidity", dhd.isValid());
+
+ id_dep = null;
+ cs = null;
+ getContext().ungetService(arch_dep);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testMultipleDependency() {
+ ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
+ assertNotNull("Check architecture availability", arch_dep);
+ PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.INVALID);
+
+ // Check dependency handler invalidity
+ DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
+ DependencyDescription dd = getDependencyDescBySpecification(id_dep, FooService.class.getName());
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+ assertTrue("Check dependency invalidity", dd.getState() == Dependency.UNRESOLVED);
+
+
+ // Check dependency metadata
+ assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
+ assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
+ assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());
+ assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
+
+ assertEquals("Check dependency interface", dd.getSpecification(), FooService.class.getName());
assertTrue("Check dependency cardinality", dd.isMultiple());
assertFalse("Check dependency optionality", dd.isOptional());
assertNull("Check dependency ref -1", dd.getServiceReferences());
-
- fooProvider1.start();
-
- ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_ps1.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
- assertEquals("Check used ref - 1 (" + dhd.getDependencies()[0].getUsedServices().size() + ")", dhd.getDependencies()[0].getUsedServices().size(), 0);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 2", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- // Start a second foo service provider
- fooProvider2.start();
-
- arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- assertNotNull("Check architecture 2 availability", arch_ps2);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
- assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);
- assertEquals("Check used ref - 2 ", dhd.getDependencies()[0].getUsedServices().size(), 1); // provider 2 not already used
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- //id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);
- ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 3.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));
- assertTrue("Check service reference - 3.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));
- assertEquals("Check used ref - 3 ("+dhd.getDependencies()[0].getUsedServices().size()+")", dhd.getDependencies()[0].getUsedServices().size(), 2);
-
- fooProvider2.stop();
-
- arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance validity - 1", id_ps1.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
- assertEquals("Check used ref - 4 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- psh = getPSDesc(id_ps1);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
- assertEquals("Check used ref - 5 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
-
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider2.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
-
- assertTrue("Check instance invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
-
- psh = getPSDesc(id_ps2);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
- assertEquals("Check used ref - 6 ", dhd.getDependencies()[0].getUsedServices().size(), 0);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- psh = getPSDesc(id_ps2);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
- assertEquals("Check used ref - 7 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
-
- fooProvider2.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertFalse("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
- public void testMultipleOptionalDependency() {
- ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
- assertNotNull("Check architecture availability", arch_dep);
- PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.VALID);
-
- // Check dependency handler invalidity
- DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- // Check dependency metadata
- assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
- assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
- assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());
- assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
-
- fooProvider1.start();
-
- ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- CheckService cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
-
- // Start a second foo service provider
- fooProvider2.start();
-
- arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- assertNotNull("Check architecture 2 availability", arch_ps2);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
- assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- //id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);
- ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 2.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));
- assertTrue("Check service reference - 2.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));
-
- fooProvider2.stop();
-
- arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps1);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler validity", dhd.isValid());
- assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- psh = getPSDesc(id_ps1);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
- assertTrue("Check service reference - 3", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+ assertFalse("Check dependency proxy", dhd.getDependencies()[0].isProxy());
- fooProvider1.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- fooProvider2.start();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
- assertNotNull("Check architecture availability", arch_ps2);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- assertTrue("Check instance invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
- psh = getPSDesc(id_ps2);
- assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
- assertTrue("Check dependency handler validity", dhd.isValid());
-
- assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
-
- cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
- assertNotNull("Check CheckService availability", cs_ref);
- cs = (CheckService) getContext().getService(cs_ref);
- assertTrue("check CheckService invocation", cs.check());
-
- // Check object graph
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- dhd = getDependencyDesc(id_dep);
- //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
- psh = getPSDesc(id_ps2);
- assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
- assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+ fooProvider1.start();
+
+ ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps1);
+ PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_ps1.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+ assertEquals("Check used ref - 1 (" + dhd.getDependencies()[0].getUsedServices().size() + ")", dhd.getDependencies()[0].getUsedServices().size(), 0);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 2", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ // Start a second foo service provider
+ fooProvider2.start();
+
+ arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps1);
+ assertNotNull("Check architecture 2 availability", arch_ps2);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
+ assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);
+ assertEquals("Check used ref - 2 ", dhd.getDependencies()[0].getUsedServices().size(), 1); // provider 2 not already used
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ //id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);
+ ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);
+ assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
+ assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 3.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));
+ assertTrue("Check service reference - 3.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));
+ assertEquals("Check used ref - 3 ("+dhd.getDependencies()[0].getUsedServices().size()+")", dhd.getDependencies()[0].getUsedServices().size(), 2);
+
+ fooProvider2.stop();
+
+ arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps1);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id_ps1.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+ assertEquals("Check used ref - 4 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ psh = getPSDesc(id_ps1);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+ assertEquals("Check used ref - 5 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
+
+ fooProvider1.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+
+ fooProvider2.start();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps1);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+
+ assertTrue("Check instance invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
+
+ psh = getPSDesc(id_ps2);
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+
+ assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+ assertEquals("Check used ref - 6 ", dhd.getDependencies()[0].getUsedServices().size(), 0);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ psh = getPSDesc(id_ps2);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+ assertEquals("Check used ref - 7 ", dhd.getDependencies()[0].getUsedServices().size(), 1);
+
+ fooProvider2.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertFalse("Check dependency handler invalidity", dhd.isValid());
+
+ id_dep = null;
+ cs = null;
+ getContext().ungetService(arch_dep);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testMultipleOptionalDependency() {
+ ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
+ assertNotNull("Check architecture availability", arch_dep);
+ PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.VALID);
+
+ // Check dependency handler invalidity
+ DependencyHandlerDescription dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler invalidity", dhd.isValid());
+
+ // Check dependency metadata
+ assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());
+ assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());
+ assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());
+ assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());
+
+ fooProvider1.start();
+
+ ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps1);
+ PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ // Start a second foo service provider
+ fooProvider2.start();
+
+ arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps1);
+ assertNotNull("Check architecture 2 availability", arch_ps2);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
+ assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ //id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);
+ ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);
+ assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
+ assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 2.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));
+ assertTrue("Check service reference - 2.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));
+
+ fooProvider2.stop();
+
+ arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps1);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+ assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ psh = getPSDesc(id_ps1);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);
+ assertTrue("Check service reference - 3", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
- fooProvider2.stop();
-
- //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
- assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
- dhd = getDependencyDesc(id_dep);
- assertTrue("Check dependency handler invalidity", dhd.isValid());
-
- id_dep = null;
- cs = null;
- getContext().ungetService(arch_dep);
- getContext().ungetService(cs_ref);
- }
-
-
-
+ fooProvider1.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler invalidity", dhd.isValid());
+
+ fooProvider2.start();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ps2);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);
+ psh = getPSDesc(id_ps2);
+ assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);
+ assertTrue("Check dependency handler validity", dhd.isValid());
+
+ assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ cs = (CheckService) getContext().getService(cs_ref);
+ assertTrue("check CheckService invocation", cs.check());
+
+ // Check object graph
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ dhd = getDependencyDesc(id_dep);
+ //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();
+ psh = getPSDesc(id_ps2);
+ assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());
+ assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));
+
+ fooProvider2.stop();
+
+ //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);
+ dhd = getDependencyDesc(id_dep);
+ assertTrue("Check dependency handler invalidity", dhd.isValid());
+
+ id_dep = null;
+ cs = null;
+ getContext().ungetService(arch_dep);
+ getContext().ungetService(cs_ref);
+ }
+
+
+
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java
index fb6eb1c..a318fdc 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java
@@ -29,14 +29,20 @@
public static Test suite(BundleContext bc) {
OSGiTestSuite ots = new OSGiTestSuite("Service Dependencies Test Suite", bc);
ots.addTestSuite(SimpleDependencies.class);
+ ots.addTestSuite(ProxiedSimpleDependencies.class);
ots.addTestSuite(OptionalDependencies.class);
+ ots.addTestSuite(ProxiedOptionalDependencies.class);
ots.addTestSuite(OptionalNoNullableDependencies.class);
ots.addTestSuite(MultipleDependencies.class);
ots.addTestSuite(OptionalMultipleDependencies.class);
ots.addTestSuite(DelayedSimpleDependencies.class);
+ ots.addTestSuite(ProxiedDelayedSimpleDependencies.class);
ots.addTestSuite(DelayedOptionalDependencies.class);
+ ots.addTestSuite(ProxiedDelayedOptionalDependencies.class);
ots.addTestSuite(DelayedMultipleDependencies.class);
+ ots.addTestSuite(ProxiedDelayedMultipleDependencies.class);
ots.addTestSuite(DelayedOptionalMultipleDependencies.class);
+ ots.addTestSuite(ProxiedDelayedOptionalMultipleDependencies.class);
ots.addTestSuite(MethodSimpleDependencies.class);
ots.addTestSuite(MethodOptionalDependencies.class);
ots.addTestSuite(MethodMultipleDependencies.class);
@@ -48,10 +54,14 @@
ots.addTest(DefaultImplementationTestSuite.suite(bc));
ots.addTestSuite(DependencyArchitectureTest.class);
ots.addTestSuite(ListMultipleDependencies.class);
+ ots.addTestSuite(ProxiedListMultipleDependencies.class);
ots.addTestSuite(VectorMultipleDependencies.class);
ots.addTestSuite(SetMultipleDependencies.class);
+ ots.addTestSuite(ProxiedSetMultipleDependencies.class);
ots.addTestSuite(CollectionMultipleDependencies.class);
+ ots.addTestSuite(ProxiedCollectionMultipleDependencies.class);
ots.addTestSuite(ModifyDependencies.class);
+ ots.addTestSuite(ProxyTest.class);
return ots;
}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.java
new file mode 100644
index 0000000..79943853
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.java
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ProxiedCollectionMultipleDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2;
+ ComponentInstance fooProvider1, fooProvider2;
+
+ public void setUp() {
+ try {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider1");
+ fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+ fooProvider1.stop();
+
+ Properties prov2 = new Properties();
+ prov2.put("instance.name","FooProvider2");
+ fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
+ fooProvider2.stop();
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCollectionCheckServiceProvider").createComponentInstance(i1);
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Optional");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalCollectionCheckServiceProvider").createComponentInstance(i2);
+ } catch(Exception e) { fail(e.getMessage()); }
+
+ }
+
+ public void tearDown() {
+ instance1.dispose();
+ instance2.dispose();
+ fooProvider1.dispose();
+ fooProvider2.dispose();
+ instance1 = null;
+ instance2 = null;
+ fooProvider1 = null;
+ fooProvider2 = null;
+ }
+
+ public void testSimple() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
+
+ fooProvider1.start();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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();
+ 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(), 2);
+ assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(cs_ref);
+ props = cs.getProps();
+ //Check properties
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
+ assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
+ assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
+ assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
+ assertEquals("check 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);
+
+ fooProvider2.stop();
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testOptional() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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 - 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);
+
+ fooProvider1.start();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ 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(), 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);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedMultipleDependencies.java
new file mode 100644
index 0000000..8f3e0d6
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedMultipleDependencies.java
@@ -0,0 +1,518 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+
+public class ProxiedDelayedMultipleDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
+ ComponentInstance fooProvider1, fooProvider2;
+
+ public void setUp() {
+ try {
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleMultipleCheckServiceProvider").createComponentInstance(i1);
+ instance1.stop();
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Void");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidMultipleCheckServiceProvider").createComponentInstance(i2);
+ instance2.stop();
+
+ Properties i3 = new Properties();
+ i3.put("instance.name","Object");
+ instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectMultipleCheckServiceProvider").createComponentInstance(i3);
+ instance3.stop();
+
+ Properties i4 = new Properties();
+ i4.put("instance.name","Ref");
+ instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefMultipleCheckServiceProvider").createComponentInstance(i4);
+ instance4.stop();
+
+ Properties i5 = new Properties();
+ i5.put("instance.name","Both");
+ instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothMultipleCheckServiceProvider").createComponentInstance(i5);
+ instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapMultipleCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dict");
+ instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictMultipleCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
+
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider1");
+ fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+
+ Properties prov2 = new Properties();
+ prov2.put("instance.name","FooProvider2");
+ fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
+ } catch(Exception e) { fail(e.getMessage()); }
+ }
+
+ 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;
+ }
+
+ public void testSimple() {
+ instance1.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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(), 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) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", 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, 0);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(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();
+ }
+
+ public void testVoid() {
+ instance2.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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(), 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) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(cs_ref);
+ props = cs.getProps();
+ //Check properties
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 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) getContext().getService(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();
+ }
+
+ public void testObject() {
+ instance3.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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.VALID);
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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(), 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) 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 - 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) getContext().getService(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();
+ }
+
+ public void testRef() {
+ instance4.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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(), 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) 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 - 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) getContext().getService(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);
+ }
+
+ public void testBoth() {
+ instance5.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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()); // 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) 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 - 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) getContext().getService(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);
+ }
+
+ public void testMap() {
+ instance6.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.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 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) 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 - 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) getContext().getService(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);
+ }
+
+ public void testDict() {
+ instance7.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.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 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) 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 - 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) getContext().getService(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/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalDependencies.java
new file mode 100644
index 0000000..2fca044
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalDependencies.java
@@ -0,0 +1,492 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+
+public class ProxiedDelayedOptionalDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
+
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ try {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider");
+ fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
+ instance1.stop();
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Void");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);
+ instance2.stop();
+
+ Properties i3 = new Properties();
+ i3.put("instance.name","Object");
+ instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);
+ instance3.stop();
+
+ Properties i4 = new Properties();
+ i4.put("instance.name","Ref");
+ instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);
+ instance4.stop();
+
+ Properties i5 = new Properties();
+ i5.put("instance.name","Both");
+ instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);
+ instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dict");
+ instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+
+ }
+
+ 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;
+ }
+
+ public void testSimple() {
+ instance1.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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(), 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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+
+ instance1.stop();
+ }
+
+ public void testVoid() {
+ instance2.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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(), 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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+
+ instance2.stop();
+ }
+
+ public void testObject() {
+ instance3.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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();
+ }
+
+ public void testRef() {
+ instance4.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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();
+ }
+
+ public void testBoth() {
+ instance5.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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);
+ 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) 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);
+ 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();
+ }
+
+ public void testMap() {
+ instance6.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.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);
+ 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) 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);
+ 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();
+ }
+
+ public void testDict() {
+ instance7.start();
+
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.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);
+ 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) 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);
+ 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/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalMultipleDependencies.java
new file mode 100644
index 0000000..3609844
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedOptionalMultipleDependencies.java
@@ -0,0 +1,356 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ProxiedDelayedOptionalMultipleDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2, instance3, instance4;
+ ComponentInstance fooProvider1, fooProvider2;
+
+ public void setUp() {
+ try {
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
+ instance1.stop();
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Void");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
+ instance2.stop();
+
+ Properties i3 = new Properties();
+ i3.put("instance.name","Object");
+ instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
+ instance3.stop();
+
+ Properties i4 = new Properties();
+ i4.put("instance.name","Ref");
+ instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
+ instance4.stop();
+
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider1");
+ fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+
+ Properties prov2 = new Properties();
+ prov2.put("instance.name","FooProvider2");
+ fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
+ } catch(Exception e) { fail(e.getMessage()); }
+ }
+
+ 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;
+ }
+
+ public void testSimple() {
+ instance1.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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 - 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);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ instance1.stop();
+ }
+
+ public void testVoid() {
+ instance2.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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 - 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);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(cs_ref);
+ props = cs.getProps();
+ //Check properties
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 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);
+
+ fooProvider2.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 - 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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ instance2.stop();
+ }
+
+ public void testObject() {
+ instance3.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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 - 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);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ instance3.stop();
+ }
+
+ public void testRef() {
+ instance4.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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 - 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);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ fooProvider2.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 - 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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ instance4.stop();
+ }
+
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedSimpleDependencies.java
new file mode 100644
index 0000000..982dfe5
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedDelayedSimpleDependencies.java
@@ -0,0 +1,364 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+public class ProxiedDelayedSimpleDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
+ ComponentInstance fooProvider;
+
+
+ public void setUp() {
+ try {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider");
+ fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);
+ instance1.stop();
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Void");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidCheckServiceProvider").createComponentInstance(i2);
+ instance2.stop();
+
+ Properties i3 = new Properties();
+ i3.put("instance.name","Object");
+ instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectCheckServiceProvider").createComponentInstance(i3);
+ instance3.stop();
+
+ Properties i4 = new Properties();
+ i4.put("instance.name","Ref");
+ instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefCheckServiceProvider").createComponentInstance(i4);
+ instance4.stop();
+
+ Properties i5 = new Properties();
+ i5.put("instance.name","Both");
+ instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothCheckServiceProvider").createComponentInstance(i5);
+ instance5.stop();
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapCheckServiceProvider").createComponentInstance(i6);
+ instance6.stop();
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dict");
+ instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictCheckServiceProvider").createComponentInstance(i7);
+ instance7.stop();
+ } catch(Exception e) { fail(e.getMessage()); }
+
+ }
+
+ 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;
+ }
+
+ public void testSimple() {
+ instance1.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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();
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
+ fooProvider.start();
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+ cs_ref = Utils.getServiceReferenceByName(getContext(), 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();
+ 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);
+ instance1.stop();
+ }
+
+ public void testVoid() {
+ instance2.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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);
+
+ fooProvider.stop();
+
+ 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);
+
+ instance2.stop();
+ }
+
+ public void testObject() {
+ instance3.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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 invalidity - 2", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+
+ instance3.stop();
+ }
+
+ public void testRef() {
+ instance4.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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 invalidity - 2", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+
+ instance4.stop();
+ }
+
+ public void testBoth() {
+ instance5.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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);
+
+ 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) 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);
+
+ instance5.stop();
+ }
+
+ public void testMap() {
+ instance6.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.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);
+
+ 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) 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);
+
+ instance6.stop();
+ }
+ public void testDict() {
+ instance7.start();
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.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);
+
+ 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) 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);
+
+ instance7.stop();
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.java
new file mode 100644
index 0000000..9365c1c
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.java
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ProxiedListMultipleDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2;
+ ComponentInstance fooProvider1, fooProvider2;
+
+ public void setUp() {
+ try {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider1");
+ fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+ fooProvider1.stop();
+
+ Properties prov2 = new Properties();
+ prov2.put("instance.name","FooProvider2");
+ fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
+ fooProvider2.stop();
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleListCheckServiceProvider").createComponentInstance(i1);
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Optional");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalListCheckServiceProvider").createComponentInstance(i2);
+ } catch(Exception e) { fail(e.getMessage()); }
+
+ }
+
+ public void tearDown() {
+ instance1.dispose();
+ instance2.dispose();
+ fooProvider1.dispose();
+ fooProvider2.dispose();
+ instance1 = null;
+ instance2 = null;
+ fooProvider1 = null;
+ fooProvider2 = null;
+ }
+
+ public void testSimple() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
+
+ fooProvider1.start();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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();
+ 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(), 2);
+ assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(cs_ref);
+ props = cs.getProps();
+ //Check properties
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
+ assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
+ assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
+ assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
+ assertEquals("check 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);
+
+ fooProvider2.stop();
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testOptional() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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 - 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);
+
+ fooProvider1.start();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ 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(), 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);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedOptionalDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedOptionalDependencies.java
new file mode 100644
index 0000000..eef46e2
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedOptionalDependencies.java
@@ -0,0 +1,547 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+
+public class ProxiedOptionalDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ try {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider");
+ fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+ fooProvider.stop();
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Void");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);
+
+ Properties i3 = new Properties();
+ i3.put("instance.name","Object");
+ instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);
+
+ Properties i4 = new Properties();
+ i4.put("instance.name","Ref");
+ instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);
+
+ Properties i5 = new Properties();
+ i5.put("instance.name","Both");
+ instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Map");
+ instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Dictionary");
+ instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);
+ } catch(Exception e) { fail(e.getMessage()); }
+ }
+
+ 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;
+ }
+
+ public void testSimple() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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")+")", 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);
+
+ 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);
+
+ 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);
+ }
+
+ public void testVoid() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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);
+ assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 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);
+
+ 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(), 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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testObject() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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()); // 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);
+ }
+
+ public void testRef() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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);
+ }
+
+ public void testBoth() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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);
+ }
+
+ public void testMap() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.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);
+ 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) 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(), 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) 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);
+ 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);
+ }
+
+ public void testDict() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.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);
+ 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) 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(), 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) 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);
+ 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/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.java
new file mode 100644
index 0000000..002d57f
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.java
@@ -0,0 +1,248 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ProxiedSetMultipleDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2;
+ ComponentInstance fooProvider1, fooProvider2;
+
+ public void setUp() {
+ try {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider1");
+ fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+ fooProvider1.stop();
+
+ Properties prov2 = new Properties();
+ prov2.put("instance.name","FooProvider2");
+ fooProvider2 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov2);
+ fooProvider2.stop();
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleSetCheckServiceProvider").createComponentInstance(i1);
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Optional");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalSetCheckServiceProvider").createComponentInstance(i2);
+ } catch(Exception e) { fail(e.getMessage()); }
+
+ }
+
+ public void tearDown() {
+ instance1.dispose();
+ instance2.dispose();
+ fooProvider1.dispose();
+ fooProvider2.dispose();
+ instance1 = null;
+ instance2 = null;
+ fooProvider1 = null;
+ fooProvider2 = null;
+ }
+
+ public void testSimple() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
+
+ fooProvider1.start();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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();
+ 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(), 2);
+ assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
+ assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(cs_ref);
+ props = cs.getProps();
+ //Check properties
+ assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here
+ assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
+ assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
+ assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
+ assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
+ assertEquals("check 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);
+
+ fooProvider2.stop();
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testOptional() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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 - 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);
+
+ fooProvider1.start();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ 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(), 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);
+
+ fooProvider1.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ fooProvider2.stop();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
+
+ cs = (CheckService) getContext().getService(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);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSimpleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSimpleDependencies.java
new file mode 100644
index 0000000..a87026f
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSimpleDependencies.java
@@ -0,0 +1,414 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.architecture.InstanceDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+
+public class ProxiedSimpleDependencies extends OSGiTestCase {
+
+ ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7, instance8;
+ ComponentInstance fooProvider;
+
+ public void setUp() {
+ try {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider");
+ fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+ fooProvider.stop();
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Simple");
+ instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);
+
+ Properties i2 = new Properties();
+ i2.put("instance.name","Void");
+ instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidCheckServiceProvider").createComponentInstance(i2);
+
+ Properties i3 = new Properties();
+ i3.put("instance.name","Object");
+ instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectCheckServiceProvider").createComponentInstance(i3);
+
+ Properties i4 = new Properties();
+ i4.put("instance.name","Ref");
+ instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefCheckServiceProvider").createComponentInstance(i4);
+
+ Properties i5 = new Properties();
+ i5.put("instance.name","Both");
+ instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothCheckServiceProvider").createComponentInstance(i5);
+
+ Properties i6 = new Properties();
+ i6.put("instance.name","Double");
+ instance6 = Utils.getFactoryByName(getContext(), "ProxiedDoubleCheckServiceProvider").createComponentInstance(i6);
+
+ Properties i7 = new Properties();
+ i7.put("instance.name","Map");
+ instance7 = Utils.getFactoryByName(getContext(), "ProxiedMapCheckServiceProvider").createComponentInstance(i7);
+
+ Properties i8 = new Properties();
+ i8.put("instance.name","Dictionary");
+ instance8 = Utils.getFactoryByName(getContext(), "ProxiedDictCheckServiceProvider").createComponentInstance(i8);
+ } catch(Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage()); }
+
+ }
+
+ 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;
+ }
+
+ public void testSimple() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());
+ assertNotNull("Check architecture availability", arch_ref);
+ InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
+
+ fooProvider.start();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
+
+ ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), 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();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
+
+ fooProvider.start();
+
+ id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
+ assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
+
+ cs_ref = Utils.getServiceReferenceByName(getContext(), 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();
+
+ 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);
+ }
+
+ public void testVoid() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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();
+
+ 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);
+ }
+
+ public void testObject() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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 invalidity - 2", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testRef() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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 invalidity - 2", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testBoth() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), 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 = Utils.getServiceReferenceByName(getContext(), 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 invalidity - 2", id.getState() == ComponentInstance.INVALID);
+
+ id = null;
+ cs = null;
+ getContext().ungetService(arch_ref);
+ getContext().ungetService(cs_ref);
+ }
+
+ public void testDouble() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());
+ assertNotNull("Check CheckService availability", cs_ref);
+ CheckService cs = (CheckService) getContext().getService(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) 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);
+ }
+
+ public void testMap() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.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);
+ 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) 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);
+ }
+
+ public void testDict() {
+ ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance8.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 = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance8.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);
+ 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) 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/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java
new file mode 100644
index 0000000..5e9af89
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java
@@ -0,0 +1,196 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+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.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ProxyTest extends OSGiTestCase {
+
+
+ public void testDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider1-Proxy");
+ ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Delegator");
+ ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
+ "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
+
+
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+ assertNotNull(ref);
+ CheckService cs = (CheckService) context.getService(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();
+ }
+
+ public void testDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+ Properties i1 = new Properties();
+ i1.put("instance.name","DelegatorNullable");
+ ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
+ "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
+
+
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+ assertNotNull(ref);
+ CheckService cs = (CheckService) context.getService(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();
+ }
+
+
+ public void testGetAndDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider1-Proxy");
+ ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Delegator");
+ ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
+ "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
+
+
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+ assertNotNull(ref);
+ CheckService cs = (CheckService) context.getService(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();
+ }
+
+ public void testGetAndDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+ Properties i1 = new Properties();
+ i1.put("instance.name","DelegatorNullable");
+ ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
+ "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
+
+
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+ assertNotNull(ref);
+ CheckService cs = (CheckService) context.getService(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();
+ }
+
+ public void testImmediate() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+ Properties prov = new Properties();
+ prov.put("instance.name","FooProvider1-Proxy");
+ ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Delegator");
+ ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
+ "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
+
+ ServiceReference ref = Utils.getServiceReference(context, CheckService.class.getName(), "(service.pid=Helper)");
+ assertNotNull(ref);
+ CheckService cs = (CheckService) context.getService(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();
+ }
+
+ public void testImmediateNoService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Delegator");
+ ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
+ "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
+
+ ServiceReference ref = Utils.getServiceReference(context, CheckService.class.getName(), "(service.pid=Helper)");
+ assertNotNull(ref);
+ CheckService cs = (CheckService) context.getService(ref);
+
+ try {
+ cs.getProps();
+ fail("Exception expected");
+ } catch(RuntimeException e) {
+ //OK
+ }
+
+ instance1.dispose();
+ }
+
+ 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 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+
+
+ Properties i1 = new Properties();
+ i1.put("instance.name","Delegator");
+ ComponentInstance instance1 = Utils.getFactoryByName(getContext(),
+ "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
+
+
+ ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+ assertNotNull(ref);
+ CheckService cs = (CheckService) context.getService(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);
+
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java
new file mode 100644
index 0000000..9d2c736
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java
@@ -0,0 +1,31 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+import org.osgi.framework.BundleContext;
+
+public class CheckServiceDelegator implements CheckService {
+
+ private FooService fs;
+
+ private Helper helper;
+
+ public CheckServiceDelegator(BundleContext bc) {
+ helper = new Helper(bc, fs);
+ }
+
+ public boolean check() {
+ // Don't access the service
+ // Just delegate
+ return helper.check();
+ }
+
+ public Properties getProps() {
+ // Don't access the service
+ // Just delegate
+ return helper.getProps();
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java
new file mode 100644
index 0000000..7f8be1e
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java
@@ -0,0 +1,29 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+import org.osgi.framework.BundleContext;
+
+public class CheckServiceGetAndDelegate implements CheckService {
+
+ private FooService fs;
+
+ private Helper helper;
+
+ public CheckServiceGetAndDelegate(BundleContext bc) {
+ helper = new Helper(bc, fs);
+ }
+
+ public boolean check() {
+ fs.foo();
+ return helper.check();
+ }
+
+ public Properties getProps() {
+ fs.getBoolean();
+ return helper.getProps();
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java
new file mode 100644
index 0000000..a72e313
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java
@@ -0,0 +1,42 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+import org.osgi.framework.BundleContext;
+
+public class CheckServiceNoDelegate implements CheckService {
+
+ private FooService fs;
+
+ private Helper helper;
+
+ private BundleContext context;
+
+ public CheckServiceNoDelegate(BundleContext bc) {
+ context = bc;
+ helper = new Helper(context, fs);
+ }
+
+ public void start() {
+ helper.publish();
+ }
+
+ public void stop() {
+ helper.unpublish();
+ }
+
+ public boolean check() {
+ // Don't access the service
+ // Just delegate
+ return helper.check();
+ }
+
+ public Properties getProps() {
+ // Don't access the service
+ // Just delegate
+ return helper.getProps();
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java
new file mode 100644
index 0000000..c2f0f29
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java
@@ -0,0 +1,47 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+
+public class Helper implements CheckService {
+
+
+ private FooService fs;
+ private BundleContext context;
+ private ServiceRegistration reg;
+
+ public Helper(BundleContext bc, FooService svc) {
+ fs = svc;
+ context = bc;
+ }
+
+ public void publish() {
+ Properties props = new Properties();
+ props.put(Constants.SERVICE_PID, "Helper");
+ reg = context.registerService(CheckService.class.getName(), this, props);
+ }
+
+ public void unpublish() {
+ if (reg != null) {
+ reg.unregister();
+ }
+ reg = null;
+ }
+
+ public boolean check() {
+ return fs.foo();
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ fs.getBoolean();
+ props.put("helper.fs", fs);
+ return props;
+ }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
index d490139..83fd97b 100644
--- a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
@@ -1,8 +1,8 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
- xmlns="org.apache.felix.ipojo">
+<ipojo>
<!--
-
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
+ xmlns="org.apache.felix.ipojo"
-->
<component
classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"
@@ -14,13 +14,13 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="SimpleCheckServiceProvider" architecture="true">
- <requires field="fs" />
+ <requires field="fs" proxy="false"/>
<provides />
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="VoidCheckServiceProvider" architecture="true">
- <requires field="fs">
+ <requires field="fs" proxy="false">
<callback type="bind" method="voidBind" />
<callback type="unbind" method="voidUnbind" />
</requires>
@@ -29,7 +29,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="ObjectCheckServiceProvider" architecture="true">
- <requires field="fs">
+ <requires field="fs" proxy="false">
<callback type="bind" method="objectBind" />
<callback type="unbind" method="objectUnbind" />
</requires>
@@ -38,7 +38,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="RefCheckServiceProvider" architecture="true">
- <requires field="fs">
+ <requires field="fs" proxy="false">
<callback type="bind" method="refBind" />
<callback type="unbind" method="refUnbind" />
</requires>
@@ -47,7 +47,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="BothCheckServiceProvider" architecture="true">
- <requires field="fs">
+ <requires field="fs" proxy="false">
<callback type="bind" method="bothBind" />
<callback type="unbind" method="bothUnbind" />
</requires>
@@ -56,7 +56,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="MapCheckServiceProvider" architecture="true">
- <requires field="fs">
+ <requires field="fs" proxy="false">
<callback type="bind" method="propertiesMapBind" />
<callback type="unbind" method="propertiesMapUnbind" />
</requires>
@@ -65,12 +65,74 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="DictCheckServiceProvider" architecture="true">
+ <requires field="fs" proxy="false">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedSimpleCheckServiceProvider" architecture="true">
+ <requires field="fs" />
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedVoidCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="voidBind" />
+ <callback type="unbind" method="voidUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedObjectCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="objectBind" />
+ <callback type="unbind" method="objectUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedRefCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="refBind" />
+ <callback type="unbind" method="refUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedBothCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="bothBind" />
+ <callback type="unbind" method="bothUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedMapCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedDictCheckServiceProvider" architecture="true">
<requires field="fs">
<callback type="bind" method="propertiesDictionaryBind" />
<callback type="unbind" method="propertiesDictionaryUnbind" />
</requires>
<provides />
</component>
+
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
@@ -79,6 +141,16 @@
<callback type="bind" method="objectBind" />
<callback type="unbind" method="objectUnbind" />
</requires>
+ <requires field="fs" proxy="true"/>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedDoubleCheckServiceProvider" architecture="true">
+ <requires>
+ <callback type="bind" method="objectBind" />
+ <callback type="unbind" method="objectUnbind" />
+ </requires>
<requires field="fs" />
<provides />
</component>
@@ -134,7 +206,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="SimpleOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true" id="FooService"/>
+ <requires field="fs" optional="true" id="FooService" proxy="false"/>
<provides />
</component>
<component
@@ -146,7 +218,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="VoidOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
+ <requires field="fs" optional="true" proxy="false">
<callback type="bind" method="voidBind" />
<callback type="unbind" method="voidUnbind" />
</requires>
@@ -164,7 +236,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="ObjectOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
+ <requires field="fs" optional="true" proxy="false">
<callback type="bind" method="objectBind" />
<callback type="unbind" method="objectUnbind" />
</requires>
@@ -182,7 +254,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="RefOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
+ <requires field="fs" optional="true" proxy="false">
<callback type="bind" method="refBind" />
<callback type="unbind" method="refUnbind" />
</requires>
@@ -200,7 +272,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="BothOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
+ <requires field="fs" optional="true" proxy="false">
<callback type="bind" method="bothBind" />
<callback type="unbind" method="bothUnbind" />
</requires>
@@ -209,7 +281,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="MapOptionalCheckServiceProvider" architecture="true">
- <requires field="fs" optional="true">
+ <requires field="fs" optional="true" proxy="false">
<callback type="bind" method="propertiesMapBind" />
<callback type="unbind" method="propertiesMapUnbind" />
</requires>
@@ -218,6 +290,67 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
name="DictOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true" proxy="false">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedSimpleOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true" id="FooService"/>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedVoidOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="voidBind" />
+ <callback type="unbind" method="voidUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedObjectOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="objectBind" />
+ <callback type="unbind" method="objectUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedRefOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="refBind" />
+ <callback type="unbind" method="refUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedBothOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="bothBind" />
+ <callback type="unbind" method="bothUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedMapOptionalCheckServiceProvider" architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"
+ name="ProxiedDictOptionalCheckServiceProvider" architecture="true">
<requires field="fs" optional="true">
<callback type="bind" method="propertiesDictionaryBind" />
<callback type="unbind" method="propertiesDictionaryUnbind" />
@@ -440,12 +573,28 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="SimpleMultipleCheckServiceProvider" architecture="true">
- <requires field="fs" />
+ <requires field="fs" proxy="false"/>
<provides />
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedSimpleMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs" />
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="VoidMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs" proxy="false">
+ <callback type="bind" method="voidBind" />
+ <callback type="unbind" method="voidUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedVoidMultipleCheckServiceProvider" architecture="true">
<requires field="fs">
<callback type="bind" method="voidBind" />
<callback type="unbind" method="voidUnbind" />
@@ -455,6 +604,15 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="ObjectMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs" proxy="false">
+ <callback type="bind" method="objectBind" />
+ <callback type="unbind" method="objectUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedObjectMultipleCheckServiceProvider" architecture="true">
<requires field="fs">
<callback type="bind" method="objectBind" />
<callback type="unbind" method="objectUnbind" />
@@ -464,7 +622,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="RefMultipleCheckServiceProvider" architecture="true">
- <requires field="fs">
+ <requires field="fs" proxy="false">
<callback type="bind" method="refBind" />
<callback type="unbind" method="refUnbind" />
</requires>
@@ -472,7 +630,26 @@
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedRefMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="refBind" />
+ <callback type="unbind" method="refUnbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="BothMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs" proxy="false">
+ <callback type="bind" method="bothBind" />
+ <callback type="unbind" method="bothUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedBothMultipleCheckServiceProvider" architecture="true">
<requires field="fs">
<callback type="bind" method="bothBind" />
<callback type="unbind" method="bothUnbind" />
@@ -482,7 +659,7 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="MapMultipleCheckServiceProvider" architecture="true">
- <requires field="fs">
+ <requires field="fs" proxy="false">
<callback type="bind" method="propertiesMapBind" />
<callback type="unbind" method="propertiesMapUnbind" />
</requires>
@@ -490,7 +667,26 @@
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
- name="DictMultipleCheckServiceProvider" architecture="true">
+ name="ProxiedMapMultipleCheckServiceProvider" architecture="true">
+ <requires field="fs">
+ <callback type="bind" method="propertiesMapBind" />
+ <callback type="unbind" method="propertiesMapUnbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="DictMultipleCheckServiceProvider" architecture="true" >
+ <requires field="fs" proxy="false">
+ <callback type="bind" method="propertiesDictionaryBind" />
+ <callback type="unbind" method="propertiesDictionaryUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedDictMultipleCheckServiceProvider" architecture="true">
<requires field="fs">
<callback type="bind" method="propertiesDictionaryBind" />
<callback type="unbind" method="propertiesDictionaryUnbind" />
@@ -551,14 +747,14 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="SimpleOptionalMultipleCheckServiceProvider"
architecture="true">
- <requires field="fs" optional="true" />
+ <requires field="fs" optional="true" proxy="false"/>
<provides />
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="VoidOptionalMultipleCheckServiceProvider"
architecture="true">
- <requires field="fs" optional="true">
+ <requires field="fs" optional="true" proxy="false">
<callback type="bind" method="voidBind" />
<callback type="unbind" method="voidUnbind" />
</requires>
@@ -568,7 +764,7 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="ObjectOptionalMultipleCheckServiceProvider"
architecture="true">
- <requires field="fs" optional="true">
+ <requires field="fs" optional="true" proxy="false">
<callback type="bind" method="objectBind" />
<callback type="unbind" method="objectUnbind" />
</requires>
@@ -578,12 +774,51 @@
classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
name="RefOptionalMultipleCheckServiceProvider"
architecture="true">
+ <requires field="fs" optional="true" proxy="false">
+ <callback type="bind" method="refBind" />
+ <callback type="unbind" method="refUnbind" />
+ </requires>
+ <provides />
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedSimpleOptionalMultipleCheckServiceProvider"
+ architecture="true">
+ <requires field="fs" optional="true" />
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedVoidOptionalMultipleCheckServiceProvider"
+ architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="voidBind" />
+ <callback type="unbind" method="voidUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedObjectOptionalMultipleCheckServiceProvider"
+ architecture="true">
+ <requires field="fs" optional="true">
+ <callback type="bind" method="objectBind" />
+ <callback type="unbind" method="objectUnbind" />
+ </requires>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"
+ name="ProxiedRefOptionalMultipleCheckServiceProvider"
+ architecture="true">
<requires field="fs" optional="true">
<callback type="bind" method="refBind" />
<callback type="unbind" method="refUnbind" />
</requires>
<provides />
</component>
+
<component
classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"
name="MObjectOptionalMultipleCheckServiceProvider"
@@ -611,13 +846,28 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
name="SimpleListCheckServiceProvider" architecture="true">
- <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
+ <requires proxy="false"
+ field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
<provides />
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
name="OptionalListCheckServiceProvider"
architecture="true">
+ <requires proxy="false"
+ specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
+ name="ProxiedSimpleListCheckServiceProvider" architecture="true">
+ <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"
+ name="ProxiedOptionalListCheckServiceProvider"
+ architecture="true">
<requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
<provides />
</component>
@@ -644,13 +894,26 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
name="SimpleSetCheckServiceProvider" architecture="true">
- <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
+ <requires proxy="false" field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
<provides />
</component>
<component
classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
name="OptionalSetCheckServiceProvider"
architecture="true">
+ <requires proxy="false" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
+ name="ProxiedSimpleSetCheckServiceProvider" architecture="true">
+ <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"
+ name="ProxiedOptionalSetCheckServiceProvider"
+ architecture="true">
<requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
<provides />
</component>
@@ -659,6 +922,12 @@
<component
classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
name="SimpleCollectionCheckServiceProvider" architecture="true">
+ <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" proxy="false"/>
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
+ name="ProxiedSimpleCollectionCheckServiceProvider" architecture="true">
<requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>
<provides />
</component>
@@ -666,7 +935,18 @@
classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
name="OptionalCollectionCheckServiceProvider"
architecture="true">
- <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />
+ <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true"
+ proxy="false"
+ />
+ <provides />
+ </component>
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"
+ name="ProxiedOptionalCollectionCheckServiceProvider"
+ architecture="true">
+ <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true"
+ proxy="false"
+ />
<provides />
</component>
@@ -740,5 +1020,21 @@
</requires>
<provides />
</component>
+
+ <!-- Proxy Tests -->
+ <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator">
+ <provides/>
+ <requires field="fs" optional="true"/>
+ </component>
+ <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate">
+ <provides/>
+ <requires field="fs" optional="true"/>
+ </component>
+ <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate">
+ <provides/>
+ <requires field="fs" optional="true"/>
+ <callback transition="validate" method="start"/>
+ <callback transition="invalidate" method="stop"/>
+ </component>
</ipojo>
diff --git a/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml b/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml
index 901cede..bb892b3 100755
--- a/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml
@@ -3,33 +3,33 @@
xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"
xmlns="org.apache.felix.ipojo"
>
- <!-- Simple provider -->
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"
- name="PSS-FooProviderType-Instance" architecture="true">
- <provides strategy="instance"/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.Consumer"
- name="PSS-Cons" architecture="true">
- <requires field="fs"/>
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.BarConsumer"
- name="PSS-ConsBar" architecture="true">
- <requires field="bs"/>
- <provides/>
- </component>
-
- <component
- classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1"
- name="PSS-FooBarProviderType-Instance" architecture="true">
- <provides strategy="instance"/>
- </component>
-
+ <!-- Simple provider -->
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"
+ name="PSS-FooProviderType-Instance" architecture="true">
+ <provides strategy="instance"/>
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.strategies.Consumer"
+ name="PSS-Cons" architecture="true">
+ <requires field="fs" proxy="false"/>
+ <provides/>
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.strategies.BarConsumer"
+ name="PSS-ConsBar" architecture="true">
+ <requires field="bs" proxy="false"/>
+ <provides/>
+ </component>
+
+ <component
+ classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1"
+ name="PSS-FooBarProviderType-Instance" architecture="true">
+ <provides strategy="instance"/>
+ </component>
+
<component
classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"
name="PSS-FooProviderType-Custom" architecture="true">