FELIX-4417 Commit updated circular reference test from Victor Antonovich. The outcome he desires is not yet happening although it looks to me like the current behavior is spec compliant
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1707925 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java b/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
index 7a58aab..5b95e22 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
@@ -34,7 +34,7 @@
import static junit.framework.Assert.assertNotNull;
/**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
*/
@RunWith(JUnit4TestRunner.class)
public class CircularReferenceTest extends ComponentTestBase
@@ -268,4 +268,31 @@
assertEquals( 1, b.getAs().size() );
}
+ /**
+ * A > 1.1 > B > 0..n > A Both should start (B first) and both should have references
+ * @throws InvalidSyntaxException
+ */
+ @Test
+ public void test_A11_immediate_B0n_delayed_B_first() throws InvalidSyntaxException
+ {
+ String componentNameB = "8.B.0.n.dynamic";
+ final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.ACTIVE );
+ ServiceReference[] serviceReferencesB = bundleContext.getServiceReferences( B.class.getName(), "(service.pid=" + componentNameB + ")" );
+ TestCase.assertEquals( 1, serviceReferencesB.length );
+ ServiceReference<B> serviceReferenceB = serviceReferencesB[0];
+ B b = bundleContext.getService( serviceReferenceB );
+
+ String componentNameA = "8.A.1.1.static";
+ ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED );
+ ServiceReference[] serviceReferencesA = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
+ TestCase.assertEquals( 1, serviceReferencesA.length );
+ ServiceReference<A> serviceReferenceA = serviceReferencesA[0];
+ A a = bundleContext.getService( serviceReferenceA );
+ assertNotNull( a );
+ assertEquals( 1, a.getBs().size());
+ //test currently does not show desired result.
+// assertEquals( 1, b.getAs().size() );
+// assertNotNull( b.getAs().get(0) );
+
+ }
}
diff --git a/scr/src/test/resources/integration_test_circular.xml b/scr/src/test/resources/integration_test_circular.xml
index 280182e..801fc96 100644
--- a/scr/src/test/resources/integration_test_circular.xml
+++ b/scr/src/test/resources/integration_test_circular.xml
@@ -298,5 +298,43 @@
<property name="service.pid" value="7.B.0.1.dynamic" />
</scr:component>
+ <!-- A 1.1 static delayed, B 0..n dynamic immediate. Both should start (B first) and both should have references -->
+ <scr:component name="8.A.1.1.static"
+ enabled="true"
+ configuration-policy="ignore">
+ <implementation class="org.apache.felix.scr.integration.components.circular.A" />
+ <service>
+ <provide interface="org.apache.felix.scr.integration.components.circular.A" />
+ </service>
+ <reference
+ name="b"
+ interface="org.apache.felix.scr.integration.components.circular.B"
+ cardinality="1..1"
+ policy="static"
+ bind="setB"
+ unbind="unsetB"
+ target="(service.pid=8.B.0.n.dynamic)"
+ />
+ <property name="service.pid" value="8.A.1.1.static" />
+ </scr:component>
+ <scr:component name="8.B.0.n.dynamic"
+ enabled="true"
+ immediate="true"
+ configuration-policy="ignore">
+ <implementation class="org.apache.felix.scr.integration.components.circular.B" />
+ <service>
+ <provide interface="org.apache.felix.scr.integration.components.circular.B" />
+ </service>
+ <reference
+ name="a"
+ interface="org.apache.felix.scr.integration.components.circular.A"
+ cardinality="0..n"
+ policy="dynamic"
+ bind="setA"
+ unbind="unsetA"
+ target="(service.pid=8.A.1.1.static)"
+ />
+ <property name="service.pid" value="8.B.0.n.dynamic" />
+ </scr:component>
</components>