You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/01/25 19:24:36 UTC
svn commit: r1235862 - in /karaf/cellar/trunk/config/src:
main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
test/java/org/apache/karaf/cellar/config/ConfigurationSupportTest.java
Author: jbonofre
Date: Wed Jan 25 18:24:36 2012
New Revision: 1235862
URL: http://svn.apache.org/viewvc?rev=1235862&view=rev
Log:
[KARAF-1147] Fix ClassCastException in Cellar config
Modified:
karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
karaf/cellar/trunk/config/src/test/java/org/apache/karaf/cellar/config/ConfigurationSupportTest.java
Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java?rev=1235862&r1=1235861&r2=1235862&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/ConfigurationSupport.java Wed Jan 25 18:24:36 2012
@@ -44,8 +44,8 @@ public class ConfigurationSupport extend
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
if (key != null && dictionary.get(key) != null) {
- String value = (String) dictionary.get(key);
- properties.put(key, dictionary.get(key));
+ String value = String.valueOf(dictionary.get(key));
+ properties.put(key, value);
}
}
}
@@ -64,9 +64,9 @@ public class ConfigurationSupport extend
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
if (key != null && dictionary.get(key) != null) {
- String value = (String) dictionary.get(key);
+ String value = String.valueOf(dictionary.get(key));
value = convertStrings(value, HOME, RELATIVE_HOME);
- properties.put(key, dictionary.get(key));
+ properties.put(key, value);
}
}
return properties;
@@ -84,9 +84,9 @@ public class ConfigurationSupport extend
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
if (key != null && dictionary.get(key) != null) {
- String value = (String) dictionary.get(key);
+ String value = String.valueOf(dictionary.get(key));
value = convertStrings(value, RELATIVE_HOME, HOME);
- properties.put(key, dictionary.get(key));
+ properties.put(key, value);
}
}
return properties;
@@ -113,7 +113,7 @@ public class ConfigurationSupport extend
while (enumaration.hasMoreElements()) {
String key = (String) enumaration.nextElement();
if (!isPropertyFiltered(key)) {
- String value = (String) dictionary.get(key);
+ String value = String.valueOf(dictionary.get(key));
result.put(key, value);
}
}
Modified: karaf/cellar/trunk/config/src/test/java/org/apache/karaf/cellar/config/ConfigurationSupportTest.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/test/java/org/apache/karaf/cellar/config/ConfigurationSupportTest.java?rev=1235862&r1=1235861&r2=1235862&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/test/java/org/apache/karaf/cellar/config/ConfigurationSupportTest.java (original)
+++ karaf/cellar/trunk/config/src/test/java/org/apache/karaf/cellar/config/ConfigurationSupportTest.java Wed Jan 25 18:24:36 2012
@@ -57,4 +57,46 @@ public class ConfigurationSupportTest {
Assert.assertEquals(expectedResult, result);
}
+ @Test
+ public void testPreparePull() throws Exception {
+ Dictionary result = null;
+ Dictionary source = new Properties();
+ Dictionary expectedResult = new Properties();
+
+ source.put("key1", "value1");
+ source.put("key2", 1);
+ source.put("key3", Boolean.FALSE);
+ source.put("key4", 12L);
+
+ expectedResult.put("key1", "value1");
+ expectedResult.put("key2", "1");
+ expectedResult.put("key3", "false");
+ expectedResult.put("key4", "12");
+
+ result = support.preparePull(source);
+
+ Assert.assertEquals(expectedResult, result);
+ }
+
+ @Test
+ public void testPreparePush() throws Exception {
+ Dictionary result = null;
+ Dictionary source = new Properties();
+ Dictionary expectedResult = new Properties();
+
+ source.put("key1", "value1");
+ source.put("key2", 1);
+ source.put("key3", Boolean.FALSE);
+ source.put("key4", 12L);
+
+ expectedResult.put("key1", "value1");
+ expectedResult.put("key2", "1");
+ expectedResult.put("key3", "false");
+ expectedResult.put("key4", "12");
+
+ result = support.preparePush(source);
+
+ Assert.assertEquals(expectedResult, result);
+ }
+
}