You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/05/22 11:36:38 UTC

[commons-codec] branch master updated (607bd7f3 -> 767ecc18)

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

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


    from 607bd7f3 ci: add GitHub token permissions
     new 54677f44 Remove unused exceptions
     new 23a1022e Remove unused exceptions
     new f5ed85f6 Access constant directly.
     new 767ecc18 Use try-with-resources; use final.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../codec/binary/Base16OutputStreamTest.java       |  8 +++---
 .../apache/commons/codec/binary/Base16Test.java    |  2 +-
 .../codec/binary/Base32InputStreamTest.java        |  4 +--
 .../codec/binary/Base32OutputStreamTest.java       | 29 ++++++++++----------
 .../codec/binary/Base64InputStreamTest.java        |  4 +--
 .../codec/binary/Base64OutputStreamTest.java       |  2 +-
 .../apache/commons/codec/binary/Base64Test.java    |  6 ++--
 .../org/apache/commons/codec/binary/HexTest.java   |  2 +-
 .../org/apache/commons/codec/cli/DigestTest.java   |  2 --
 .../codec/digest/Blake3TestVectorsTest.java        | 10 +++----
 .../commons/codec/digest/HmacAlgorithmsTest.java   | 32 +++++++++++-----------
 .../codec/digest/MessageDigestAlgorithmsTest.java  | 22 +++++++--------
 .../apache/commons/codec/digest/XXHash32Test.java  |  4 +--
 .../codec/language/bm/BeiderMorseEncoderTest.java  |  2 +-
 .../codec/language/bm/LanguageGuessingTest.java    |  2 +-
 .../org/apache/commons/codec/net/BCodecTest.java   |  2 +-
 .../org/apache/commons/codec/net/URLCodecTest.java |  9 +++---
 17 files changed, 71 insertions(+), 71 deletions(-)


[commons-codec] 02/04: Remove unused exceptions

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 23a1022e8810849d1479ea85e84a5133b34562f1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 22 07:28:02 2022 -0400

    Remove unused exceptions
---
 src/test/java/org/apache/commons/codec/cli/DigestTest.java | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/cli/DigestTest.java b/src/test/java/org/apache/commons/codec/cli/DigestTest.java
index 2d4d8ab8..702bec40 100644
--- a/src/test/java/org/apache/commons/codec/cli/DigestTest.java
+++ b/src/test/java/org/apache/commons/codec/cli/DigestTest.java
@@ -19,8 +19,6 @@ package org.apache.commons.codec.cli;
 
 import org.junit.jupiter.api.Test;
 
-import java.io.IOException;
-
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /**


[commons-codec] 01/04: Remove unused exceptions

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 54677f44b2efdf52cade07c7dcf20c856fc7a6cc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 22 07:27:12 2022 -0400

    Remove unused exceptions
---
 src/test/java/org/apache/commons/codec/binary/Base16Test.java    | 2 +-
 src/test/java/org/apache/commons/codec/binary/HexTest.java       | 2 +-
 .../java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java | 4 ++--
 .../apache/commons/codec/language/bm/BeiderMorseEncoderTest.java | 2 +-
 src/test/java/org/apache/commons/codec/net/BCodecTest.java       | 2 +-
 src/test/java/org/apache/commons/codec/net/URLCodecTest.java     | 9 +++++----
 6 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/binary/Base16Test.java b/src/test/java/org/apache/commons/codec/binary/Base16Test.java
index a015c699..0ce8b0d9 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base16Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base16Test.java
@@ -412,7 +412,7 @@ public class Base16Test {
     }
 
     @Test
-    public void testByteToStringVariations() throws DecoderException {
+    public void testByteToStringVariations() {
         final Base16 base16 = new Base16();
         final byte[] b1 = StringUtils.getBytesUtf8("Hello World");
         final byte[] b2 = {};
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 19104cff..5d21ea2b 100644
--- a/src/test/java/org/apache/commons/codec/binary/HexTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/HexTest.java
@@ -396,7 +396,7 @@ public class HexTest {
     }
 
     @Test
-    public void testEncodeDecodeHexCharArrayRandomToOutput() throws DecoderException, EncoderException {
+    public void testEncodeDecodeHexCharArrayRandomToOutput() throws DecoderException {
         for (int i = 5; i > 0; i--) {
             final byte[] data = new byte[ThreadLocalRandom.current().nextInt(10000) + 1];
             ThreadLocalRandom.current().nextBytes(data);
diff --git a/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java b/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
index 4a8bbb65..12bf2bf2 100644
--- a/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
@@ -156,7 +156,7 @@ public class HmacAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testHmacFailInputStream(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) throws IOException {
+    public void testHmacFailInputStream(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> new HmacUtils(hmacAlgorithm, (byte[]) null).hmac(new ByteArrayInputStream(STANDARD_PHRASE_BYTES)));
     }
@@ -177,7 +177,7 @@ public class HmacAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testHmacHexFailInputStream(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) throws IOException {
+    public void testHmacHexFailInputStream(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> new HmacUtils(hmacAlgorithm, (byte[]) null).hmac(new ByteArrayInputStream(STANDARD_PHRASE_BYTES)));
     }
diff --git a/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java b/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java
index 3e65734f..19140c6e 100644
--- a/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java
+++ b/src/test/java/org/apache/commons/codec/language/bm/BeiderMorseEncoderTest.java
@@ -123,7 +123,7 @@ public class BeiderMorseEncoderTest extends StringEncoderAbstractTest<StringEnco
     }
 
     @Test
-    public void testLongestEnglishSurname() throws EncoderException {
+    public void testLongestEnglishSurname() {
         final BeiderMorseEncoder bmpm = createGenericApproxEncoder();
         assertTimeout(Duration.ofMillis(10000L), () -> bmpm.encode("MacGhilleseatheanaich"));
     }
diff --git a/src/test/java/org/apache/commons/codec/net/BCodecTest.java b/src/test/java/org/apache/commons/codec/net/BCodecTest.java
index 276aeedd..5b046007 100644
--- a/src/test/java/org/apache/commons/codec/net/BCodecTest.java
+++ b/src/test/java/org/apache/commons/codec/net/BCodecTest.java
@@ -165,7 +165,7 @@ public class BCodecTest {
     }
 
     @Test
-    public void testBase64ImpossibleSamplesStrict() throws DecoderException {
+    public void testBase64ImpossibleSamplesStrict() {
         final BCodec codec = new BCodec(StandardCharsets.UTF_8, CodecPolicy.STRICT);
         assertTrue(codec.isStrictDecoding());
         for (final String s : BASE64_IMPOSSIBLE_CASES) {
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 08bbf222..366d7719 100644
--- a/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
+++ b/src/test/java/org/apache/commons/codec/net/URLCodecTest.java
@@ -17,7 +17,10 @@
 
 package org.apache.commons.codec.net;
 
-import java.io.UnsupportedEncodingException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 import java.nio.charset.StandardCharsets;
 
 import org.apache.commons.codec.CharEncoding;
@@ -25,8 +28,6 @@ import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.EncoderException;
 import org.junit.jupiter.api.Test;
 
-import static org.junit.jupiter.api.Assertions.*;
-
 /**
  * URL codec test cases
  *
@@ -131,7 +132,7 @@ public class URLCodecTest {
     }
 
     @Test
-    public void testDecodeInvalidContent() throws UnsupportedEncodingException, DecoderException {
+    public void testDecodeInvalidContent() throws DecoderException {
         final String ch_msg = constructString(SWISS_GERMAN_STUFF_UNICODE);
         final URLCodec urlCodec = new URLCodec();
         final byte[] input = ch_msg.getBytes(StandardCharsets.ISO_8859_1);


[commons-codec] 04/04: Use try-with-resources; use final.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 767ecc184246c2a1f11517c8e37d15efb0a2f782
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 22 07:35:53 2022 -0400

    Use try-with-resources; use final.
---
 .../codec/binary/Base16OutputStreamTest.java       |  8 +++---
 .../codec/binary/Base32InputStreamTest.java        |  4 +--
 .../codec/binary/Base32OutputStreamTest.java       | 29 ++++++++++----------
 .../codec/binary/Base64InputStreamTest.java        |  4 +--
 .../codec/binary/Base64OutputStreamTest.java       |  2 +-
 .../apache/commons/codec/binary/Base64Test.java    |  2 +-
 .../codec/digest/Blake3TestVectorsTest.java        | 10 +++----
 .../commons/codec/digest/HmacAlgorithmsTest.java   | 32 +++++++++++-----------
 .../codec/digest/MessageDigestAlgorithmsTest.java  | 22 +++++++--------
 .../apache/commons/codec/digest/XXHash32Test.java  |  4 +--
 .../codec/language/bm/LanguageGuessingTest.java    |  2 +-
 11 files changed, 60 insertions(+), 59 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/binary/Base16OutputStreamTest.java b/src/test/java/org/apache/commons/codec/binary/Base16OutputStreamTest.java
index 37cb5ab6..2d576338 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base16OutputStreamTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base16OutputStreamTest.java
@@ -52,7 +52,7 @@ public class Base16OutputStreamTest {
      * @throws IOException for some failure scenarios.
      */
     @Test
-    public void testBase16OutputStreamByChunk() throws Exception {
+    public void testBase16OutputStreamByChunk() throws IOException {
         // Hello World test.
         byte[] encoded = StringUtils.getBytesUtf8("48656C6C6F20576F726C64");
         byte[] decoded = StringUtils.getBytesUtf8(STRING_FIXTURE);
@@ -146,9 +146,9 @@ public class Base16OutputStreamTest {
         }
 
         // wrap encoder with decoder
-        try (final ByteArrayOutputStream byteOut = new ByteArrayOutputStream()) {
-            final OutputStream decoderOut = new Base16OutputStream(byteOut, false, lowerCase);
-            final OutputStream encoderOut = new Base16OutputStream(decoderOut, true, lowerCase);
+        try (final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+             final OutputStream decoderOut = new Base16OutputStream(byteOut, false, lowerCase);
+             final OutputStream encoderOut = new Base16OutputStream(decoderOut, true, lowerCase)) {
 
             encoderOut.write(decoded);
             final byte[] output = byteOut.toByteArray();
diff --git a/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java b/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java
index b7da9bbd..b27155ec 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base32InputStreamTest.java
@@ -537,13 +537,13 @@ public class Base32InputStreamTest {
     public void testStrictDecoding() throws Exception {
         for (final String s : Base32Test.BASE32_IMPOSSIBLE_CASES) {
             final byte[] encoded = StringUtils.getBytesUtf8(s);
-            Base32InputStream in = new Base32InputStream(new ByteArrayInputStream(encoded), false);
+            final Base32InputStream in = new Base32InputStream(new ByteArrayInputStream(encoded), false);
             // Default is lenient decoding; it should not throw
             assertFalse(in.isStrictDecoding());
             BaseNTestData.streamToBytes(in);
 
             // Strict decoding should throw
-            Base32InputStream in2 = new Base32InputStream(new ByteArrayInputStream(encoded), false, 0, null, CodecPolicy.STRICT);
+            final Base32InputStream in2 = new Base32InputStream(new ByteArrayInputStream(encoded), false, 0, null, CodecPolicy.STRICT);
             assertTrue(in2.isStrictDecoding());
             assertThrows(IllegalArgumentException.class, () -> BaseNTestData.streamToBytes(in2));
         }
diff --git a/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java b/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java
index 0780da34..773364fc 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base32OutputStreamTest.java
@@ -203,7 +203,7 @@ public class Base32OutputStreamTest {
         out.close();
         output = byteOut.toByteArray();
 
-        assertArrayEquals(decoded, output, "Streaming chunked Base32 wrap-wrap-wrap!");
+        assertArrayEquals(decoded, byteOut.toByteArray(), "Streaming chunked Base32 wrap-wrap-wrap!");
     }
 
     /**
@@ -316,19 +316,20 @@ public class Base32OutputStreamTest {
         for (final String s : Base32Test.BASE32_IMPOSSIBLE_CASES) {
             final byte[] encoded = StringUtils.getBytesUtf8(s);
             ByteArrayOutputStream bout = new ByteArrayOutputStream();
-            Base32OutputStream out = new Base32OutputStream(bout, false);
-            // Default is lenient decoding; it should not throw
-            assertFalse(out.isStrictDecoding());
-            out.write(encoded);
-            out.close();
-            assertTrue(bout.size() > 0);
-
-            // Strict decoding should throw
-            bout = new ByteArrayOutputStream();
-            final Base32OutputStream out2 = new Base32OutputStream(bout, false, 0, null, CodecPolicy.STRICT);
-            assertTrue(out2.isStrictDecoding());
-            assertThrows(IllegalArgumentException.class, () -> out2.write(encoded));
-            out2.close();
+            try (Base32OutputStream out = new Base32OutputStream(bout, false)) {
+                // Default is lenient decoding; it should not throw
+                assertFalse(out.isStrictDecoding());
+                out.write(encoded);
+                out.close();
+                assertTrue(bout.size() > 0);
+
+                // Strict decoding should throw
+                bout = new ByteArrayOutputStream();
+                try (final Base32OutputStream out2 = new Base32OutputStream(bout, false, 0, null, CodecPolicy.STRICT)) {
+                    assertTrue(out2.isStrictDecoding());
+                    assertThrows(IllegalArgumentException.class, () -> out2.write(encoded));
+                }
+            }
         }
     }
 }
diff --git a/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java b/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
index 5c915429..a0142e05 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
@@ -575,13 +575,13 @@ public class Base64InputStreamTest {
     public void testStrictDecoding() throws Exception {
         for (final String s : Base64Test.BASE64_IMPOSSIBLE_CASES) {
             final byte[] encoded = StringUtils.getBytesUtf8(s);
-            Base64InputStream in = new Base64InputStream(new ByteArrayInputStream(encoded), false);
+            final Base64InputStream in = new Base64InputStream(new ByteArrayInputStream(encoded), false);
             // Default is lenient decoding; it should not throw
             assertFalse(in.isStrictDecoding());
             BaseNTestData.streamToBytes(in);
 
             // Strict decoding should throw
-            Base64InputStream in2 = new Base64InputStream(new ByteArrayInputStream(encoded), false, 0, null, CodecPolicy.STRICT);
+            final Base64InputStream in2 = new Base64InputStream(new ByteArrayInputStream(encoded), false, 0, null, CodecPolicy.STRICT);
             assertTrue(in2.isStrictDecoding());
             assertThrows(IllegalArgumentException.class, () -> BaseNTestData.streamToBytes(in2));
         }
diff --git a/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java b/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
index 39fa2adf..e6e38d69 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64OutputStreamTest.java
@@ -334,7 +334,7 @@ public class Base64OutputStreamTest {
 
             // Strict decoding should throw
             bout = new ByteArrayOutputStream();
-            Base64OutputStream out = new Base64OutputStream(bout, false, 0, null, CodecPolicy.STRICT);
+            final Base64OutputStream out = new Base64OutputStream(bout, false, 0, null, CodecPolicy.STRICT);
             // May throw on write or on close depending on the position of the
             // impossible last character in the output block size
             assertThrows(IllegalArgumentException.class, () -> {
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 332c5afa..3fa47d13 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64Test.java
@@ -520,7 +520,7 @@ public class Base64Test {
 
         try {
             final Base64 b64 = new Base64();
-            byte[] result = b64.decode(bArray);
+            final byte[] result = b64.decode(bArray);
 
             assertEquals(0, result.length, "The result should be empty as the test encoded content did " +
                     "not contain any valid base 64 characters");
diff --git a/src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java b/src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java
index 289a5763..7b23a401 100644
--- a/src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/Blake3TestVectorsTest.java
@@ -279,7 +279,7 @@ public class Blake3TestVectorsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void hashArbitraryOutputLength(int inputLength, String hash, String keyedHash, String deriveKey) throws DecoderException {
+    public void hashArbitraryOutputLength(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
         initData(inputLength, hash, keyedHash, deriveKey);
         hasher.update(inputByteArray);
         final byte[] actual = hasher.doFinalize(hashByteArray.length);
@@ -288,7 +288,7 @@ public class Blake3TestVectorsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void hashTruncatedOutput(int inputLength, String hash, String keyedHash, String deriveKey) throws DecoderException {
+    public void hashTruncatedOutput(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
         initData(inputLength, hash, keyedHash, deriveKey);
         final byte[] actual = Blake3.hash(inputByteArray);
         assertArrayEquals(Arrays.copyOf(this.hashByteArray, 32), actual);
@@ -296,7 +296,7 @@ public class Blake3TestVectorsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void keyedHashArbitraryOutputLength(int inputLength, String hash, String keyedHash, String deriveKey) throws DecoderException {
+    public void keyedHashArbitraryOutputLength(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
         initData(inputLength, hash, keyedHash, deriveKey);
         keyedHasher.update(inputByteArray);
         final byte[] actual = keyedHasher.doFinalize(keyedHashByteArray.length);
@@ -305,7 +305,7 @@ public class Blake3TestVectorsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void keyedHashTruncatedOutput(int inputLength, String hash, String keyedHash, String deriveKey) throws DecoderException {
+    public void keyedHashTruncatedOutput(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
         initData(inputLength, hash, keyedHash, deriveKey);
         final byte[] actual = Blake3.keyedHash(KEY, inputByteArray);
         assertArrayEquals(Arrays.copyOf(keyedHashByteArray, 32), actual);
@@ -313,7 +313,7 @@ public class Blake3TestVectorsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void keyDerivation(int inputLength, String hash, String keyedHash, String deriveKey) throws DecoderException {
+    public void keyDerivation(final int inputLength, final String hash, final String keyedHash, final String deriveKey) throws DecoderException {
         initData(inputLength, hash, keyedHash, deriveKey);
         kdfHasher.update(inputByteArray);
         final byte[] actual = kdfHasher.doFinalize(deriveKeyByteArray.length);
diff --git a/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java b/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
index 12bf2bf2..7891d76b 100644
--- a/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/HmacAlgorithmsTest.java
@@ -124,7 +124,7 @@ public class HmacAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testAlgorithm(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) throws NoSuchAlgorithmException {
+    public void testAlgorithm(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) throws NoSuchAlgorithmException {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         final String algorithm = hmacAlgorithm.getName();
         assertNotNull(algorithm);
@@ -135,63 +135,63 @@ public class HmacAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testGetHmacEmptyKey(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testGetHmacEmptyKey(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> HmacUtils.getInitializedMac(hmacAlgorithm, EMPTY_BYTE_ARRAY));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testGetHmacNullKey(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testGetHmacNullKey(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> HmacUtils.getInitializedMac(hmacAlgorithm, null));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testHmacFailByteArray(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testHmacFailByteArray(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> new HmacUtils(hmacAlgorithm, (byte[]) null).hmac(STANDARD_PHRASE_BYTES));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testHmacFailInputStream(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testHmacFailInputStream(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> new HmacUtils(hmacAlgorithm, (byte[]) null).hmac(new ByteArrayInputStream(STANDARD_PHRASE_BYTES)));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testHmacFailString(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testHmacFailString(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> new HmacUtils(hmacAlgorithm, (String) null).hmac(STANDARD_PHRASE_STRING));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testHmacHexFailByteArray(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testHmacHexFailByteArray(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> new HmacUtils(hmacAlgorithm, (byte[]) null).hmac(STANDARD_PHRASE_BYTES));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testHmacHexFailInputStream(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testHmacHexFailInputStream(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> new HmacUtils(hmacAlgorithm, (byte[]) null).hmac(new ByteArrayInputStream(STANDARD_PHRASE_BYTES)));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testHmacHexFailString(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testHmacHexFailString(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertThrows(IllegalArgumentException.class, () -> new HmacUtils(hmacAlgorithm, (String) null).hmac(STANDARD_PHRASE_STRING));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testInitializedMac(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testInitializedMac(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         final Mac mac = HmacUtils.getInitializedMac(hmacAlgorithm, STANDARD_KEY_BYTES);
         final Mac mac2 = HmacUtils.getInitializedMac(hmacAlgorithm.getName(), STANDARD_KEY_BYTES);
@@ -201,21 +201,21 @@ public class HmacAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testMacByteArary(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testMacByteArary(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertArrayEquals(standardResultBytes, new HmacUtils(hmacAlgorithm, STANDARD_KEY_BYTES).hmac(STANDARD_PHRASE_BYTES));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testMacHexByteArray(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testMacHexByteArray(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertEquals(standardResultString, new HmacUtils(hmacAlgorithm, STANDARD_KEY_BYTES).hmacHex(STANDARD_PHRASE_BYTES));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testMacHexInputStream(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) throws IOException {
+    public void testMacHexInputStream(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) throws IOException {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertEquals(standardResultString,
                 new HmacUtils(hmacAlgorithm, STANDARD_KEY_BYTES).hmacHex(new ByteArrayInputStream(STANDARD_PHRASE_BYTES)));
@@ -223,14 +223,14 @@ public class HmacAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testMacHexString(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testMacHexString(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertEquals(standardResultString, new HmacUtils(hmacAlgorithm, STANDARD_KEY_BYTES).hmacHex(STANDARD_PHRASE_STRING));
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testMacInputStream(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) throws IOException {
+    public void testMacInputStream(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) throws IOException {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertArrayEquals(standardResultBytes,
                 new HmacUtils(hmacAlgorithm, STANDARD_KEY_BYTES).hmac(new ByteArrayInputStream(STANDARD_PHRASE_BYTES)));
@@ -238,7 +238,7 @@ public class HmacAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testMacString(HmacAlgorithms hmacAlgorithm, byte[] standardResultBytes, String standardResultString) {
+    public void testMacString(final HmacAlgorithms hmacAlgorithm, final byte[] standardResultBytes, final String standardResultString) {
         assumeTrue(HmacUtils.isAvailable(hmacAlgorithm));
         assertArrayEquals(standardResultBytes, new HmacUtils(hmacAlgorithm, STANDARD_KEY_BYTES).hmac(STANDARD_PHRASE_STRING));
     }
diff --git a/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java b/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java
index ca1aab2b..b688e598 100644
--- a/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java
+++ b/src/test/java/org/apache/commons/codec/digest/MessageDigestAlgorithmsTest.java
@@ -89,7 +89,7 @@ public class MessageDigestAlgorithmsTest {
 
     private DigestUtilsTest digestUtilsTest;
 
-    private byte[] digestTestData(String messageDigestAlgorithm) {
+    private byte[] digestTestData(final String messageDigestAlgorithm) {
         return DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm),getTestData());
     }
 
@@ -123,7 +123,7 @@ public class MessageDigestAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testAlgorithm(String messageDigestAlgorithm) throws NoSuchAlgorithmException {
+    public void testAlgorithm(final String messageDigestAlgorithm) throws NoSuchAlgorithmException {
         final String algorithm = messageDigestAlgorithm;
         assertNotNull(algorithm);
         assertFalse(algorithm.isEmpty());
@@ -133,7 +133,7 @@ public class MessageDigestAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testDigestByteArray(String messageDigestAlgorithm) {
+    public void testDigestByteArray(final String messageDigestAlgorithm) {
         assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
         assertArrayEquals(digestTestData(messageDigestAlgorithm),
                 DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), getTestData()));
@@ -142,7 +142,7 @@ public class MessageDigestAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testDigestByteBuffer(String messageDigestAlgorithm) {
+    public void testDigestByteBuffer(final String messageDigestAlgorithm) {
         assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
         assertArrayEquals(digestTestData(messageDigestAlgorithm),
                 DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), ByteBuffer.wrap(getTestData())));
@@ -151,7 +151,7 @@ public class MessageDigestAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testDigestFile(String messageDigestAlgorithm) throws IOException {
+    public void testDigestFile(final String messageDigestAlgorithm) throws IOException {
         assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
         assertArrayEquals(digestTestData(messageDigestAlgorithm),
             DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), getTestFile()));
@@ -161,7 +161,7 @@ public class MessageDigestAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testDigestInputStream(String messageDigestAlgorithm) throws IOException {
+    public void testDigestInputStream(final String messageDigestAlgorithm) throws IOException {
         assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
         assertArrayEquals(digestTestData(messageDigestAlgorithm),
                 DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), new ByteArrayInputStream(getTestData())));
@@ -170,7 +170,7 @@ public class MessageDigestAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    private void testDigestPath(String messageDigestAlgorithm, final OpenOption... options) throws IOException {
+    private void testDigestPath(final String messageDigestAlgorithm, final OpenOption... options) throws IOException {
         assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
         assertArrayEquals(digestTestData(messageDigestAlgorithm),
             DigestUtils.digest(DigestUtils.getDigest(messageDigestAlgorithm), getTestPath(), options));
@@ -180,19 +180,19 @@ public class MessageDigestAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testDigestPathOpenOptionsEmpty(String messageDigestAlgorithm) throws IOException {
+    public void testDigestPathOpenOptionsEmpty(final String messageDigestAlgorithm) throws IOException {
         testDigestPath(messageDigestAlgorithm);
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testDigestPathStandardOpenOptionRead(String messageDigestAlgorithm) throws IOException {
+    public void testDigestPathStandardOpenOptionRead(final String messageDigestAlgorithm) throws IOException {
         testDigestPath(messageDigestAlgorithm, StandardOpenOption.READ);
     }
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testGetMessageDigest(String messageDigestAlgorithm) {
+    public void testGetMessageDigest(final String messageDigestAlgorithm) {
         assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
         final MessageDigest messageDigest = DigestUtils.getDigest(messageDigestAlgorithm);
         assertEquals(messageDigestAlgorithm, messageDigest.getAlgorithm());
@@ -200,7 +200,7 @@ public class MessageDigestAlgorithmsTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testNonBlockingDigestRandomAccessFile(String messageDigestAlgorithm) throws IOException {
+    public void testNonBlockingDigestRandomAccessFile(final String messageDigestAlgorithm) throws IOException {
         assumeTrue(DigestUtils.isAvailable(messageDigestAlgorithm));
 
         final byte[] expected = digestTestData(messageDigestAlgorithm);
diff --git a/src/test/java/org/apache/commons/codec/digest/XXHash32Test.java b/src/test/java/org/apache/commons/codec/digest/XXHash32Test.java
index 4b97e021..f8f43b44 100644
--- a/src/test/java/org/apache/commons/codec/digest/XXHash32Test.java
+++ b/src/test/java/org/apache/commons/codec/digest/XXHash32Test.java
@@ -65,7 +65,7 @@ public class XXHash32Test {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void verifyChecksum(String path, String c) throws IOException {
+    public void verifyChecksum(final String path, final String c) throws IOException {
         initData(path, c);
         final XXHash32 h = new XXHash32();
         try (final FileInputStream s = new FileInputStream(file)) {
@@ -77,7 +77,7 @@ public class XXHash32Test {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void verifyIncrementalChecksum(String path, String c) throws IOException {
+    public void verifyIncrementalChecksum(final String path, final String c) throws IOException {
         initData(path, c);
         final XXHash32 h = new XXHash32();
         try (final FileInputStream s = new FileInputStream(file)) {
diff --git a/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java b/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java
index 6f3fdf9d..6215abf4 100644
--- a/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java
+++ b/src/test/java/org/apache/commons/codec/language/bm/LanguageGuessingTest.java
@@ -59,7 +59,7 @@ public class LanguageGuessingTest {
 
     @ParameterizedTest
     @MethodSource("data")
-    public void testLanguageGuessing(String name, String language) {
+    public void testLanguageGuessing(final String name, final String language) {
         final Languages.LanguageSet guesses = this.lang.guessLanguages(name);
 
         assertTrue(guesses.contains(language),


[commons-codec] 03/04: Access constant directly.

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f5ed85f6e278b01a173504dc7b06d3378b11f7e5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun May 22 07:28:18 2022 -0400

    Access constant directly.
---
 src/test/java/org/apache/commons/codec/binary/Base64Test.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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 f6c91978..332c5afa 100644
--- a/src/test/java/org/apache/commons/codec/binary/Base64Test.java
+++ b/src/test/java/org/apache/commons/codec/binary/Base64Test.java
@@ -591,7 +591,7 @@ public class Base64Test {
      */
     @Test
     public void testRfc2045Section2Dot1CrLfDefinition() {
-        assertArrayEquals(new byte[]{13, 10}, Base64.CHUNK_SEPARATOR);
+        assertArrayEquals(new byte[]{13, 10}, BaseNCodec.CHUNK_SEPARATOR);
     }
 
     /**
@@ -653,7 +653,7 @@ public class Base64Test {
      */
     @Test
     public void testRfc4648Section10DecodeWithCrLf() {
-        final String CRLF = StringUtils.newStringUsAscii(Base64.CHUNK_SEPARATOR);
+        final String CRLF = StringUtils.newStringUsAscii(BaseNCodec.CHUNK_SEPARATOR);
         assertEquals("", StringUtils.newStringUsAscii(Base64.decodeBase64("" + CRLF)));
         assertEquals("f", StringUtils.newStringUsAscii(Base64.decodeBase64("Zg==" + CRLF)));
         assertEquals("fo", StringUtils.newStringUsAscii(Base64.decodeBase64("Zm8=" + CRLF)));