commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject [commons-codec] branch release updated: [CODEC-277] Don't reload standard Charsets in org.apache.commons.codec.Charsets.
Date Mon, 30 Dec 2019 14:29:23 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/release by this push:
     new 5241656  [CODEC-277] Don't reload standard Charsets in org.apache.commons.codec.Charsets.
5241656 is described below

commit 5241656633c0b1f098deea410119a3435f41ea59
Author: Gary Gregory <garydgregory@gmail.com>
AuthorDate: Mon Dec 30 09:29:19 2019 -0500

    [CODEC-277] Don't reload standard Charsets in
    org.apache.commons.codec.Charsets.
    
    Use Java 7's java.nio.charset.StandardCharsets instead of our Charsets.
---
 .../java/org/apache/commons/codec/binary/Hex.java  |  3 ++-
 .../apache/commons/codec/binary/StringUtils.java   | 27 +++++++++++-----------
 .../org/apache/commons/codec/digest/Crypt.java     |  5 ++--
 .../org/apache/commons/codec/digest/Md5Crypt.java  | 11 ++++-----
 .../org/apache/commons/codec/digest/Sha2Crypt.java |  5 ++--
 .../org/apache/commons/codec/digest/UnixCrypt.java |  7 +++---
 .../java/org/apache/commons/codec/net/BCodec.java  |  4 ++--
 .../java/org/apache/commons/codec/net/QCodec.java  |  4 ++--
 .../commons/codec/net/QuotedPrintableCodec.java    |  5 ++--
 .../org/apache/commons/codec/CharsetsTest.java     | 13 ++++++-----
 .../apache/commons/codec/binary/Base32Test.java    |  4 ++--
 .../commons/codec/binary/Base64Codec13Test.java    |  4 ++--
 .../apache/commons/codec/binary/Base64Test.java    |  4 ++--
 .../commons/codec/binary/BinaryCodecTest.java      |  4 ++--
 .../org/apache/commons/codec/binary/HexTest.java   |  5 ++--
 .../apache/commons/codec/digest/Apr1CryptTest.java |  6 ++---
 .../apache/commons/codec/digest/Md5CryptTest.java  |  4 ++--
 .../commons/codec/digest/Sha256CryptTest.java      | 16 ++++++-------
 .../commons/codec/digest/Sha512CryptTest.java      | 12 +++++-----
 .../apache/commons/codec/digest/UnixCryptTest.java |  5 ++--
 .../codec/net/QuotedPrintableCodecTest.java        |  8 +++----
 .../org/apache/commons/codec/net/URLCodecTest.java |  8 +++----
 22 files changed, 82 insertions(+), 82 deletions(-)

diff --git a/src/main/java/org/apache/commons/codec/binary/Hex.java b/src/main/java/org/apache/commons/codec/binary/Hex.java
index fa303e9..6a0f038 100644
--- a/src/main/java/org/apache/commons/codec/binary/Hex.java
+++ b/src/main/java/org/apache/commons/codec/binary/Hex.java
@@ -19,6 +19,7 @@ package org.apache.commons.codec.binary;
 
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.codec.BinaryDecoder;
 import org.apache.commons.codec.BinaryEncoder;
@@ -42,7 +43,7 @@ public class Hex implements BinaryEncoder, BinaryDecoder {
      *
      * @since 1.7
      */
-    public static final Charset DEFAULT_CHARSET = Charsets.UTF_8;
+    public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
 
     /**
      * Default charset name is {@link CharEncoding#UTF_8}
diff --git a/src/main/java/org/apache/commons/codec/binary/StringUtils.java b/src/main/java/org/apache/commons/codec/binary/StringUtils.java
index adb7ad8..ae0493d 100644
--- a/src/main/java/org/apache/commons/codec/binary/StringUtils.java
+++ b/src/main/java/org/apache/commons/codec/binary/StringUtils.java
@@ -20,6 +20,7 @@ package org.apache.commons.codec.binary;
 import java.io.UnsupportedEncodingException;
 import java.nio.ByteBuffer;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.codec.CharEncoding;
 import org.apache.commons.codec.Charsets;
@@ -127,7 +128,7 @@ public class StringUtils {
      * @since 1.11
      */
     public static ByteBuffer getByteBufferUtf8(final String string) {
-        return getByteBuffer(string, Charsets.UTF_8);
+        return getByteBuffer(string, StandardCharsets.UTF_8);
     }
 
     /**
@@ -145,7 +146,7 @@ public class StringUtils {
      * @see #getBytesUnchecked(String, String)
      */
     public static byte[] getBytesIso8859_1(final String string) {
-        return getBytes(string, Charsets.ISO_8859_1);
+        return getBytes(string, StandardCharsets.ISO_8859_1);
     }
 
 
@@ -194,7 +195,7 @@ public class StringUtils {
      * @see #getBytesUnchecked(String, String)
      */
     public static byte[] getBytesUsAscii(final String string) {
-        return getBytes(string, Charsets.US_ASCII);
+        return getBytes(string, StandardCharsets.US_ASCII);
     }
 
     /**
@@ -212,7 +213,7 @@ public class StringUtils {
      * @see #getBytesUnchecked(String, String)
      */
     public static byte[] getBytesUtf16(final String string) {
-        return getBytes(string, Charsets.UTF_16);
+        return getBytes(string, StandardCharsets.UTF_16);
     }
 
     /**
@@ -230,7 +231,7 @@ public class StringUtils {
      * @see #getBytesUnchecked(String, String)
      */
     public static byte[] getBytesUtf16Be(final String string) {
-        return getBytes(string, Charsets.UTF_16BE);
+        return getBytes(string, StandardCharsets.UTF_16BE);
     }
 
     /**
@@ -248,7 +249,7 @@ public class StringUtils {
      * @see #getBytesUnchecked(String, String)
      */
     public static byte[] getBytesUtf16Le(final String string) {
-        return getBytes(string, Charsets.UTF_16LE);
+        return getBytes(string, StandardCharsets.UTF_16LE);
     }
 
     /**
@@ -266,7 +267,7 @@ public class StringUtils {
      * @see #getBytesUnchecked(String, String)
      */
     public static byte[] getBytesUtf8(final String string) {
-        return getBytes(string, Charsets.UTF_8);
+        return getBytes(string, StandardCharsets.UTF_8);
     }
 
     private static IllegalStateException newIllegalStateException(final String charsetName,
@@ -333,7 +334,7 @@ public class StringUtils {
      * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
      */
     public static String newStringIso8859_1(final byte[] bytes) {
-        return newString(bytes, Charsets.ISO_8859_1);
+        return newString(bytes, StandardCharsets.ISO_8859_1);
     }
 
     /**
@@ -349,7 +350,7 @@ public class StringUtils {
      * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
      */
     public static String newStringUsAscii(final byte[] bytes) {
-        return newString(bytes, Charsets.US_ASCII);
+        return newString(bytes, StandardCharsets.US_ASCII);
     }
 
     /**
@@ -365,7 +366,7 @@ public class StringUtils {
      * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
      */
     public static String newStringUtf16(final byte[] bytes) {
-        return newString(bytes, Charsets.UTF_16);
+        return newString(bytes, StandardCharsets.UTF_16);
     }
 
     /**
@@ -381,7 +382,7 @@ public class StringUtils {
      * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
      */
     public static String newStringUtf16Be(final byte[] bytes) {
-        return newString(bytes, Charsets.UTF_16BE);
+        return newString(bytes, StandardCharsets.UTF_16BE);
     }
 
     /**
@@ -397,7 +398,7 @@ public class StringUtils {
      * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
      */
     public static String newStringUtf16Le(final byte[] bytes) {
-        return newString(bytes, Charsets.UTF_16LE);
+        return newString(bytes, StandardCharsets.UTF_16LE);
     }
 
     /**
@@ -413,7 +414,7 @@ public class StringUtils {
      * @since As of 1.7, throws {@link NullPointerException} instead of UnsupportedEncodingException
      */
     public static String newStringUtf8(final byte[] bytes) {
-        return newString(bytes, Charsets.UTF_8);
+        return newString(bytes, StandardCharsets.UTF_8);
     }
 
 }
diff --git a/src/main/java/org/apache/commons/codec/digest/Crypt.java b/src/main/java/org/apache/commons/codec/digest/Crypt.java
index 7669b43..e73ec9f 100644
--- a/src/main/java/org/apache/commons/codec/digest/Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Crypt.java
@@ -16,11 +16,10 @@
  */
 package org.apache.commons.codec.digest;
 
+import java.nio.charset.StandardCharsets;
 import java.security.SecureRandom;
 import java.util.concurrent.ThreadLocalRandom;
 
-import org.apache.commons.codec.Charsets;
-
 /**
  * GNU libc crypt(3) compatible hash method.
  * <p>
@@ -165,6 +164,6 @@ public class Crypt {
      *             when a {@link java.security.NoSuchAlgorithmException} is caught. *
      */
     public static String crypt(final String key, final String salt) {
-        return crypt(key.getBytes(Charsets.UTF_8), salt);
+        return crypt(key.getBytes(StandardCharsets.UTF_8), salt);
     }
 }
diff --git a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
index b6a14dd..f607b88 100644
--- a/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Md5Crypt.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.codec.digest;
 
+import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.security.SecureRandom;
 import java.util.Arrays;
@@ -24,8 +25,6 @@ import java.util.concurrent.ThreadLocalRandom;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.codec.Charsets;
-
 /**
  * The libc crypt() "$1$" and Apache "$apr1$" MD5-based hash algorithm.
  * <p>
@@ -140,7 +139,7 @@ public class Md5Crypt {
      * @see #apr1Crypt(byte[], String)
      */
     public static String apr1Crypt(final String keyBytes) {
-        return apr1Crypt(keyBytes.getBytes(Charsets.UTF_8));
+        return apr1Crypt(keyBytes.getBytes(StandardCharsets.UTF_8));
     }
 
     /**
@@ -162,7 +161,7 @@ public class Md5Crypt {
      *             when a {@link java.security.NoSuchAlgorithmException} is caught.
      */
     public static String apr1Crypt(final String keyBytes, final String salt) {
-        return apr1Crypt(keyBytes.getBytes(Charsets.UTF_8), salt);
+        return apr1Crypt(keyBytes.getBytes(StandardCharsets.UTF_8), salt);
     }
 
     /**
@@ -295,7 +294,7 @@ public class Md5Crypt {
             }
             saltString = m.group(1);
         }
-        final byte[] saltBytes = saltString.getBytes(Charsets.UTF_8);
+        final byte[] saltBytes = saltString.getBytes(StandardCharsets.UTF_8);
 
         final MessageDigest ctx = DigestUtils.getMd5Digest();
 
@@ -307,7 +306,7 @@ public class Md5Crypt {
         /*
          * Then our magic string
          */
-        ctx.update(prefix.getBytes(Charsets.UTF_8));
+        ctx.update(prefix.getBytes(StandardCharsets.UTF_8));
 
         /*
          * Then the raw salt
diff --git a/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java b/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java
index 1b8eb14..7d2f70e 100644
--- a/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/Sha2Crypt.java
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.codec.digest;
 
+import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
@@ -25,8 +26,6 @@ import java.util.concurrent.ThreadLocalRandom;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.commons.codec.Charsets;
-
 /**
  * SHA2-based Unix crypt implementation.
  * <p>
@@ -187,7 +186,7 @@ public class Sha2Crypt {
             roundsCustom = true;
         }
         final String saltString = m.group(4);
-        final byte[] saltBytes = saltString.getBytes(Charsets.UTF_8);
+        final byte[] saltBytes = saltString.getBytes(StandardCharsets.UTF_8);
         final int saltLen = saltBytes.length;
 
         // 1. start digest A
diff --git a/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java b/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
index 36e0a11..aac0123 100644
--- a/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
+++ b/src/main/java/org/apache/commons/codec/digest/UnixCrypt.java
@@ -16,11 +16,10 @@
  */
 package org.apache.commons.codec.digest;
 
+import java.nio.charset.StandardCharsets;
 import java.security.SecureRandom;
 import java.util.concurrent.ThreadLocalRandom;
 
-import org.apache.commons.codec.Charsets;
-
 /**
  * Unix crypt(3) algorithm implementation.
  * <p>
@@ -267,7 +266,7 @@ public class UnixCrypt {
      * @return a 13 character string starting with the salt string
      */
     public static String crypt(final String original) {
-        return crypt(original.getBytes(Charsets.UTF_8));
+        return crypt(original.getBytes(StandardCharsets.UTF_8));
     }
 
     /**
@@ -284,7 +283,7 @@ public class UnixCrypt {
      *             if the salt does not match the allowed pattern
      */
     public static String crypt(final String original, final String salt) {
-        return crypt(original.getBytes(Charsets.UTF_8), salt);
+        return crypt(original.getBytes(StandardCharsets.UTF_8), salt);
     }
 
     private static int[] body(final int schedule[], final int eSwap0, final int eSwap1) {
diff --git a/src/main/java/org/apache/commons/codec/net/BCodec.java b/src/main/java/org/apache/commons/codec/net/BCodec.java
index dade5e7..cabb489 100644
--- a/src/main/java/org/apache/commons/codec/net/BCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/BCodec.java
@@ -19,8 +19,8 @@ package org.apache.commons.codec.net;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.StringDecoder;
@@ -52,7 +52,7 @@ public class BCodec extends RFC1522Codec implements StringEncoder, StringDecoder
      * Default constructor.
      */
     public BCodec() {
-        this(Charsets.UTF_8);
+        this(StandardCharsets.UTF_8);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/codec/net/QCodec.java b/src/main/java/org/apache/commons/codec/net/QCodec.java
index f42ea66..86d4a50 100644
--- a/src/main/java/org/apache/commons/codec/net/QCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/QCodec.java
@@ -19,9 +19,9 @@ package org.apache.commons.codec.net;
 
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.BitSet;
 
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.apache.commons.codec.StringDecoder;
@@ -112,7 +112,7 @@ public class QCodec extends RFC1522Codec implements StringEncoder, StringDecoder
      * Default constructor.
      */
     public QCodec() {
-        this(Charsets.UTF_8);
+        this(StandardCharsets.UTF_8);
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java b/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
index d3a327f..bd80297 100644
--- a/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
+++ b/src/main/java/org/apache/commons/codec/net/QuotedPrintableCodec.java
@@ -21,6 +21,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
 import java.nio.charset.IllegalCharsetNameException;
+import java.nio.charset.StandardCharsets;
 import java.nio.charset.UnsupportedCharsetException;
 import java.util.BitSet;
 
@@ -110,7 +111,7 @@ public class QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder,
Strin
      * Default constructor, assumes default Charset of {@link Charsets#UTF_8}
      */
     public QuotedPrintableCodec() {
-        this(Charsets.UTF_8, false);
+        this(StandardCharsets.UTF_8, false);
     }
 
     /**
@@ -121,7 +122,7 @@ public class QuotedPrintableCodec implements BinaryEncoder, BinaryDecoder,
Strin
      * @since 1.10
      */
     public QuotedPrintableCodec(final boolean strict) {
-        this(Charsets.UTF_8, strict);
+        this(StandardCharsets.UTF_8, strict);
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/codec/CharsetsTest.java b/src/test/java/org/apache/commons/codec/CharsetsTest.java
index af3742e..8272ccd 100644
--- a/src/test/java/org/apache/commons/codec/CharsetsTest.java
+++ b/src/test/java/org/apache/commons/codec/CharsetsTest.java
@@ -18,6 +18,7 @@
 package org.apache.commons.codec;
 
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -38,32 +39,32 @@ public class CharsetsTest {
 
     @Test
     public void testIso8859_1() {
-        Assert.assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name());
+        Assert.assertEquals("ISO-8859-1", StandardCharsets.ISO_8859_1.name());
     }
 
     @Test
     public void testUsAscii() {
-        Assert.assertEquals("US-ASCII", Charsets.US_ASCII.name());
+        Assert.assertEquals("US-ASCII", StandardCharsets.US_ASCII.name());
     }
 
     @Test
     public void testUtf16() {
-        Assert.assertEquals("UTF-16", Charsets.UTF_16.name());
+        Assert.assertEquals("UTF-16", StandardCharsets.UTF_16.name());
     }
 
     @Test
     public void testUtf16Be() {
-        Assert.assertEquals("UTF-16BE", Charsets.UTF_16BE.name());
+        Assert.assertEquals("UTF-16BE", StandardCharsets.UTF_16BE.name());
     }
 
     @Test
     public void testUtf16Le() {
-        Assert.assertEquals("UTF-16LE", Charsets.UTF_16LE.name());
+        Assert.assertEquals("UTF-16LE", StandardCharsets.UTF_16LE.name());
     }
 
     @Test
     public void testUtf8() {
-        Assert.assertEquals("UTF-8", Charsets.UTF_8.name());
+        Assert.assertEquals("UTF-8", StandardCharsets.UTF_8.name());
     }
 
 }
diff --git a/src/test/java/org/apache/commons/codec/binary/Base32Test.java b/src/test/java/org/apache/commons/codec/binary/Base32Test.java
index 360f221..270da85 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base32Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base32Test.java
@@ -24,9 +24,9 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.lang3.ArrayUtils;
 import org.junit.Test;
@@ -34,7 +34,7 @@ import org.junit.Test;
 public class Base32Test {
 
 
-    private static final Charset CHARSET_UTF8 = Charsets.UTF_8;
+    private static final Charset CHARSET_UTF8 = StandardCharsets.UTF_8;
 
     private static final String [][] BASE32_TEST_CASES = { // RFC 4648
         {""       ,""},
diff --git a/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java b/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java
index 2d4c28e..4a044b1 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64Codec13Test.java
@@ -19,11 +19,11 @@ package org.apache.commons.codec.binary;
 
 import static org.junit.Assert.assertTrue;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 
 import org.apache.commons.codec.BinaryDecoder;
 import org.apache.commons.codec.BinaryEncoder;
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.Decoder;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.Encoder;
@@ -511,6 +511,6 @@ public class Base64Codec13Test {
         // need this class to be able to run against commons-codec-1.3.jar, hence the
         // duplication here.
 
-        return s != null ? s.getBytes(Charsets.UTF_8) : null;
+        return s != null ? s.getBytes(StandardCharsets.UTF_8) : null;
     }
 }
diff --git a/src/test/java/org/apache/commons/codec/binary/Base64Test.java b/src/test/java/org/apache/commons/codec/binary/Base64Test.java
index d4a63fc..0637989 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64Test.java
@@ -25,10 +25,10 @@ import static org.junit.Assert.fail;
 
 import java.math.BigInteger;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Random;
 
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.apache.commons.lang3.ArrayUtils;
@@ -42,7 +42,7 @@ import org.junit.Test;
  */
 public class Base64Test {
 
-    private static final Charset CHARSET_UTF8 = Charsets.UTF_8;
+    private static final Charset CHARSET_UTF8 = StandardCharsets.UTF_8;
 
     private static final String[] BASE64_IMPOSSIBLE_CASES = {
         "ZE==",
diff --git a/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java b/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
index a0892cc..2e3e638 100644
--- a/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/BinaryCodecTest.java
@@ -21,8 +21,8 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.After;
@@ -35,7 +35,7 @@ import org.junit.Test;
  */
 public class BinaryCodecTest {
 
-    private static final Charset CHARSET_UTF8 = Charsets.UTF_8;
+    private static final Charset CHARSET_UTF8 = StandardCharsets.UTF_8;
 
     /** Mask with bit zero-based index 0 raised. */
     private static final int BIT_0 = 0x01;
diff --git a/src/test/java/org/apache/commons/codec/binary/HexTest.java b/src/test/java/org/apache/commons/codec/binary/HexTest.java
index be50718..4c29548 100644
--- a/src/test/java/org/apache/commons/codec/binary/HexTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/HexTest.java
@@ -30,7 +30,6 @@ import java.nio.charset.UnsupportedCharsetException;
 import java.util.Arrays;
 import java.util.Random;
 
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.Assert;
@@ -637,12 +636,12 @@ public class HexTest {
 
     @Test
     public void testGetCharset() {
-        Assert.assertEquals(Charsets.UTF_8, new Hex(Charsets.UTF_8).getCharset());
+        Assert.assertEquals(StandardCharsets.UTF_8, new Hex(StandardCharsets.UTF_8).getCharset());
     }
 
     @Test
     public void testGetCharsetName() {
-        Assert.assertEquals(Charsets.UTF_8.name(), new Hex(Charsets.UTF_8).getCharsetName());
+        Assert.assertEquals(StandardCharsets.UTF_8.name(), new Hex(StandardCharsets.UTF_8).getCharsetName());
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java b/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java
index 80016ab..cdeb7dd 100644
--- a/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/Apr1CryptTest.java
@@ -20,9 +20,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.commons.codec.Charsets;
 import org.junit.Test;
 
+import java.nio.charset.StandardCharsets;
 import java.util.concurrent.ThreadLocalRandom;
 
 public class Apr1CryptTest {
@@ -54,7 +54,7 @@ public class Apr1CryptTest {
         // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4.
         assertEquals("$apr1$./$EeFrYzWWbmTyGdf4xULYc.", Md5Crypt.apr1Crypt("t\u00e4st", "$apr1$./$"));
         // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4.
-        assertEquals("$apr1$./$kCwT1pY9qXAJElYG9q1QE1", Md5Crypt.apr1Crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1),
"$apr1$./$"));
+        assertEquals("$apr1$./$kCwT1pY9qXAJElYG9q1QE1", Md5Crypt.apr1Crypt("t\u00e4st".getBytes(StandardCharsets.ISO_8859_1),
"$apr1$./$"));
     }
 
     @Test
@@ -70,7 +70,7 @@ public class Apr1CryptTest {
         // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4.
         assertEquals("$apr1$./$EeFrYzWWbmTyGdf4xULYc.", Md5Crypt.apr1Crypt("t\u00e4st", "$apr1$./$"));
         // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4.
-        assertEquals("$apr1$./$kCwT1pY9qXAJElYG9q1QE1", Md5Crypt.apr1Crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1),
"$apr1$./$"));
+        assertEquals("$apr1$./$kCwT1pY9qXAJElYG9q1QE1", Md5Crypt.apr1Crypt("t\u00e4st".getBytes(StandardCharsets.ISO_8859_1),
"$apr1$./$"));
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java b/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java
index 6b7dfee..21401f3 100644
--- a/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/Md5CryptTest.java
@@ -20,9 +20,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.commons.codec.Charsets;
 import org.junit.Test;
 
+import java.nio.charset.StandardCharsets;
 import java.util.concurrent.ThreadLocalRandom;
 
 public class Md5CryptTest {
@@ -52,7 +52,7 @@ public class Md5CryptTest {
         // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4.
         assertEquals("$1$./$52agTEQZs877L9jyJnCNZ1", Crypt.crypt("t\u00e4st", "$1$./$"));
         // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4.
-        assertEquals("$1$./$J2UbKzGe0Cpe63WZAt6p//", Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1),
"$1$./$"));
+        assertEquals("$1$./$J2UbKzGe0Cpe63WZAt6p//", Crypt.crypt("t\u00e4st".getBytes(StandardCharsets.ISO_8859_1),
"$1$./$"));
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java b/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java
index 1bea725..f609012 100644
--- a/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/Sha256CryptTest.java
@@ -19,10 +19,10 @@ package org.apache.commons.codec.digest;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.concurrent.ThreadLocalRandom;
 
-import org.apache.commons.codec.Charsets;
 import org.junit.Test;
 
 public class Sha256CryptTest {
@@ -47,24 +47,24 @@ public class Sha256CryptTest {
         // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4.
         assertEquals("$5$./$iH66LwY5sTDTdHeOxq5nvNDVAxuoCcyH/y6Ptte82P8", Crypt.crypt("t\u00e4st",
"$5$./$"));
         // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4.
-        assertEquals("$5$./$qx5gFfCzjuWUOvsDDy.5Nor3UULPIqLVBZhgGNS0c14", Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1),
"$5$./$"));
+        assertEquals("$5$./$qx5gFfCzjuWUOvsDDy.5Nor3UULPIqLVBZhgGNS0c14", Crypt.crypt("t\u00e4st".getBytes(StandardCharsets.ISO_8859_1),
"$5$./$"));
     }
 
     @Test
     public void testSha2CryptRounds() {
         // minimum rounds?
-        assertEquals("$5$rounds=1000$abcd$b8MCU4GEeZIekOy5ahQ8EWfT330hvYGVeDYkBxXBva.", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=50$abcd$"));
-        assertEquals("$5$rounds=1001$abcd$SQsJZs7KXKdd2DtklI3TY3tkD7UYA99RD0FBLm4Sk48", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=1001$abcd$"));
-        assertEquals("$5$rounds=9999$abcd$Rh/8ngVh9oyuS6lL3.fsq.9xbvXJsfyKWxSjO2mPIa7", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=9999$abcd"));
+        assertEquals("$5$rounds=1000$abcd$b8MCU4GEeZIekOy5ahQ8EWfT330hvYGVeDYkBxXBva.", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=50$abcd$"));
+        assertEquals("$5$rounds=1001$abcd$SQsJZs7KXKdd2DtklI3TY3tkD7UYA99RD0FBLm4Sk48", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=1001$abcd$"));
+        assertEquals("$5$rounds=9999$abcd$Rh/8ngVh9oyuS6lL3.fsq.9xbvXJsfyKWxSjO2mPIa7", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=9999$abcd"));
     }
 
     @Test
     public void testSha2CryptRoundsThreadLocalRandom() {
         final ThreadLocalRandom random = ThreadLocalRandom.current();
         // minimum rounds?
-        assertEquals("$5$rounds=1000$abcd$b8MCU4GEeZIekOy5ahQ8EWfT330hvYGVeDYkBxXBva.", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=50$abcd$", random));
-        assertEquals("$5$rounds=1001$abcd$SQsJZs7KXKdd2DtklI3TY3tkD7UYA99RD0FBLm4Sk48", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=1001$abcd$", random));
-        assertEquals("$5$rounds=9999$abcd$Rh/8ngVh9oyuS6lL3.fsq.9xbvXJsfyKWxSjO2mPIa7", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=9999$abcd", random));
+        assertEquals("$5$rounds=1000$abcd$b8MCU4GEeZIekOy5ahQ8EWfT330hvYGVeDYkBxXBva.", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=50$abcd$", random));
+        assertEquals("$5$rounds=1001$abcd$SQsJZs7KXKdd2DtklI3TY3tkD7UYA99RD0FBLm4Sk48", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=1001$abcd$", random));
+        assertEquals("$5$rounds=9999$abcd$Rh/8ngVh9oyuS6lL3.fsq.9xbvXJsfyKWxSjO2mPIa7", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=9999$abcd", random));
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java b/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java
index 4db1f62..4f488b4 100644
--- a/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/Sha512CryptTest.java
@@ -19,10 +19,10 @@ package org.apache.commons.codec.digest;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.concurrent.ThreadLocalRandom;
 
-import org.apache.commons.codec.Charsets;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -48,7 +48,7 @@ public class Sha512CryptTest {
         // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4.
         assertEquals("$6$./$fKtWqslQkwI8ZxjdWoeS.jHHrte97bZxiwB5gwCRHX6LG62fUhT6Bb5MRrjWvieh0C/gxh8ItFuTsVy80VrED1",
Crypt.crypt("t\u00e4st", "$6$./$"));
         // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4.
-        assertEquals("$6$./$L49DSK.d2df/LxGLJQMyS5A/Um.TdHqgc46j5FpScEPlqQHP5dEazltaDNDZ6UEs2mmNI6kPwtH/rsP9g5zBI.",
Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1), "$6$./$"));
+        assertEquals("$6$./$L49DSK.d2df/LxGLJQMyS5A/Um.TdHqgc46j5FpScEPlqQHP5dEazltaDNDZ6UEs2mmNI6kPwtH/rsP9g5zBI.",
Crypt.crypt("t\u00e4st".getBytes(StandardCharsets.ISO_8859_1), "$6$./$"));
     }
 
     @Test
@@ -77,14 +77,14 @@ public class Sha512CryptTest {
     @Test
     public void testSha2CryptRounds() {
         // minimum rounds?
-        assertEquals("$5$rounds=1000$abcd$b8MCU4GEeZIekOy5ahQ8EWfT330hvYGVeDYkBxXBva.", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=50$abcd$"));
-        assertEquals("$5$rounds=1001$abcd$SQsJZs7KXKdd2DtklI3TY3tkD7UYA99RD0FBLm4Sk48", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=1001$abcd$"));
-        assertEquals("$5$rounds=9999$abcd$Rh/8ngVh9oyuS6lL3.fsq.9xbvXJsfyKWxSjO2mPIa7", Sha2Crypt.sha256Crypt("secret".getBytes(Charsets.UTF_8),
"$5$rounds=9999$abcd"));
+        assertEquals("$5$rounds=1000$abcd$b8MCU4GEeZIekOy5ahQ8EWfT330hvYGVeDYkBxXBva.", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=50$abcd$"));
+        assertEquals("$5$rounds=1001$abcd$SQsJZs7KXKdd2DtklI3TY3tkD7UYA99RD0FBLm4Sk48", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=1001$abcd$"));
+        assertEquals("$5$rounds=9999$abcd$Rh/8ngVh9oyuS6lL3.fsq.9xbvXJsfyKWxSjO2mPIa7", Sha2Crypt.sha256Crypt("secret".getBytes(StandardCharsets.UTF_8),
"$5$rounds=9999$abcd"));
     }
 
     @Test(expected = IllegalArgumentException.class)
     public void testSha2CryptWrongSalt() {
-        Sha2Crypt.sha512Crypt("secret".getBytes(Charsets.UTF_8), "xx");
+        Sha2Crypt.sha512Crypt("secret".getBytes(StandardCharsets.UTF_8), "xx");
     }
 
     @Test(expected = IllegalArgumentException.class)
diff --git a/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java b/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java
index e5ba440..466adcb 100644
--- a/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/UnixCryptTest.java
@@ -21,7 +21,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 
-import org.apache.commons.codec.Charsets;
+import java.nio.charset.StandardCharsets;
+
 import org.junit.Test;
 
 public class UnixCryptTest {
@@ -49,7 +50,7 @@ public class UnixCryptTest {
         // UTF-8 stores \u00e4 "a with diaeresis" as two bytes 0xc3 0xa4.
         assertEquals("./287bds2PjVw", Crypt.crypt("t\u00e4st", "./"));
         // ISO-8859-1 stores "a with diaeresis" as single byte 0xe4.
-        assertEquals("./bLIFNqo9XKQ", Crypt.crypt("t\u00e4st".getBytes(Charsets.ISO_8859_1),
"./"));
+        assertEquals("./bLIFNqo9XKQ", Crypt.crypt("t\u00e4st".getBytes(StandardCharsets.ISO_8859_1),
"./"));
         assertEquals("./bLIFNqo9XKQ", Crypt.crypt(new byte[]{(byte) 0x74, (byte) 0xe4, (byte)
0x73, (byte) 0x74}, "./"));
     }
 
diff --git a/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java b/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java
index 57654b3..f41e7f8 100644
--- a/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java
+++ b/src/test/java/org/apache/commons/codec/net/QuotedPrintableCodecTest.java
@@ -19,10 +19,10 @@ package org.apache.commons.codec.net;
 
 import static org.junit.Assert.*;
 
+import java.nio.charset.StandardCharsets;
 import java.nio.charset.UnsupportedCharsetException;
 
 import org.apache.commons.codec.CharEncoding;
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.Test;
@@ -151,7 +151,7 @@ public class QuotedPrintableCodecTest {
         final QuotedPrintableCodec qpcodec = new QuotedPrintableCodec();
         final String plain = "1+1 = 2";
         final String encoded = new String(QuotedPrintableCodec.
-            encodeQuotedPrintable(null, plain.getBytes(Charsets.UTF_8)));
+            encodeQuotedPrintable(null, plain.getBytes(StandardCharsets.UTF_8)));
         assertEquals("Basic quoted-printable encoding test",
             "1+1 =3D 2", encoded);
         assertEquals("Basic quoted-printable decoding test",
@@ -190,7 +190,7 @@ public class QuotedPrintableCodecTest {
         assertEquals("Basic quoted-printable encoding test",
             "1+1 =3D 2", encoded);
 
-        final byte[] plainBA = plain.getBytes(Charsets.UTF_8);
+        final byte[] plainBA = plain.getBytes(StandardCharsets.UTF_8);
         final byte[] encodedBA = (byte[]) qpcodec.encode((Object) plainBA);
         encoded = new String(encodedBA);
         assertEquals("Basic quoted-printable encoding test",
@@ -221,7 +221,7 @@ public class QuotedPrintableCodecTest {
         assertEquals("Basic quoted-printable decoding test",
             "1+1 = 2", decoded);
 
-        final byte[] plainBA = plain.getBytes(Charsets.UTF_8);
+        final byte[] plainBA = plain.getBytes(StandardCharsets.UTF_8);
         final byte[] decodedBA = (byte[]) qpcodec.decode((Object) plainBA);
         decoded = new String(decodedBA);
         assertEquals("Basic quoted-printable decoding test",
diff --git a/src/test/java/org/apache/commons/codec/net/URLCodecTest.java b/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
index 9b5fe6b..8ae4f75 100644
--- a/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
+++ b/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
@@ -22,9 +22,9 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.codec.CharEncoding;
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.Test;
@@ -187,7 +187,7 @@ public class URLCodecTest {
     public void testEncodeUrlWithNullBitSet() throws Exception {
         final URLCodec urlCodec = new URLCodec();
         final String plain = "Hello there!";
-        final String encoded = new String( URLCodec.encodeUrl(null, plain.getBytes(Charsets.UTF_8)));
+        final String encoded = new String( URLCodec.encodeUrl(null, plain.getBytes(StandardCharsets.UTF_8)));
         assertEquals("Basic URL encoding test",
             "Hello+there%21", encoded);
         assertEquals("Basic URL decoding test",
@@ -226,7 +226,7 @@ public class URLCodecTest {
         assertEquals("Basic URL encoding test",
             "Hello+there%21", encoded);
 
-        final byte[] plainBA = plain.getBytes(Charsets.UTF_8);
+        final byte[] plainBA = plain.getBytes(StandardCharsets.UTF_8);
         final byte[] encodedBA = (byte[]) urlCodec.encode((Object) plainBA);
         encoded = new String(encodedBA);
         assertEquals("Basic URL encoding test",
@@ -272,7 +272,7 @@ public class URLCodecTest {
         assertEquals("Basic URL decoding test",
             "Hello there!", decoded);
 
-        final byte[] plainBA = plain.getBytes(Charsets.UTF_8);
+        final byte[] plainBA = plain.getBytes(StandardCharsets.UTF_8);
         final byte[] decodedBA = (byte[]) urlCodec.decode((Object) plainBA);
         decoded = new String(decodedBA);
         assertEquals("Basic URL decoding test",


Mime
View raw message