You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2021/02/01 07:30:43 UTC
[felix-dev] branch master updated: Add test cases with spaces in
values
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 0aa232a Add test cases with spaces in values
0aa232a is described below
commit 0aa232a4ff8f95e92d947027ac7d8010e2a0e142
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 1 08:30:18 2021 +0100
Add test cases with spaces in values
---
.../felix/cm/file/ConfigurationHandlerTest.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
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 @@ public class ConfigurationHandlerTest {
}
@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 @@ public class ConfigurationHandlerTest {
}
@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));