This is an automated email from the ASF dual-hosted git repository. garydgregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 1946f59f21cb61bc658d0f82996cb10b883a61e8 Author: Gary Gregory <[email protected]> AuthorDate: Fri Jul 31 10:36:13 2026 -0400 Use compact array notation Use final --- ...ctLhStaticHuffmanCompressorInputStreamTest.java | 16 ++++++------ .../compress/compressors/lha/BinaryTreeTest.java | 30 +++++++++++----------- .../compressors/lha/CircularBufferTest.java | 8 +++--- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/compressors/lha/AbstractLhStaticHuffmanCompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/lha/AbstractLhStaticHuffmanCompressorInputStreamTest.java index 83abe9f7a..342da17c4 100644 --- a/src/test/java/org/apache/commons/compress/compressors/lha/AbstractLhStaticHuffmanCompressorInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/lha/AbstractLhStaticHuffmanCompressorInputStreamTest.java @@ -84,7 +84,7 @@ void testReadCodeLength() throws IOException { try { createLh5CompressorInputStream(0xff, 0xf8).readCodeLength(); // 1111 1111 1111 1000 fail("Expected CompressorException for code length overflow"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Code length overflow", e.getMessage()); } } @@ -94,7 +94,7 @@ void testReadCodeLengthUnexpectedEndOfStream() throws IOException { try { createLh5CompressorInputStream(0xff).readCodeLength(); // 1111 1111 EOF fail("Expected CompressorException for unexpected end of stream"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Unexpected end of stream", e.getMessage()); } } @@ -107,7 +107,7 @@ void testReadCommandDecodingTreeWithInvalidSize() throws IOException { ).readCommandDecodingTree(); fail("Expected CompressorException for table invalid size"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Code length table has invalid size (20 > 19)", e.getMessage()); } } @@ -126,9 +126,9 @@ void testReadCommandTreeUnexpectedEndOfStream() throws IOException { try { createLh5CompressorInputStream( 0b00000000, 0b01111111 // 9 bits length (0x00) and only 8 bits instead of expected 9 bits which will cause an unexpected end of stream - ).readCommandTree(new BinaryTree(new int [] { 0 })); + ).readCommandTree(new BinaryTree(0)); fail("Expected CompressorException for unexpected end of stream"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Unexpected end of stream", e.getMessage()); } } @@ -138,10 +138,10 @@ void testReadCommandTreeWithInvalidSize() throws IOException { try { createLh5CompressorInputStream( 0b11111111, 0b10000000 // 9 bits length (0x01ff = 511) - ).readCommandTree(new BinaryTree(new int [] { 0 })); + ).readCommandTree(new BinaryTree(0)); fail("Expected CompressorException for table invalid size"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Code length table has invalid size (511 > 510)", e.getMessage()); } } @@ -150,7 +150,7 @@ void testReadCommandTreeWithInvalidSize() throws IOException { void testReadCommandTreeWithSingleValue() throws IOException { final BinaryTree tree = createLh5CompressorInputStream( 0b00000000, 0b01111111, 0b01000000 // 9 bits length (0x00) and 9 bits the root value (0x01fd = 509) - ).readCommandTree(new BinaryTree(new int [] { 0 })); + ).readCommandTree(new BinaryTree(0)); assertEquals(0x01fd, tree.read(new BitInputStream(new ByteArrayInputStream(new byte[0]), ByteOrder.BIG_ENDIAN))); } diff --git a/src/test/java/org/apache/commons/compress/compressors/lha/BinaryTreeTest.java b/src/test/java/org/apache/commons/compress/compressors/lha/BinaryTreeTest.java index a324146a3..8c48936fa 100644 --- a/src/test/java/org/apache/commons/compress/compressors/lha/BinaryTreeTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/lha/BinaryTreeTest.java @@ -45,14 +45,14 @@ void testCheckMaxDepth() throws Exception { try { new BinaryTree(1, 17); fail("Expected CompressorException for depth > 16"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Tree depth must not be negative and not bigger than 16 but is 17", e.getMessage()); } } @Test void testInvalidBitstream() throws Exception { - final int[] length = new int[] { 4, 2, 3, 0, 5, 0, 1 }; + final int[] length = { 4, 2, 3, 0, 5, 0, 1 }; // Value: 0 1 2 3 4 5 6 final BinaryTree tree = new BinaryTree(length); @@ -66,7 +66,7 @@ void testInvalidBitstream() throws Exception { try { assertEquals(5, tree.read(createBitInputStream(0xf8))); // 1111 1xxx fail("Expected CompressorException for invalid bitstream"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Invalid bitstream. The node at index 62 is not defined.", e.getMessage()); } } @@ -76,14 +76,14 @@ void testNoLeafNodes() throws Exception { try { new BinaryTree(0, 0, 0, 0, 0); fail("Expected CompressorException for no leaf nodes"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Tree contains no leaf nodes", e.getMessage()); } } @Test void testReadEof() throws Exception { - final int[] length = new int[] { 4, 2, 3, 0, 5, 5, 1 }; + final int[] length = { 4, 2, 3, 0, 5, 5, 1 }; // Value: 0 1 2 3 4 5 6 final BinaryTree tree = new BinaryTree(length); @@ -100,7 +100,7 @@ void testTooManyLeafNodes() throws Exception { try { new BinaryTree(0, 2, 1, 2, 2); fail("Expected CompressorException for too many leaf nodes"); - } catch (CompressorException e) { + } catch (final CompressorException e) { assertEquals("Tree contains too many leaf nodes for depth 2", e.getMessage()); } } @@ -116,7 +116,7 @@ void testTree1() throws Exception { @Test void testTree10() throws Exception { // Maximum length of 510 entries for command tree and maximum supported depth of 16 - final int[] length = new int[] { 4, 7, 7, 8, 7, 9, 8, 9, 7, 10, 8, 10, 7, 10, 8, 10, 7, 9, 8, 9, 8, 10, 8, 12, 8, 10, 9, 11, 9, 9, 8, 10, 6, 9, + final int[] length = { 4, 7, 7, 8, 7, 9, 8, 9, 7, 10, 8, 10, 7, 10, 8, 10, 7, 9, 8, 9, 8, 10, 8, 12, 8, 10, 9, 11, 9, 9, 8, 10, 6, 9, 7, 9, 8, 10, 8, 11, 7, 9, 8, 9, 8, 9, 8, 9, 7, 9, 8, 8, 8, 10, 9, 11, 8, 9, 8, 10, 8, 9, 8, 9, 7, 7, 7, 8, 8, 8, 8, 9, 7, 8, 7, 9, 8, 9, 8, 8, 8, 10, 7, 7, 8, 8, 8, 9, 8, 9, 8, 9, 9, 10, 9, 10, 7, 8, 9, 9, 8, 7, 7, 7, 8, 8, 9, 8, 8, 9, 8, 8, 8, 11, 8, 9, 8, 8, 9, 10, 9, 9, 8, 10, 8, 10, 9, 9, 7, 9, 9, 10, 9, 10, 9, 9, 9, 10, 9, 11, 10, 11, 9, 10, 8, 10, 9, 11, 9, 10, 10, 12, 9, 11, 9, 12, 10, 14, 10, 14, 10, @@ -154,7 +154,7 @@ void testTree10() throws Exception { @Test void testTree2() throws Exception { - final int[] length = new int[] { 1, 1 }; + final int[] length = { 1, 1 }; // Value: 0 1 final BinaryTree tree = new BinaryTree(length); @@ -165,7 +165,7 @@ void testTree2() throws Exception { @Test void testTree3() throws Exception { - final int[] length = new int[] { 1, 0, 1 }; + final int[] length = { 1, 0, 1 }; // Value: 0 1 2 final BinaryTree tree = new BinaryTree(length); @@ -176,7 +176,7 @@ void testTree3() throws Exception { @Test void testTree4() throws Exception { - final int[] length = new int[] { 2, 0, 1, 2 }; + final int[] length = { 2, 0, 1, 2 }; // Value: 0 1 2 3 final BinaryTree tree = new BinaryTree(length); @@ -188,7 +188,7 @@ void testTree4() throws Exception { @Test void testTree5() throws Exception { - final int[] length = new int[] { 2, 0, 0, 2, 1 }; + final int[] length = { 2, 0, 0, 2, 1 }; // Value: 0 1 2 3 4 final BinaryTree tree = new BinaryTree(length); @@ -200,7 +200,7 @@ void testTree5() throws Exception { @Test void testTree6() throws Exception { - final int[] length = new int[] { 1, 0, 2, 3, 3 }; + final int[] length = { 1, 0, 2, 3, 3 }; // Value: 0 1 2 3 4 final BinaryTree tree = new BinaryTree(length); @@ -213,7 +213,7 @@ void testTree6() throws Exception { @Test void testTree7() throws Exception { - final int[] length = new int[] { 0, 0, 0, 0, 1, 1 }; + final int[] length = { 0, 0, 0, 0, 1, 1 }; // Value: 0 1 2 3 4 5 final BinaryTree tree = new BinaryTree(length); @@ -224,7 +224,7 @@ void testTree7() throws Exception { @Test void testTree8() throws Exception { - final int[] length = new int[] { 4, 2, 3, 0, 5, 5, 1 }; + final int[] length = { 4, 2, 3, 0, 5, 5, 1 }; // Value: 0 1 2 3 4 5 6 final BinaryTree tree = new BinaryTree(length); @@ -239,7 +239,7 @@ void testTree8() throws Exception { @Test void testTree9() throws Exception { - final int[] length = new int[] { 5, 6, 6, 0, 0, 8, 7, 7, 7, 4, 3, 2, 2, 4, 5, 5, 5, 4, 8 }; + final int[] length = { 5, 6, 6, 0, 0, 8, 7, 7, 7, 4, 3, 2, 2, 4, 5, 5, 5, 4, 8 }; // Value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 final BinaryTree tree = new BinaryTree(length); diff --git a/src/test/java/org/apache/commons/compress/compressors/lha/CircularBufferTest.java b/src/test/java/org/apache/commons/compress/compressors/lha/CircularBufferTest.java index 1025af26a..569509741 100644 --- a/src/test/java/org/apache/commons/compress/compressors/lha/CircularBufferTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/lha/CircularBufferTest.java @@ -161,7 +161,7 @@ void testCopyCausingBufferOverflow() { try { buffer.copy(4, 4); // Copying 4 bytes and write to the buffer that will be full during copy fail("Expected IllegalStateException for buffer overflow during copy"); - } catch (IllegalStateException e) { + } catch (final IllegalStateException e) { assertEquals("Buffer overflow: Cannot write to a full buffer", e.getMessage()); } } @@ -179,7 +179,7 @@ void testCopyDistanceExceedingBufferSize() { try { buffer.copy(5, 2); // Try to copy from a distance that is bigger than the buffer size fail("Expected IllegalArgumentException for distance exceeding buffer size"); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { assertEquals("Distance exceeds buffer size", e.getMessage()); } } @@ -195,7 +195,7 @@ void testCopyDistanceInvalid() { try { buffer.copy(0, 2); // Try to copy from distance 0 fail("Expected IllegalArgumentException for invalid distance"); - } catch (IllegalArgumentException e) { + } catch (final IllegalArgumentException e) { assertEquals("Distance must be at least 1", e.getMessage()); } } @@ -305,7 +305,7 @@ void testPutOverflow() { try { buffer.put(0x05); fail("Expected IllegalStateException for buffer overflow"); - } catch (IllegalStateException e) { + } catch (final IllegalStateException e) { assertEquals("Buffer overflow: Cannot write to a full buffer", e.getMessage()); } }
