diff --git a/apm-commons/apm-util/src/test/java/org/apache/skywalking/apm/util/StringUtilTest.java b/apm-commons/apm-util/src/test/java/org/apache/skywalking/apm/util/StringUtilTest.java index f4a0b8d068..b918e2e4b3 100644 --- a/apm-commons/apm-util/src/test/java/org/apache/skywalking/apm/util/StringUtilTest.java +++ b/apm-commons/apm-util/src/test/java/org/apache/skywalking/apm/util/StringUtilTest.java @@ -39,5 +39,18 @@ public class StringUtilTest { Assert.assertNull(StringUtil.join('.')); Assert.assertEquals("Single part.", StringUtil.join('.', "Single part.")); Assert.assertEquals("part1.part2.p3", StringUtil.join('.', "part1", "part2", "p3")); + Assert.assertEquals("E", StringUtil.join('E', new String[2])); } -} + + @Test + public void testSubstringMatchReturningTrue() { + StringBuffer stringBuffer = new StringBuffer("ZP~>xz1;"); + Assert.assertTrue(StringUtil.substringMatch(stringBuffer, 0, stringBuffer)); + } + + @Test + public void testSubstringMatchWithPositive() { + Assert.assertFalse(StringUtil.substringMatch("", 4770, "")); + } + +} \ No newline at end of file diff --git a/oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/PropertyPlaceholderHelperTest.java b/oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/PropertyPlaceholderHelperTest.java index 53bcc55f1b..0771e8f331 100644 --- a/oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/PropertyPlaceholderHelperTest.java +++ b/oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/PropertyPlaceholderHelperTest.java @@ -80,6 +80,19 @@ public class PropertyPlaceholderHelperTest { yaml.load(placeholderHelper.replacePlaceholders(properties.getProperty("restPort"), properties))); } + @Test + public void testReplacePlaceholders() { + PropertyPlaceholderHelper propertyPlaceholderHelper = PropertyPlaceholderHelper.INSTANCE; + Properties properties = new Properties(); + String resultString = propertyPlaceholderHelper.replacePlaceholders("&${[}7", properties); + + Assert.assertEquals(0, properties.size()); + Assert.assertTrue(properties.isEmpty()); + + Assert.assertNotNull(resultString); + Assert.assertEquals("&${[}7", resultString); + } + @After public void afterTest() { //revert environment variables changes after the test for safe.