You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/05/03 00:29:32 UTC

[skywalking] branch master updated: Added Unit Tests to increase code coverage (#2571)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new ac2cc73  Added Unit Tests to increase code coverage (#2571)
ac2cc73 is described below

commit ac2cc7339de628feb9ae168219d8e0deff8d6194
Author: Michael Hausegger <ha...@googlemail.com>
AuthorDate: Fri May 3 02:29:24 2019 +0200

    Added Unit Tests to increase code coverage (#2571)
---
 .../org/apache/skywalking/apm/util/StringUtilTest.java    | 15 ++++++++++++++-
 .../library/util/PropertyPlaceholderHelperTest.java       | 13 +++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

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 f4a0b8d..b918e2e 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 53bcc55..0771e8f 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.