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 2026/04/07 12:55:48 UTC

(commons-compress) branch master updated (3c2c3e70a -> b85c70102)

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-compress.git


    from 3c2c3e70a Add tests
     new 48411e44f Rename test method
     new 084129d31 Add tests
     new b85c70102 Use final

The 3 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:
 .../apache/commons/compress/archivers/ZipTest.java |  2 +-
 .../archivers/cpio/CpioArchiveEntryTest.java       |  2 +-
 .../compress/archivers/dump/Compress712Test.java   |  2 +-
 .../compress/archivers/sevenz/SevenZFileTest.java  | 20 ++++----
 .../archivers/sevenz/SevenZOutputFileTest.java     | 27 ++++++++++-
 .../archivers/zip/UnshrinkingInputStreamTest.java  |  2 +-
 .../compress/archivers/zip/ZipFileTest.java        | 54 ++++++++++++++++------
 .../internal/AttributeLayoutParserTest.java        | 28 +++++------
 .../harmony/internal/AttributeLayoutUtilsTest.java |  4 +-
 .../harmony/unpack200/NewAttributeBandsTest.java   |  4 +-
 .../apache/commons/compress/utils/IOUtilsTest.java | 23 +++++++--
 .../MultiReadOnlySeekableByteChannelTest.java      |  3 +-
 .../ZipSplitReadOnlySeekableByteChannelTest.java   |  9 ++++
 13 files changed, 130 insertions(+), 50 deletions(-)


(commons-compress) 02/03: Add tests

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-compress.git

commit 084129d31369ba3b4e7172c217dc82cdfb77364e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Apr 7 08:53:20 2026 -0400

    Add tests
    
    - Add non-deprecated version of some tests
    - Migrate from deprecated APIs for some other tests
---
 .../compress/archivers/sevenz/SevenZFileTest.java  | 20 ++++----
 .../archivers/sevenz/SevenZOutputFileTest.java     | 27 ++++++++++-
 .../compress/archivers/zip/ZipFileTest.java        | 54 ++++++++++++++++------
 .../apache/commons/compress/utils/IOUtilsTest.java | 23 +++++++--
 .../MultiReadOnlySeekableByteChannelTest.java      |  3 +-
 .../ZipSplitReadOnlySeekableByteChannelTest.java   |  9 ++++
 6 files changed, 108 insertions(+), 28 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
index 7bcedee00..1962d1f17 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java
@@ -63,6 +63,8 @@
 import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.channels.ByteArraySeekableByteChannel;
+import org.apache.commons.io.function.IOIterator;
+import org.apache.commons.io.function.IOStream;
 import org.apache.commons.io.input.ChecksumInputStream;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -547,9 +549,8 @@ void testGetDefaultName() throws Exception {
     }
 
     @Test
-    void testGetEntriesOfUnarchiveInMemory() throws IOException {
-        final byte[] data = readAllBytes("bla.7z");
-        try (SevenZFile sevenZFile = SevenZFile.builder().setChannel(ByteArraySeekableByteChannel.wrap(data)).get()) {
+    void testGetEntriesOfUnarchive() throws IOException {
+        try (SevenZFile sevenZFile = getSevenZFile("bla.7z")) {
             final Iterable<SevenZArchiveEntry> entries = sevenZFile.getEntries();
             final Iterator<SevenZArchiveEntry> iter = entries.iterator();
             SevenZArchiveEntry entry = iter.next();
@@ -561,11 +562,11 @@ void testGetEntriesOfUnarchiveInMemory() throws IOException {
     }
 
     @Test
-    void testGetEntriesOfUnarchiveInMemoryDeprecacted() throws IOException {
+    void testGetEntriesOfUnarchiveInMemory() throws IOException {
         final byte[] data = readAllBytes("bla.7z");
-        try (SevenZFile sevenZFile = SevenZFile.builder().setSeekableByteChannel(new SeekableInMemoryByteChannel(data)).get()) {
-            final Iterable<SevenZArchiveEntry> entries = sevenZFile.getEntries();
-            final Iterator<SevenZArchiveEntry> iter = entries.iterator();
+        try (SevenZFile sevenZFile = SevenZFile.builder().setChannel(ByteArraySeekableByteChannel.wrap(data)).get()) {
+            final IOStream<? extends SevenZArchiveEntry> entries = sevenZFile.stream();
+            final IOIterator<? extends SevenZArchiveEntry> iter = entries.iterator();
             SevenZArchiveEntry entry = iter.next();
             assertEquals("test1.xml", entry.getName());
             entry = iter.next();
@@ -575,8 +576,9 @@ void testGetEntriesOfUnarchiveInMemoryDeprecacted() throws IOException {
     }
 
     @Test
-    void testGetEntriesOfUnarchive() throws IOException {
-        try (SevenZFile sevenZFile = getSevenZFile("bla.7z")) {
+    void testGetEntriesOfUnarchiveInMemoryDeprecacted() throws IOException {
+        final byte[] data = readAllBytes("bla.7z");
+        try (SevenZFile sevenZFile = SevenZFile.builder().setSeekableByteChannel(new SeekableInMemoryByteChannel(data)).get()) {
             final Iterable<SevenZArchiveEntry> entries = sevenZFile.getEntries();
             final Iterator<SevenZArchiveEntry> iter = entries.iterator();
             SevenZArchiveEntry entry = iter.next();
diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
index ddcf781f7..c16e471fb 100644
--- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZOutputFileTest.java
@@ -46,6 +46,7 @@
 import org.apache.commons.compress.archivers.ArchiveException;
 import org.apache.commons.compress.utils.SeekableInMemoryByteChannel;
 import org.apache.commons.compress.utils.TimeUtilsTest;
+import org.apache.commons.io.channels.ByteArraySeekableByteChannel;
 import org.apache.commons.lang3.ArrayUtils;
 import org.junit.jupiter.api.Test;
 import org.tukaani.xz.LZMA2Options;
@@ -99,6 +100,16 @@ private void addFile(final SevenZOutputFile archive, final int index, final int
         archive.closeArchiveEntry();
     }
 
+    private void createAndReadBack(final ByteArraySeekableByteChannel output, final Iterable<SevenZMethodConfiguration> methods) throws Exception {
+        try (SevenZOutputFile outArchive = new SevenZOutputFile(output)) {
+            outArchive.setContentMethods(methods);
+            addFile(outArchive, 0, true);
+        }
+        try (SevenZFile archive = SevenZFile.builder().setByteArray(output.array()).setDefaultName("in memory").get()) {
+            assertEquals(Boolean.TRUE, verifyFile(archive, 0, methods));
+        }
+    }
+
     private void createAndReadBack(final File output, final Iterable<SevenZMethodConfiguration> methods) throws Exception {
         try (SevenZOutputFile outArchive = new SevenZOutputFile(output)) {
             outArchive.setContentMethods(methods);
@@ -110,7 +121,7 @@ private void createAndReadBack(final File output, final Iterable<SevenZMethodCon
         }
     }
 
-    private void createAndReadBack(final SeekableInMemoryByteChannel output, final Iterable<SevenZMethodConfiguration> methods) throws Exception {
+    private void createAndReadBackDeprecated(final SeekableInMemoryByteChannel output, final Iterable<SevenZMethodConfiguration> methods) throws Exception {
         try (SevenZOutputFile outArchive = new SevenZOutputFile(output)) {
             outArchive.setContentMethods(methods);
             addFile(outArchive, 0, true);
@@ -600,11 +611,23 @@ void testStackOfContentCompressionsInMemory() throws Exception {
         methods.add(new SevenZMethodConfiguration(SevenZMethod.COPY));
         methods.add(new SevenZMethodConfiguration(SevenZMethod.DEFLATE));
         methods.add(new SevenZMethodConfiguration(SevenZMethod.BZIP2));
-        try (SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel()) {
+        try (ByteArraySeekableByteChannel channel = new ByteArraySeekableByteChannel()) {
             createAndReadBack(channel, methods);
         }
     }
 
+    @Test
+    void testStackOfContentCompressionsInMemoryDeprecated() throws Exception {
+        final ArrayList<SevenZMethodConfiguration> methods = new ArrayList<>();
+        methods.add(new SevenZMethodConfiguration(SevenZMethod.LZMA2));
+        methods.add(new SevenZMethodConfiguration(SevenZMethod.COPY));
+        methods.add(new SevenZMethodConfiguration(SevenZMethod.DEFLATE));
+        methods.add(new SevenZMethodConfiguration(SevenZMethod.BZIP2));
+        try (SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel()) {
+            createAndReadBackDeprecated(channel, methods);
+        }
+    }
+
     @Test
     void testTwentyNineEmptyFiles() throws Exception {
         testCompress252(29, 0);
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
index be29b7835..05d211c8e 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileTest.java
@@ -51,6 +51,8 @@
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+import java.util.function.Supplier;
 import java.util.zip.CRC32;
 import java.util.zip.Deflater;
 import java.util.zip.ZipEntry;
@@ -356,12 +358,16 @@ void testConcurrentReadFile() throws Exception {
 
     @Test
     void testConcurrentReadSeekable() throws Exception {
+        testConcurrentReadSeekable(ByteArraySeekableByteChannel::wrap);
+    }
+
+    void testConcurrentReadSeekable(final Function<byte[], SeekableByteChannel> factory) throws Exception {
         // mixed.zip contains both inflated and stored files
         final byte[] data;
         try (InputStream fis = newInputStream("mixed.zip")) {
             data = IOUtils.toByteArray(fis);
         }
-        try (SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel(data)) {
+        try (SeekableByteChannel channel = factory.apply(data)) {
             zf = ZipFile.builder().setChannel(channel).setCharset(StandardCharsets.UTF_8).get();
             final Map<String, byte[]> content = new HashMap<>();
             zf.stream().forEach(entry -> {
@@ -384,6 +390,11 @@ void testConcurrentReadSeekable() throws Exception {
         }
     }
 
+    @Test
+    void testConcurrentReadSeekableDeprecated() throws Exception {
+        testConcurrentReadSeekable(SeekableInMemoryByteChannel::new);
+    }
+
     @Test
     void testCreateBoundedInputStream() throws IOException {
         try (ZipFile zipFile = ZipFile.builder().setPath("src/test/resources/org/apache/commons/compress/zip/createBoundedInputStream.bin").get()) {
@@ -473,7 +484,11 @@ void testEmptyCentralDirectory() throws Exception {
      */
     @Test
     void testEntryAlignment() throws Exception {
-        try (SeekableInMemoryByteChannel zipContent = new SeekableInMemoryByteChannel()) {
+        testEntryAlignment(ByteArraySeekableByteChannel::new, s -> ((ByteArraySeekableByteChannel) s).array());
+    }
+
+    private void testEntryAlignment(final Supplier<SeekableByteChannel> supplier, final Function<SeekableByteChannel, byte[]> arrayAccessor) throws Exception {
+        try (SeekableByteChannel zipContent = supplier.get()) {
             try (ZipArchiveOutputStream zipOutput = new ZipArchiveOutputStream(zipContent)) {
                 final ZipArchiveEntry inflatedEntry = new ZipArchiveEntry("inflated.txt");
                 inflatedEntry.setMethod(ZipEntry.DEFLATED);
@@ -481,14 +496,12 @@ void testEntryAlignment() throws Exception {
                 zipOutput.putArchiveEntry(inflatedEntry);
                 zipOutput.writeUtf8("Hello Deflated\n");
                 zipOutput.closeArchiveEntry();
-
                 final ZipArchiveEntry storedEntry = new ZipArchiveEntry("stored.txt");
                 storedEntry.setMethod(ZipEntry.STORED);
                 storedEntry.setAlignment(1024);
                 zipOutput.putArchiveEntry(storedEntry);
                 zipOutput.writeUtf8("Hello Stored\n");
                 zipOutput.closeArchiveEntry();
-
                 final ZipArchiveEntry storedEntry2 = new ZipArchiveEntry("stored2.txt");
                 storedEntry2.setMethod(ZipEntry.STORED);
                 storedEntry2.setAlignment(1024);
@@ -496,18 +509,15 @@ void testEntryAlignment() throws Exception {
                 zipOutput.putArchiveEntry(storedEntry2);
                 zipOutput.writeUtf8("Hello overload-alignment Stored\n");
                 zipOutput.closeArchiveEntry();
-
                 final ZipArchiveEntry storedEntry3 = new ZipArchiveEntry("stored3.txt");
                 storedEntry3.setMethod(ZipEntry.STORED);
                 storedEntry3.addExtraField(new ResourceAlignmentExtraField(1024));
                 zipOutput.putArchiveEntry(storedEntry3);
                 zipOutput.writeUtf8("Hello copy-alignment Stored\n");
                 zipOutput.closeArchiveEntry();
-
             }
-
-            try (ZipFile zf = ZipFile.builder().setByteArray(Arrays.copyOfRange(zipContent.array(), 0, (int) FieldUtils.readDeclaredField(zipContent, "size",
-                    true))).get()) {
+            try (ZipFile zf = ZipFile.builder()
+                    .setByteArray(Arrays.copyOfRange(arrayAccessor.apply(zipContent), 0, (int) FieldUtils.readDeclaredField(zipContent, "size", true))).get()) {
                 final ZipArchiveEntry inflatedEntry = zf.getEntry("inflated.txt");
                 final ResourceAlignmentExtraField inflatedAlignmentEx = (ResourceAlignmentExtraField) inflatedEntry
                         .getExtraField(ResourceAlignmentExtraField.ID);
@@ -531,7 +541,6 @@ void testEntryAlignment() throws Exception {
                 try (InputStream stream = zf.getInputStream(storedEntry)) {
                     assertEquals("Hello Stored\n", new String(IOUtils.toByteArray(stream), UTF_8));
                 }
-
                 final ZipArchiveEntry storedEntry2 = zf.getEntry("stored2.txt");
                 final ResourceAlignmentExtraField stored2AlignmentEx = (ResourceAlignmentExtraField) storedEntry2.getExtraField(ResourceAlignmentExtraField.ID);
                 assertNotEquals(-1L, storedEntry2.getCompressedSize());
@@ -543,7 +552,6 @@ void testEntryAlignment() throws Exception {
                 try (InputStream stream = zf.getInputStream(storedEntry2)) {
                     assertEquals("Hello overload-alignment Stored\n", new String(IOUtils.toByteArray(stream), UTF_8));
                 }
-
                 final ZipArchiveEntry storedEntry3 = zf.getEntry("stored3.txt");
                 final ResourceAlignmentExtraField stored3AlignmentEx = (ResourceAlignmentExtraField) storedEntry3.getExtraField(ResourceAlignmentExtraField.ID);
                 assertNotEquals(-1L, storedEntry3.getCompressedSize());
@@ -559,19 +567,39 @@ void testEntryAlignment() throws Exception {
         }
     }
 
+    @Test
+    void testEntryAlignmentDeprecated() throws Exception {
+        testEntryAlignment(SeekableInMemoryByteChannel::new, s -> ((SeekableInMemoryByteChannel) s).array());
+    }
+
     /**
      * Test too big alignment, resulting into exceeding extra field limit.
      */
     @Test
     void testEntryAlignmentExceed() throws Exception {
-        try (SeekableInMemoryByteChannel zipContent = new SeekableInMemoryByteChannel();
-                ZipArchiveOutputStream zipOutput = new ZipArchiveOutputStream(zipContent)) {
+        try (SeekableByteChannel zipContent = new ByteArraySeekableByteChannel()) {
+            testEntryAlignmentExceed(zipContent);
+        }
+    }
+
+    private void testEntryAlignmentExceed(final SeekableByteChannel zipContent) throws IOException {
+        try (ZipArchiveOutputStream zipOutput = new ZipArchiveOutputStream(zipContent)) {
             final ZipArchiveEntry inflatedEntry = new ZipArchiveEntry("inflated.txt");
             inflatedEntry.setMethod(ZipEntry.STORED);
             assertThrows(IllegalArgumentException.class, () -> inflatedEntry.setAlignment(0x20000));
         }
     }
 
+    /**
+     * Test too big alignment, resulting into exceeding extra field limit.
+     */
+    @Test
+    void testEntryAlignmentExceedDeprecated() throws Exception {
+        try (SeekableByteChannel zipContent = new SeekableInMemoryByteChannel()) {
+            testEntryAlignmentExceed(zipContent);
+        }
+    }
+
     /**
      * @see "https://issues.apache.org/jira/browse/COMPRESS-228"
      */
diff --git a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
index be73d7942..d3fa1ddc3 100644
--- a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
@@ -35,6 +35,7 @@
 import java.nio.channels.ReadableByteChannel;
 import java.nio.charset.StandardCharsets;
 
+import org.apache.commons.io.channels.ByteArraySeekableByteChannel;
 import org.apache.commons.io.input.NullInputStream;
 import org.apache.commons.io.output.NullOutputStream;
 import org.apache.commons.lang3.ArrayUtils;
@@ -47,7 +48,7 @@ private interface StreamWrapper {
     }
 
     private static void readFully(final byte[] source, final ByteBuffer b) throws IOException {
-        try (SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel(source)) {
+        try (ByteArraySeekableByteChannel channel = ByteArraySeekableByteChannel.wrap(source)) {
             IOUtils.readFully(channel, b);
         }
     }
@@ -140,7 +141,7 @@ void testReadFullyOnChannelThrowsEof() {
 
     @Test
     void testReadRangeFromChannelDoesntReadMoreThanAskedFor() throws IOException {
-        try (ReadableByteChannel in = new SeekableInMemoryByteChannel(new byte[] { 1, 2, 3, 4, 5 })) {
+        try (ReadableByteChannel in = ByteArraySeekableByteChannel.wrap(new byte[] { 1, 2, 3, 4, 5 })) {
             final byte[] read = IOUtils.readRange(in, 3);
             assertArrayEquals(new byte[] { 1, 2, 3 }, read);
             final ByteBuffer b = ByteBuffer.allocate(1);
@@ -170,7 +171,7 @@ public int read(ByteBuffer buf) throws IOException {
 
     @Test
     void testReadRangeFromChannelStopsIfThereIsNothingToReadAnymore() throws IOException {
-        try (ReadableByteChannel in = new SeekableInMemoryByteChannel(new byte[] { 1, 2, 3, 4, 5 })) {
+        try (ReadableByteChannel in = ByteArraySeekableByteChannel.wrap(new byte[] { 1, 2, 3, 4, 5 })) {
             final byte[] read = IOUtils.readRange(in, 10);
             assertArrayEquals(new byte[] { 1, 2, 3, 4, 5 }, read);
             final ByteBuffer b = ByteBuffer.allocate(1);
@@ -203,6 +204,22 @@ void testReadRangeMoreThanCopyBufferSize() throws Exception {
         // Make an input that requires two read loops to trigger COMPRESS-585
         final byte[] input = new byte[copyBufSize + 10];
 
+        try (ByteArraySeekableByteChannel in = ByteArraySeekableByteChannel.wrap(input)) {
+            // Ask for less than the input length, but more than the buffer size
+            final int toRead = copyBufSize + 1;
+            final byte[] read = IOUtils.readRange(in, toRead);
+            assertEquals(toRead, read.length);
+            assertEquals(toRead, in.position());
+        }
+    }
+
+    @Test
+    void testReadRangeMoreThanCopyBufferSizeDeprecated() throws Exception {
+        final int copyBufSize = org.apache.commons.io.IOUtils.DEFAULT_BUFFER_SIZE;
+
+        // Make an input that requires two read loops to trigger COMPRESS-585
+        final byte[] input = new byte[copyBufSize + 10];
+
         try (SeekableInMemoryByteChannel in = new SeekableInMemoryByteChannel(input)) {
             // Ask for less than the input length, but more than the buffer size
             final int toRead = copyBufSize + 1;
diff --git a/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java b/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java
index 475d6ffba..a6d9c43bd 100644
--- a/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/MultiReadOnlySeekableByteChannelTest.java
@@ -37,6 +37,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.commons.io.channels.ByteArraySeekableByteChannel;
 import org.apache.commons.lang3.ArrayUtils;
 import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
@@ -200,7 +201,7 @@ private SeekableByteChannel makeMulti(final byte[][] arr) {
     }
 
     private SeekableByteChannel makeSingle(final byte[] arr) {
-        return new SeekableInMemoryByteChannel(arr);
+        return ByteArraySeekableByteChannel.wrap(arr);
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/compress/utils/ZipSplitReadOnlySeekableByteChannelTest.java b/src/test/java/org/apache/commons/compress/utils/ZipSplitReadOnlySeekableByteChannelTest.java
index 3f3872125..9ccb9ea08 100644
--- a/src/test/java/org/apache/commons/compress/utils/ZipSplitReadOnlySeekableByteChannelTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/ZipSplitReadOnlySeekableByteChannelTest.java
@@ -37,6 +37,7 @@
 import java.util.Random;
 
 import org.apache.commons.compress.archivers.zip.ZipSplitReadOnlySeekableByteChannel;
+import org.apache.commons.io.channels.ByteArraySeekableByteChannel;
 import org.apache.commons.lang3.ArrayUtils;
 import org.junit.jupiter.api.Test;
 
@@ -147,6 +148,14 @@ void testForOrderedSeekableByteChannelsReturnCorrectClass() throws IOException {
 
     @Test
     void testForOrderedSeekableByteChannelsReturnsIdentityForSingleElement() throws IOException {
+        try (SeekableByteChannel emptyChannel = ByteArraySeekableByteChannel.wrap(ArrayUtils.EMPTY_BYTE_ARRAY);
+                SeekableByteChannel channel = ZipSplitReadOnlySeekableByteChannel.forOrderedSeekableByteChannels(emptyChannel)) {
+            assertSame(emptyChannel, channel);
+        }
+    }
+
+    @Test
+    void testForOrderedSeekableByteChannelsReturnsIdentityForSingleElementDeprecated() throws IOException {
         try (SeekableByteChannel emptyChannel = new SeekableInMemoryByteChannel(ArrayUtils.EMPTY_BYTE_ARRAY);
                 SeekableByteChannel channel = ZipSplitReadOnlySeekableByteChannel.forOrderedSeekableByteChannels(emptyChannel)) {
             assertSame(emptyChannel, channel);


(commons-compress) 01/03: Rename test method

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-compress.git

commit 48411e44f91887583b91f1970a0f33f622c2a134
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Apr 7 08:29:13 2026 -0400

    Rename test method
---
 src/test/java/org/apache/commons/compress/archivers/ZipTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/ZipTest.java b/src/test/java/org/apache/commons/compress/archivers/ZipTest.java
index a130c091c..109f740c4 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ZipTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ZipTest.java
@@ -804,7 +804,7 @@ void testZipArchiveCreationInMemory() throws Exception {
      * @throws Exception
      */
     @Test
-    void testZipArchiveCreationInMemoryDepreacted() throws Exception {
+    void testZipArchiveCreationInMemoryDeprecated() throws Exception {
         final byte[] file1Contents = readAllBytes("test1.xml");
         final byte[] file2Contents = readAllBytes("test2.xml");
         final List<byte[]> results = new ArrayList<>();


(commons-compress) 03/03: 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-compress.git

commit b85c70102968697a30f9ef4099bf38d482a563a3
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Apr 7 08:55:42 2026 -0400

    Use final
    
    Use compact array declarations
---
 .../archivers/cpio/CpioArchiveEntryTest.java       |  2 +-
 .../compress/archivers/dump/Compress712Test.java   |  2 +-
 .../archivers/zip/UnshrinkingInputStreamTest.java  |  2 +-
 .../internal/AttributeLayoutParserTest.java        | 28 +++++++++++-----------
 .../harmony/internal/AttributeLayoutUtilsTest.java |  4 ++--
 .../harmony/unpack200/NewAttributeBandsTest.java   |  4 ++--
 6 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntryTest.java b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntryTest.java
index dd656bbf6..c5311598c 100644
--- a/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntryTest.java
@@ -36,7 +36,7 @@ void testCpioEntrySizeOldAsciiFormatOver4GiB() {
 
     @ParameterizedTest
     @ValueSource(shorts = {CpioConstants.FORMAT_NEW, CpioConstants.FORMAT_NEW_CRC, CpioConstants.FORMAT_OLD_BINARY})
-    void testCpioEntrySizeUnder4GiBNotOldAsciiFormat(short format) {
+    void testCpioEntrySizeUnder4GiBNotOldAsciiFormat(final short format) {
         final CpioArchiveEntry entry = new CpioArchiveEntry(format);
         assertThrows(IllegalArgumentException.class, () -> entry.setSize(0x1FFFFFFFFL));
     }
diff --git a/src/test/java/org/apache/commons/compress/archivers/dump/Compress712Test.java b/src/test/java/org/apache/commons/compress/archivers/dump/Compress712Test.java
index 53e6ffa42..127095da1 100644
--- a/src/test/java/org/apache/commons/compress/archivers/dump/Compress712Test.java
+++ b/src/test/java/org/apache/commons/compress/archivers/dump/Compress712Test.java
@@ -178,7 +178,7 @@ public void testPart1() throws IOException {
 
     @Test
     public void testPart2() throws IOException {
-        final byte[] data = new byte[] { 1, 0, 0, 0, -50, 46, 75, 78, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, -22, 0, 0, -50, -24, -112, -115, 0,
+        final byte[] data = { 1, 0, 0, 0, -50, 46, 75, 78, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, -22, 0, 0, -50, -24, -112, -115, 0,
                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/UnshrinkingInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/UnshrinkingInputStreamTest.java
index c22e452af..842171f37 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/UnshrinkingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/UnshrinkingInputStreamTest.java
@@ -43,7 +43,7 @@ private static byte[] encodeLsbFirst9Bit(final int... codes) {
         int bitBuffer = 0;
         int bitCount = 0;
 
-        for (int code : codes) {
+        for (final int code : codes) {
             bitBuffer |= (code & 0x1FF) << bitCount;
             bitCount += 9;
 
diff --git a/src/test/java/org/apache/commons/compress/harmony/internal/AttributeLayoutParserTest.java b/src/test/java/org/apache/commons/compress/harmony/internal/AttributeLayoutParserTest.java
index 7c45618ad..2eaef9927 100644
--- a/src/test/java/org/apache/commons/compress/harmony/internal/AttributeLayoutParserTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/internal/AttributeLayoutParserTest.java
@@ -35,50 +35,50 @@ public class AttributeLayoutParserTest {
     private static class AttributeLayoutFactory implements AttributeLayoutParser.Factory<LayoutElement> {
 
         @Override
-        public LayoutElement createCall(int callableIndex) {
+        public LayoutElement createCall(final int callableIndex) {
             return new LayoutElement(callableIndex);
         }
 
         @Override
-        public LayoutElement createCallable(List<LayoutElement> body) {
+        public LayoutElement createCallable(final List<LayoutElement> body) {
             return new LayoutElement(body);
         }
 
         @Override
-        public LayoutElement createIntegral(String tag) {
+        public LayoutElement createIntegral(final String tag) {
             return new LayoutElement(tag);
         }
 
         @Override
-        public LayoutElement createReference(String tag) {
+        public LayoutElement createReference(final String tag) {
             return new LayoutElement(tag);
         }
 
         @Override
-        public LayoutElement createReplication(String unsignedInt, List<LayoutElement> body) {
+        public LayoutElement createReplication(final String unsignedInt, final List<LayoutElement> body) {
             return new LayoutElement(unsignedInt, body);
         }
 
         @Override
-        public LayoutElement createUnion(String anyInt, List<AttributeLayoutParser.UnionCaseData<LayoutElement>> cases, List<LayoutElement> body) {
+        public LayoutElement createUnion(final String anyInt, final List<AttributeLayoutParser.UnionCaseData<LayoutElement>> cases, final List<LayoutElement> body) {
             return new LayoutElement(anyInt, cases, body);
         }
     }
 
     private static class LayoutElement {
-        private LayoutElement(int callableIndex) {
+        private LayoutElement(final int callableIndex) {
         }
 
-        private LayoutElement(List<LayoutElement> body) {
+        private LayoutElement(final List<LayoutElement> body) {
         }
 
-        private LayoutElement(String tag) {
+        private LayoutElement(final String tag) {
         }
 
-        private LayoutElement(String anyInt, List<AttributeLayoutParser.UnionCaseData<LayoutElement>> cases, List<LayoutElement> body) {
+        private LayoutElement(final String anyInt, final List<AttributeLayoutParser.UnionCaseData<LayoutElement>> cases, final List<LayoutElement> body) {
         }
 
-        private LayoutElement(String unsignedInt, List<LayoutElement> body) {
+        private LayoutElement(final String unsignedInt, final List<LayoutElement> body) {
         }
     }
 
@@ -121,7 +121,7 @@ static Stream<String> validLayouts() {
             "T", "TA", "TI", "TSA", "TI(A)[]()[]",
             // Invalid call layouts
             "()", "(A)", "(-A)", "(9999999999999999999999)", "(1234"})
-    void testInvalidLayout(String layout) {
+    void testInvalidLayout(final String layout) {
         final AttributeLayoutParser<LayoutElement> parser = new AttributeLayoutParser<>(layout, FACTORY);
         final Pack200Exception ex = assertThrows(Pack200Exception.class, parser::readElement);
         assertTrue(ex.getMessage().contains("Corrupted Pack200 archive"), "Unexpected exception message: " + ex.getMessage());
@@ -130,14 +130,14 @@ void testInvalidLayout(String layout) {
 
     @ParameterizedTest
     @MethodSource("validLayouts")
-    void testReadBody(String layout) throws Pack200Exception {
+    void testReadBody(final String layout) throws Pack200Exception {
         final List<LayoutElement> result = AttributeLayoutUtils.readBody(layout, FACTORY);
         assertFalse(result.isEmpty(), "Expected at least one LayoutElement for layout: " + layout);
     }
 
     @ParameterizedTest
     @MethodSource({"validLayouts", "validCallableLayouts"})
-    void testReadElement(String layout) throws Pack200Exception {
+    void testReadElement(final String layout) throws Pack200Exception {
         final List<LayoutElement> result = AttributeLayoutUtils.readAttributeLayout(layout, FACTORY);
         assertFalse(result.isEmpty(), "Expected at least one LayoutElement for layout: " + layout);
     }
diff --git a/src/test/java/org/apache/commons/compress/harmony/internal/AttributeLayoutUtilsTest.java b/src/test/java/org/apache/commons/compress/harmony/internal/AttributeLayoutUtilsTest.java
index 70c06b858..a1c9d748b 100644
--- a/src/test/java/org/apache/commons/compress/harmony/internal/AttributeLayoutUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/internal/AttributeLayoutUtilsTest.java
@@ -41,13 +41,13 @@ class AttributeLayoutUtilsTest {
             "KI", "RC", "RU", "KIN", "RCN", "RUN",
             // Extra characters
             "KIBB", "RCBB", "RUNNH"})
-    void testCheckReferenceTag_Invalid(String tag) {
+    void testCheckReferenceTag_Invalid(final String tag) {
         assertThrows(IllegalArgumentException.class, () -> AttributeLayoutUtils.checkReferenceTag(tag));
     }
 
     @ParameterizedTest
     @ValueSource(strings = {"KIB", "KJH", "KFI", "KDV", "KSB", "KQV", "KMI", "KTI", "KLV", "RCB", "RCH", "RDI", "RFV", "RMI", "RII", "RYB", "RBNI"})
-    void testCheckReferenceTag_Valid(String tag) {
+    void testCheckReferenceTag_Valid(final String tag) {
         assertEquals(tag, AttributeLayoutUtils.checkReferenceTag(tag));
     }
 
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBandsTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBandsTest.java
index 6a904f130..b7f02e18f 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBandsTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/NewAttributeBandsTest.java
@@ -54,7 +54,7 @@ public List<?> getLayoutElements() {
         }
     }
 
-    private static String createRecursiveLayout(int level, String prefix) {
+    private static String createRecursiveLayout(final int level, final String prefix) {
         final StringBuilder sb = new StringBuilder();
         for (int i = 0; i < level; i++) {
             sb.append(prefix);
@@ -185,7 +185,7 @@ void testLayoutWithCalls() throws IOException, Pack200Exception {
 
     @ParameterizedTest
     @ValueSource(strings = {"NH[", "TH()["})
-    void testRecursiveReplicationLayout(String prefix) {
+    void testRecursiveReplicationLayout(final String prefix) {
         final String layout = createRecursiveLayout(8192, prefix);
         assertThrows(Pack200Exception.class, () -> createNewAttributeBands(layout));
     }