Add test cases with spaces in values
diff --git a/configadmin/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java b/configadmin/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java
index d24bb8b..831b225 100644
--- a/configadmin/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java
+++ b/configadmin/src/test/java/org/apache/felix/cm/file/ConfigurationHandlerTest.java
@@ -104,6 +104,16 @@
}
@Test
+ public void test_writeStringWithSpaces() throws IOException {
+ OutputStream out = new ByteArrayOutputStream();
+ Dictionary< String, String> properties = new Hashtable<>();
+ properties.put("prop", "Hello World");
+ ConfigurationHandler.write(out, properties);
+ String entry = new String(((ByteArrayOutputStream)out).toByteArray(),"UTF-8");
+ Assert.assertEquals("prop=\"Hello\\ World\"\r\n", entry);
+ }
+
+ @Test
public void test_writeInteger() throws IOException {
OutputStream out = new ByteArrayOutputStream();
Dictionary< String, Integer> properties = new Hashtable<>();
@@ -237,6 +247,16 @@
}
@Test
+ public void test_readStringWithSpaces() throws IOException {
+ String entry = "prop=\"Hello\\ World\"\r\n";
+ InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));
+ @SuppressWarnings("unchecked")
+ Dictionary<String, Object> dictionary = ConfigurationHandler.read(stream);
+ Assert.assertEquals(1, dictionary.size());
+ Assert.assertEquals( "Hello World", dictionary.get("prop"));
+ }
+
+ @Test
public void test_readSimpleStrings() throws IOException {
String entry = "service.pid=\"com.adobe.granite.foo.Bar\"\r\nfoo.bar=\"com.adobe.granite.foo.Baz\"\r\n";
InputStream stream = new ByteArrayInputStream(entry.getBytes(StandardCharsets.UTF_8));