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

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit 6cf348211a23835128465a22c9148138fb99c060
Author: Alex Herbert <aherb...@apache.org>
AuthorDate: Thu Dec 5 21:21:27 2019 +0000

    [CODEC-259] Test StringUtils.getByteBufferUtf8.
    
    This method was only used in Hex. Its usage has been removed so this
    simple test ensures the method does what it is documented to do.
---
 .../java/org/apache/commons/codec/binary/StringUtilsTest.java  | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java 
b/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
index acfc80a..67040d4 100644
--- a/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java
@@ -18,6 +18,8 @@
 package org.apache.commons.codec.binary;
 
 import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 
 import org.junit.Assert;
@@ -236,4 +238,12 @@ public class StringUtilsTest {
         Assert.assertFalse(StringUtils.equals("abcd", new 
StringBuilder("abc")));
         Assert.assertFalse(StringUtils.equals(new StringBuilder("abc"), 
"ABC"));
     }
+
+    @Test
+    public void testByteBufferUtf8() {
+        Assert.assertNull("Should be null safe", 
StringUtils.getByteBufferUtf8(null));
+        final String text = "asdhjfhsadiogasdjhagsdygfjasfgsdaksjdhfk";
+        final ByteBuffer bb = StringUtils.getByteBufferUtf8(text);
+        Assert.assertArrayEquals(text.getBytes(StandardCharsets.UTF_8), 
bb.array());
+    }
 }

Reply via email to