Add test cases with spaces in values
@@ -103,6 +103,16 @@ public class ConfigurationHandlerTest {
Assert.assertEquals("service.pid=\"com.adobe.granite.foo.Bar\"\r\n", entry);
}
+ @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();
@@ -236,6 +246,16 @@ public class ConfigurationHandlerTest {
Assert.assertEquals( "com.adobe.granite.foo.Bar", dictionary.get(SERVICE_PID));
}
+ @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";
