From 2e75c0addaf824e47ddf69658a0e3f2e99139066 Mon Sep 17 00:00:00 2001 From: Huxing Zhang Date: Mon, 11 Mar 2019 10:53:42 +0800 Subject: [PATCH] Add UT to ConfigurationUtilsTest --- .../common/config/ConfigurationUtilsTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/dubbo-common/src/test/java/org/apache/dubbo/common/config/ConfigurationUtilsTest.java b/dubbo-common/src/test/java/org/apache/dubbo/common/config/ConfigurationUtilsTest.java index 89da34c26d1..a16a3748310 100644 --- a/dubbo-common/src/test/java/org/apache/dubbo/common/config/ConfigurationUtilsTest.java +++ b/dubbo-common/src/test/java/org/apache/dubbo/common/config/ConfigurationUtilsTest.java @@ -21,6 +21,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.Map; + /** * */ @@ -39,4 +41,29 @@ public void testGetProperty () { Assertions.assertEquals("10000", ConfigurationUtils.getProperty(Constants.SHUTDOWN_WAIT_KEY)); System.clearProperty(Constants.SHUTDOWN_WAIT_KEY); } + + @Test + public void testParseSingleProperties() throws Exception { + String p1 = "aaa=bbb"; + Map result = ConfigurationUtils.parseProperties(p1); + Assertions.assertEquals(1, result.size()); + Assertions.assertEquals("bbb", result.get("aaa")); + } + + @Test + public void testParseMultipleProperties() throws Exception { + String p1 = "aaa=bbb\nccc=ddd"; + Map result = ConfigurationUtils.parseProperties(p1); + Assertions.assertEquals(2, result.size()); + Assertions.assertEquals("bbb", result.get("aaa")); + Assertions.assertEquals("ddd", result.get("ccc")); + } + + @Test + public void testEscapedNewLine() throws Exception { + String p1 = "dubbo.registry.address=zookeeper://127.0.0.1:2181\\\\ndubbo.protocol.port=20880"; + Map result = ConfigurationUtils.parseProperties(p1); + Assertions.assertEquals(1, result.size()); + Assertions.assertEquals("zookeeper://127.0.0.1:2181\\ndubbo.protocol.port=20880", result.get("dubbo.registry.address")); + } }