Fix FELIX-3192
Propagated service properties must be updated when propagated a second times
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1195532 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/tests/core/configuration/pom.xml b/ipojo/tests/core/configuration/pom.xml
index b13edfc..c7c1c22 100644
--- a/ipojo/tests/core/configuration/pom.xml
+++ b/ipojo/tests/core/configuration/pom.xml
@@ -18,12 +18,12 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>ipojo.tests</groupId>
- <artifactId>ipojo.tests</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
+ <parent>
+ <groupId>ipojo.tests</groupId>
+ <artifactId>ipojo.tests</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
<modelVersion>4.0.0</modelVersion>
<packaging>bundle</packaging>
@@ -35,6 +35,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo</artifactId>
+ <version>${ipojo.core.snapshot}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
@@ -45,10 +46,10 @@
<artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.0.0</version>
- </dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.0.0</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
diff --git a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java
index 754d33a..92997b2 100644
--- a/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java
+++ b/ipojo/tests/core/configuration/src/main/java/org/apache/felix/ipojo/test/scenarios/configuration/ManagedServiceConfigurableProperties.java
@@ -113,8 +113,8 @@
assertEquals("Check baz equality -2", bazP, "zab");
getContext().ungetService(msRef);
}
-
- public void testStaticInstance2() {
+
+ public void testStaticInstance2() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
assertNotNull("Check FS availability", fooRef);
String fooP = (String) fooRef.getProperty("foo");
@@ -123,11 +123,11 @@
assertEquals("Check foo equality -1", fooP, "foo");
assertEquals("Check bar equality -1", barP, new Integer(2));
assertEquals("Check baz equality -1", bazP, "baz");
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
assertNotNull("Check ManagedService availability", msRef);
-
-
+
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -137,7 +137,7 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
@@ -149,7 +149,7 @@
getContext().ungetService(fooRef);
getContext().ungetService(msRef);
}
-
+
public void testStaticInstance3() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
assertNotNull("Check FS availability", fooRef);
@@ -160,11 +160,11 @@
assertEquals("Check foo equality -1", fooP, null);
assertEquals("Check bar equality -1", barP, null);
assertEquals("Check baz equality -1", bazP, null);
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance-3");
assertNotNull("Check ManagedService availability", msRef);
-
-
+
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -174,7 +174,7 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
@@ -186,22 +186,22 @@
getContext().ungetService(fooRef);
getContext().ungetService(msRef);
}
-
+
public void testDynamicInstance1() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
assertNotNull("Check FS availability", fooRef);
-
+
String fooP = (String) fooRef.getProperty("foo");
Integer barP = (Integer) fooRef.getProperty("bar");
String bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "foo");
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "baz");
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
assertNotNull("Check ManagedServiceFactory availability", msRef);
-
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -211,45 +211,45 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Re-check props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
barP = (Integer) fooRef.getProperty("bar");
bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "oof");
assertEquals("Check bar equality", barP, new Integer(0));
assertEquals("Check baz equality", bazP, "zab");
-
+
// Check field value
FooService fs = (FooService) getContext().getService(fooRef);
Properties p = fs.fooProps();
fooP = (String) p.get("foo");
barP = (Integer) p.get("bar");
-
+
assertEquals("Check foo field equality", fooP, "oof");
assertEquals("Check bar field equality", barP, new Integer(0));
-
+
getContext().ungetService(fooRef);
getContext().ungetService(msRef);
}
-
+
public void testDynamicInstance2() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
assertNotNull("Check FS availability", fooRef);
-
+
String fooP = (String) fooRef.getProperty("foo");
Integer barP = (Integer) fooRef.getProperty("bar");
String bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "foo");
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "baz");
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
assertNotNull("Check ManagedServiceFactory availability", msRef);
-
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -259,34 +259,34 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
barP = (Integer) fooRef.getProperty("bar");
bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "oof");
assertEquals("Check bar equality", barP, new Integer(0));
assertEquals("Check baz equality", bazP, "zab");
-
+
// Check field value
FooService fs = (FooService) getContext().getService(fooRef);
Properties p = fs.fooProps();
fooP = (String) p.get("foo");
barP = (Integer) p.get("bar");
-
+
assertEquals("Check foo field equality", fooP, "oof");
assertEquals("Check bar field equality", barP, new Integer(0));
-
+
getContext().ungetService(fooRef);
getContext().ungetService(msRef);
}
-
+
public void testDynamicInstance3() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
assertNotNull("Check FS availability", fooRef);
-
+
Object fooP = fooRef.getProperty("foo");
Object barP = fooRef.getProperty("bar");
Object bazP = fooRef.getProperty("baz");
@@ -294,10 +294,10 @@
assertEquals("Check foo equality", fooP, null);
assertEquals("Check bar equality", barP, null);
assertEquals("Check baz equality", bazP, null);
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance-3");
assertNotNull("Check ManagedServiceFactory availability", msRef);
-
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -307,26 +307,26 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
barP = (Integer) fooRef.getProperty("bar");
bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "oof");
assertEquals("Check bar equality", barP, new Integer(0));
assertEquals("Check baz equality", bazP, "zab");
-
+
// Check field value
FooService fs = (FooService) getContext().getService(fooRef);
Properties p = fs.fooProps();
fooP = (String) p.get("foo");
barP = (Integer) p.get("bar");
-
+
assertEquals("Check foo field equality", fooP, "oof");
assertEquals("Check bar field equality", barP, new Integer(0));
-
+
getContext().ungetService(fooRef);
getContext().ungetService(msRef);
}
@@ -335,18 +335,18 @@
assertEquals("Check instance1 state", ComponentInstance.VALID,instance1.getState());
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
assertNotNull("Check FS availability", fooRef);
-
+
String fooP = (String) fooRef.getProperty("foo");
Integer barP = (Integer) fooRef.getProperty("bar");
String bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality - 1", fooP, "foo");
assertEquals("Check bar equality - 1", barP, new Integer(2));
assertEquals("Check baz equality - 1", bazP, "baz");
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
assertNotNull("Check ManagedService availability", msRef);
-
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -354,53 +354,53 @@
conf.put("bar", "0");
assertEquals("Check instance1 state (2)", ComponentInstance.VALID,instance1.getState());
ManagedService ms = (ManagedService) getContext().getService(msRef);
-
+
PrimitiveHandler ph = (PrimitiveHandler) ms;
assertSame("Check the correct instance", ph.getInstanceManager(), instance1);
-
+
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
assertEquals("Check instance1 state (3)", ComponentInstance.VALID,instance1.getState());
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
barP = (Integer) fooRef.getProperty("bar");
bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality - 2", fooP, "oof");
assertEquals("Check bar equality - 2", barP, new Integer(0));
assertEquals("Check baz equality - 2", bazP, "zab");
-
+
// Check field value
FooService fs = (FooService) getContext().getService(fooRef);
Properties p = fs.fooProps();
fooP = (String) p.get("foo");
barP = (Integer) p.get("bar");
-
+
assertEquals("Check foo field equality", fooP, "oof");
assertEquals("Check bar field equality", barP, new Integer(0));
-
+
getContext().ungetService(fooRef);
getContext().ungetService(msRef);
}
-
+
public void testDynamicStringInstance2() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
assertNotNull("Check FS availability", fooRef);
-
+
String fooP = (String) fooRef.getProperty("foo");
Integer barP = (Integer) fooRef.getProperty("bar");
String bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "foo");
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "baz");
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
assertNotNull("Check ManagedService availability", msRef);
-
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -410,45 +410,45 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
barP = (Integer) fooRef.getProperty("bar");
bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "oof");
assertEquals("Check bar equality", barP, new Integer(0));
assertEquals("Check baz equality", bazP, "zab");
-
+
// Check field value
FooService fs = (FooService) getContext().getService(fooRef);
Properties p = fs.fooProps();
fooP = (String) p.get("foo");
barP = (Integer) p.get("bar");
-
+
assertEquals("Check foo field equality", fooP, "oof");
assertEquals("Check bar field equality", barP, new Integer(0));
-
+
getContext().ungetService(fooRef);
getContext().ungetService(msRef);
}
-
+
public void testPropagationInstance1() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
assertNotNull("Check FS availability", fooRef);
-
+
String fooP = (String) fooRef.getProperty("foo");
Integer barP = (Integer) fooRef.getProperty("bar");
String bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "foo");
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "baz");
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "FooProvider-3");
assertNotNull("Check ManagedService availability", msRef);
-
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -460,7 +460,7 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance1.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
@@ -470,31 +470,31 @@
String prop1 = (String) fooRef.getProperty("propagated1");
assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
Integer prop2 = (Integer) fooRef.getProperty("propagated2");
-
+
assertEquals("Check foo equality", fooP, "foo");
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "zab");
assertEquals("Check propagated1 equality", prop1, "propagated");
assertEquals("Check propagated2 equality", prop2, new Integer(1));
-
+
getContext().ungetService(msRef);
}
-
+
public void testPropagationInstance2() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
assertNotNull("Check FS availability", fooRef);
-
+
String fooP = (String) fooRef.getProperty("foo");
Integer barP = (Integer) fooRef.getProperty("bar");
String bazP = (String) fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, "foo");
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "baz");
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance");
assertNotNull("Check ManagedService availability", msRef);
-
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -506,7 +506,7 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance2.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
@@ -516,31 +516,31 @@
String prop1 = (String) fooRef.getProperty("propagated1");
assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
Integer prop2 = (Integer) fooRef.getProperty("propagated2");
-
+
assertEquals("Check foo equality", fooP, "foo");
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "zab");
assertEquals("Check propagated1 equality", prop1, "propagated");
assertEquals("Check propagated2 equality", prop2, new Integer(1));
-
+
getContext().ungetService(msRef);
}
-
+
public void testPropagationInstance3() {
ServiceReference fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
assertNotNull("Check FS availability", fooRef);
-
+
Object fooP = fooRef.getProperty("foo");
Object barP = fooRef.getProperty("bar");
Object bazP = fooRef.getProperty("baz");
-
+
assertEquals("Check foo equality", fooP, null);
assertEquals("Check bar equality", barP, null);
assertEquals("Check baz equality", bazP, null);
-
+
ServiceReference msRef = Utils.getServiceReferenceByPID(getContext(), ManagedService.class.getName(), "instance-3");
assertNotNull("Check ManagedService availability", msRef);
-
+
// Configuration of baz
Properties conf = new Properties();
conf.put("baz", "zab");
@@ -552,7 +552,7 @@
try {
ms.updated(conf);
} catch (ConfigurationException e) { fail("Configuration Exception : " + e); }
-
+
// Recheck props
fooRef = Utils.getServiceReferenceByName(getContext(), FooService.class.getName(), instance3.getInstanceName());
fooP = (String) fooRef.getProperty("foo");
@@ -562,14 +562,16 @@
String prop1 = (String) fooRef.getProperty("propagated1");
assertNotNull("Check the propagated2 existency", fooRef.getProperty("propagated2"));
Integer prop2 = (Integer) fooRef.getProperty("propagated2");
-
+
assertEquals("Check foo equality", fooP, "foo");
assertEquals("Check bar equality", barP, new Integer(2));
assertEquals("Check baz equality", bazP, "zab");
assertEquals("Check propagated1 equality", prop1, "propagated");
assertEquals("Check propagated2 equality", prop2, new Integer(1));
-
+
getContext().ungetService(msRef);
}
+
+
}