This is an automated email from the ASF dual-hosted git repository.
pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git
The following commit(s) were added to refs/heads/master by this push:
new 05d3975 Add unit tests for org.apache.jorphan.util.JOrphanUtils (#472)
05d3975 is described below
commit 05d39754aa31e17e40d3425c2fefb65e39d1ef34
Author: John Bergqvist <[email protected]>
AuthorDate: Wed Jul 10 18:02:04 2019 +0100
Add unit tests for org.apache.jorphan.util.JOrphanUtils (#472)
These tests were written using Diffblue Cover
---
.../org/apache/jorphan/util/TestJorphanUtils.java | 45 ++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/test/src/org/apache/jorphan/util/TestJorphanUtils.java
b/test/src/org/apache/jorphan/util/TestJorphanUtils.java
index 9bd5133..3d9189f 100644
--- a/test/src/org/apache/jorphan/util/TestJorphanUtils.java
+++ b/test/src/org/apache/jorphan/util/TestJorphanUtils.java
@@ -256,6 +256,12 @@ public class TestJorphanUtils {
}
@Test
+ public void testGetByteArraySlice() throws Exception {
+ Assert.assertArrayEquals(new byte[] {1, 2},
+ JOrphanUtils.getByteArraySlice(new byte[]{0, 1, 2, 3}, 1, 2));
+ }
+
+ @Test
public void testbaToHexString(){
assertEquals("",JOrphanUtils.baToHexString(new byte[]{}));
assertEquals("00",JOrphanUtils.baToHexString(new byte[]{0}));
@@ -263,6 +269,13 @@ public class TestJorphanUtils {
}
@Test
+ public void testBaToHexStringSeparator(){
+ assertEquals("", JOrphanUtils.baToHexString(new byte[]{}, '-'));
+ assertEquals("00", JOrphanUtils.baToHexString(new byte[]{0}, '-'));
+ assertEquals("0f-10-7f-80-81-ff", JOrphanUtils.baToHexString(new
byte[]{15,16,127,-128,-127,-1}, '-'));
+ }
+
+ @Test
public void testbaToByte() throws Exception{
assertEqualsArray(new byte[]{},JOrphanUtils.baToHexBytes(new
byte[]{}));
assertEqualsArray(new byte[]{'0','0'},JOrphanUtils.baToHexBytes(new
byte[]{0}));
@@ -278,6 +291,13 @@ public class TestJorphanUtils {
}
@Test
+ public void testNullifyIfEmptyTrimmed() {
+ Assert.assertNull(JOrphanUtils.nullifyIfEmptyTrimmed(null));
+ Assert.assertNull(JOrphanUtils.nullifyIfEmptyTrimmed("\u0001"));
+ assertEquals("1234", JOrphanUtils.nullifyIfEmptyTrimmed("1234"));
+ }
+
+ @Test
public void testIsBlank() {
assertTrue(JOrphanUtils.isBlank(""));
assertTrue(JOrphanUtils.isBlank(null));
@@ -295,6 +315,24 @@ public class TestJorphanUtils {
assertEquals("baulpismuth", JOrphanUtils.rightAlign(in, 6).toString());
in = new StringBuilder("A");
assertEquals(" A", JOrphanUtils.rightAlign(in, 8).toString());
+ assertEquals(" foo",
+ JOrphanUtils.rightAlign(new StringBuilder("foo"), 39).toString());
+ }
+
+ @Test
+ public void testLeftAlign() {
+ assertEquals("foo ",
+ JOrphanUtils.leftAlign(new StringBuilder("foo"), 5).toString());
+ assertEquals("foo",
+ JOrphanUtils.leftAlign(new StringBuilder("foo"), 2).toString());
+ assertEquals("foo ",
+ JOrphanUtils.leftAlign(new StringBuilder("foo"), 39).toString());
+ }
+
+ @Test
+ public void testBooleanToSTRING() {
+ assertEquals("TRUE", JOrphanUtils.booleanToSTRING(true));
+ assertEquals("FALSE", JOrphanUtils.booleanToSTRING(false));
}
@Test
@@ -357,4 +395,11 @@ public class TestJorphanUtils {
public void testReplaceValueWithNullSetterThatGetsCalled() {
JOrphanUtils.replaceValue("\\d+", "${port}", true, "80", null);
}
+
+ @Test
+ public void testUnsplit() {
+ assertEquals("", JOrphanUtils.unsplit(new Object[] {null, null}, 0));
+ assertEquals("11", JOrphanUtils.unsplit(new Object[] {null, 1}, 1));
+ assertEquals("-26738698", JOrphanUtils.unsplit(new Object[]
{-26_738_698}, 1));
+ }
}