Skip to content

Commit 2e75c0a

Browse files
committed
Add UT to ConfigurationUtilsTest
1 parent 82022b6 commit 2e75c0a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

dubbo-common/src/test/java/org/apache/dubbo/common/config/ConfigurationUtilsTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.junit.jupiter.api.Assertions;
2222
import org.junit.jupiter.api.Test;
2323

24+
import java.util.Map;
25+
2426
/**
2527
*
2628
*/
@@ -39,4 +41,29 @@ public void testGetProperty () {
3941
Assertions.assertEquals("10000", ConfigurationUtils.getProperty(Constants.SHUTDOWN_WAIT_KEY));
4042
System.clearProperty(Constants.SHUTDOWN_WAIT_KEY);
4143
}
44+
45+
@Test
46+
public void testParseSingleProperties() throws Exception {
47+
String p1 = "aaa=bbb";
48+
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
49+
Assertions.assertEquals(1, result.size());
50+
Assertions.assertEquals("bbb", result.get("aaa"));
51+
}
52+
53+
@Test
54+
public void testParseMultipleProperties() throws Exception {
55+
String p1 = "aaa=bbb\nccc=ddd";
56+
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
57+
Assertions.assertEquals(2, result.size());
58+
Assertions.assertEquals("bbb", result.get("aaa"));
59+
Assertions.assertEquals("ddd", result.get("ccc"));
60+
}
61+
62+
@Test
63+
public void testEscapedNewLine() throws Exception {
64+
String p1 = "dubbo.registry.address=zookeeper://127.0.0.1:2181\\\\ndubbo.protocol.port=20880";
65+
Map<String, String> result = ConfigurationUtils.parseProperties(p1);
66+
Assertions.assertEquals(1, result.size());
67+
Assertions.assertEquals("zookeeper://127.0.0.1:2181\\ndubbo.protocol.port=20880", result.get("dubbo.registry.address"));
68+
}
4269
}

0 commit comments

Comments
 (0)