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 <[email protected]> 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),
