FELIX-4964 Activate a component at most once from a service event
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1691760 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
index d6f60bf..9854c33 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
@@ -374,7 +374,7 @@
Collection<ServiceReference<S>> srs;
try {
srs = bundleContext.getServiceReferences(clazz, filter);
- Assert.assertEquals(1, srs.size());
+ Assert.assertEquals("Nothing for filter: " + filter, 1, srs.size());
ServiceReference<S> sr = srs.iterator().next();
S s = bundleContext.getService(sr);
Assert.assertNotNull(s);
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java b/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java
index 6674ee4..cd01550 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java
@@ -46,18 +46,20 @@
{
bundleContext.registerService( Object.class, new Object(), null );
- findComponentConfigurationByName( "AsyncLocate", ComponentConfigurationDTO.ACTIVE );
+ findComponentConfigurationByName( "Consumer", ComponentConfigurationDTO.ACTIVE );
- final String pid = "SimpleComponent";
+ final String pid = "TestComponent";
Configuration config = getConfigurationAdmin().getConfiguration( pid, null );
final Hashtable props = new Hashtable();
+ //wrong target property, will not bind
props.put( "target", "bar" );
config.update(props);
delay();
//when deadlock is present the state is actually unsatisfied.
- ComponentConfigurationDTO cc = findComponentConfigurationByName( pid, ComponentConfigurationDTO.ACTIVE );
- delay();
+ ComponentConfigurationDTO cc = findComponentConfigurationByName( pid, ComponentConfigurationDTO.SATISFIED );
+// delay();
+ //correct target property: will bind as new properties are propagated.
props.put( "target", "foo" );
config.update(props);
delay();
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/deadlock/Consumer.java b/scr/src/test/java/org/apache/felix/scr/integration/components/deadlock/Consumer.java
index b99d824..4673cdb 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/components/deadlock/Consumer.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/deadlock/Consumer.java
@@ -31,12 +31,12 @@
this.cc = cc;
}
- protected void setSimpleComponent(TestComponent sc)
+ protected void setTestComponent(TestComponent tc)
{
- sc.doIt( );
+ tc.doIt( );
}
- protected void unsetSimpleComponent(ServiceReference<TestComponent> sr)
+ protected void unsetTestComponent(ServiceReference<TestComponent> sr)
{
}
diff --git a/scr/src/test/resources/integration_test_locate.xml b/scr/src/test/resources/integration_test_locate.xml
index 1ca586e..9e285c8 100644
--- a/scr/src/test/resources/integration_test_locate.xml
+++ b/scr/src/test/resources/integration_test_locate.xml
@@ -11,7 +11,7 @@
language governing permissions and limitations under the License. -->
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
- <scr:component name="SimpleComponent"
+ <scr:component name="TestComponent"
configuration-policy="require">
<implementation class="org.apache.felix.scr.integration.components.deadlock.TestComponent" />
<service>
@@ -28,17 +28,17 @@
</scr:component>
- <scr:component name="AsyncLocate"
+ <scr:component name="Consumer"
immediate="true">
<implementation class="org.apache.felix.scr.integration.components.deadlock.Consumer" />
<reference
- name="SimpleComponent"
+ name="TestComponent"
interface="org.apache.felix.scr.integration.components.deadlock.TestComponent"
cardinality="0..1"
policy="dynamic"
- bind="setSimpleComponent"
- unbind="unsetSimpleComponent"
- target='target="foo"'
+ bind="setTestComponent"
+ unbind="unsetTestComponent"
+ target='(target=foo)'
/>
</scr:component>