Skip to content

Commit

Permalink
Add UT to ConfigurationUtilsTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ralf0131 committed Mar 11, 2019
1 parent 82022b6 commit 2e75c0a
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Map;

/**
*
*/
Expand All @@ -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<String, String> 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<String, String> 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<String, String> 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"));
}
}

0 comments on commit 2e75c0a

Please sign in to comment.