You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ppkarwasz (via GitHub)" <gi...@apache.org> on 2025/09/20 08:49:09 UTC

[PR] tests: Add coverage for deprecated and single-argument constructors [commons-compress]

ppkarwasz opened a new pull request, #708:
URL: https://github.com/apache/commons-compress/pull/708

   This change ensures that behavior of legacy constructors remains consistent with version `1.28.0` while paving the way for their eventual removal.
   
   **Key changes:**
   
   * Introduces a new `LegacyConstructorsTest` class that verifies the parameter values of *deprecated* constructors. *Rationale:* this provides explicit coverage and will allow us to remove both the constructors and their tests in one step when deprecations are finalized.
   * Adds equivalent test cases for non-deprecated single-argument constructors in their corresponding test classes.
   * Makes the constructor of `TarArchiveInputStream.Builder` private, aligning it with the visibility of other builder constructors.
   * Fixes Javadoc on deprecated constructors, which previously (incorrectly) suggested using private `Builder()` constructors.
   
   Before you push a pull request, review this list:
   
   - [ ] Read the [contribution guidelines](CONTRIBUTING.md) for this project.
   - [ ] Read the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) if you use Artificial Intelligence (AI).
   - [x] I used AI to create the PR description.
   - [x] Run a successful build using the default [Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command line by itself.
   - [x] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best-practice.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] tests: Add coverage for deprecated and single-argument constructors [commons-compress]

Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #708:
URL: https://github.com/apache/commons-compress/pull/708


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] tests: Add coverage for deprecated and single-argument constructors [commons-compress]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #708:
URL: https://github.com/apache/commons-compress/pull/708#discussion_r2365548412


##########
src/test/java/org/apache/commons/compress/LegacyConstructorsTest.java:
##########
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress;
+
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField;
+import static org.apache.commons.lang3.reflect.FieldUtils.readField;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.stream.Stream;
+
+import org.apache.commons.compress.archivers.arj.ArjArchiveInputStream;
+import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
+import org.apache.commons.compress.archivers.dump.DumpArchiveInputStream;
+import org.apache.commons.compress.archivers.jar.JarArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+/**
+ * Verifies that deprecated constructors are equivalent to the new builder pattern.
+ */
+@Tag("deprecated")
+@SuppressWarnings("deprecation") // testing deprecated code
+class LegacyConstructorsTest extends AbstractTest {
+
+    @Test
+    void testArjConstructor() throws Exception {
+        try (InputStream inputStream = Files.newInputStream(getPath("bla.arj"));
+                ArjArchiveInputStream archiveInputStream = new ArjArchiveInputStream(inputStream, "US-ASCII")) {
+            // Arj wraps the input stream in a DataInputStream
+            assertEquals(inputStream, getNestedInputStream(getNestedInputStream(archiveInputStream)));
+            assertEquals(US_ASCII, archiveInputStream.getCharset());
+        }
+    }
+
+    static Stream<Arguments> testCpioConstructors() {
+        final InputStream inputStream = mock(InputStream.class);
+        return Stream.of(
+                Arguments.of(new CpioArchiveInputStream(inputStream, 1024), inputStream, "US-ASCII", 1024),
+                Arguments.of(new CpioArchiveInputStream(inputStream, 1024, "UTF-8"), inputStream, "UTF-8", 1024),
+                Arguments.of(new CpioArchiveInputStream(inputStream, "UTF-8"), inputStream, "UTF-8", 512));
+    }
+
+    @ParameterizedTest
+    @MethodSource
+    void testCpioConstructors(
+            CpioArchiveInputStream archiveStream,
+            InputStream expectedInput,
+            String expectedEncoding,
+            int expectedBlockSize)
+            throws Exception {
+        assertEquals(expectedInput, getNestedInputStream(archiveStream));
+        assertEquals(Charset.forName(expectedEncoding), archiveStream.getCharset());
+        assertEquals(expectedBlockSize, readDeclaredField(archiveStream, "blockSize", true));
+    }
+
+    @Test
+    void testDumpConstructor() throws Exception {
+        final String otherEncoding = "UTF-8".equals(Charset.defaultCharset().name()) ? "US-ASCII" : "UTF-8";
+        try (InputStream inputStream = Files.newInputStream(getPath("bla.dump"));
+                DumpArchiveInputStream archiveStream = new DumpArchiveInputStream(inputStream, otherEncoding)) {
+            assertEquals(inputStream, getNestedInputStream(archiveStream));
+            assertEquals(Charset.forName(otherEncoding), archiveStream.getCharset());
+        }
+    }
+
+    @Test
+    void testJarConstructor() throws Exception {
+        final InputStream inputStream = mock(InputStream.class);
+        try (JarArchiveInputStream archiveInputStream = new JarArchiveInputStream(inputStream, "US-ASCII")) {
+            assertEquals(US_ASCII, archiveInputStream.getCharset());
+        }
+    }
+
+    static Stream<Arguments> testTarContructors() {

Review Comment:
   Method name has a typo: 'testTarContructors' should be 'testTarConstructors'.



##########
src/main/java/org/apache/commons/compress/archivers/arj/ArjArchiveInputStream.java:
##########
@@ -138,7 +138,7 @@ private ArjArchiveInputStream(final InputStream inputStream, final Builder build
      * @param inputStream the underlying stream, whose ownership is taken
      * @param charsetName the charset used for file names and comments in the archive. May be {@code null} to use the platform default.
      * @throws ArchiveException if an exception occurs while reading
-     * @deprecated Use {@link #builder()} and {@link Builder}.
+     * @deprecated Since 1.29.0 use {@link #builder()}.

Review Comment:
   Missing comma after version number. Should be 'Since 1.29.0, use {@link #builder()}'.
   ```suggestion
        * @deprecated Since 1.29.0, use {@link #builder()}.
   ```



##########
src/test/java/org/apache/commons/compress/LegacyConstructorsTest.java:
##########
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress;
+
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField;
+import static org.apache.commons.lang3.reflect.FieldUtils.readField;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.stream.Stream;
+
+import org.apache.commons.compress.archivers.arj.ArjArchiveInputStream;
+import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
+import org.apache.commons.compress.archivers.dump.DumpArchiveInputStream;
+import org.apache.commons.compress.archivers.jar.JarArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+/**
+ * Verifies that deprecated constructors are equivalent to the new builder pattern.
+ */
+@Tag("deprecated")
+@SuppressWarnings("deprecation") // testing deprecated code
+class LegacyConstructorsTest extends AbstractTest {
+
+    @Test
+    void testArjConstructor() throws Exception {
+        try (InputStream inputStream = Files.newInputStream(getPath("bla.arj"));
+                ArjArchiveInputStream archiveInputStream = new ArjArchiveInputStream(inputStream, "US-ASCII")) {
+            // Arj wraps the input stream in a DataInputStream
+            assertEquals(inputStream, getNestedInputStream(getNestedInputStream(archiveInputStream)));
+            assertEquals(US_ASCII, archiveInputStream.getCharset());
+        }
+    }
+
+    static Stream<Arguments> testCpioConstructors() {
+        final InputStream inputStream = mock(InputStream.class);
+        return Stream.of(
+                Arguments.of(new CpioArchiveInputStream(inputStream, 1024), inputStream, "US-ASCII", 1024),
+                Arguments.of(new CpioArchiveInputStream(inputStream, 1024, "UTF-8"), inputStream, "UTF-8", 1024),
+                Arguments.of(new CpioArchiveInputStream(inputStream, "UTF-8"), inputStream, "UTF-8", 512));
+    }
+
+    @ParameterizedTest
+    @MethodSource
+    void testCpioConstructors(
+            CpioArchiveInputStream archiveStream,
+            InputStream expectedInput,
+            String expectedEncoding,
+            int expectedBlockSize)
+            throws Exception {
+        assertEquals(expectedInput, getNestedInputStream(archiveStream));
+        assertEquals(Charset.forName(expectedEncoding), archiveStream.getCharset());
+        assertEquals(expectedBlockSize, readDeclaredField(archiveStream, "blockSize", true));
+    }
+
+    @Test
+    void testDumpConstructor() throws Exception {
+        final String otherEncoding = "UTF-8".equals(Charset.defaultCharset().name()) ? "US-ASCII" : "UTF-8";
+        try (InputStream inputStream = Files.newInputStream(getPath("bla.dump"));
+                DumpArchiveInputStream archiveStream = new DumpArchiveInputStream(inputStream, otherEncoding)) {
+            assertEquals(inputStream, getNestedInputStream(archiveStream));
+            assertEquals(Charset.forName(otherEncoding), archiveStream.getCharset());
+        }
+    }
+
+    @Test
+    void testJarConstructor() throws Exception {
+        final InputStream inputStream = mock(InputStream.class);
+        try (JarArchiveInputStream archiveInputStream = new JarArchiveInputStream(inputStream, "US-ASCII")) {
+            assertEquals(US_ASCII, archiveInputStream.getCharset());
+        }
+    }
+
+    static Stream<Arguments> testTarContructors() {
+        final InputStream inputStream = mock(InputStream.class);
+        final String defaultEncoding = Charset.defaultCharset().name();
+        final String otherEncoding = "UTF-8".equals(defaultEncoding) ? "US-ASCII" : "UTF-8";
+        return Stream.of(
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, true), inputStream, 10240, 512, defaultEncoding, true),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480), inputStream, 20480, 512, defaultEncoding, false),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480, 1024),
+                        inputStream,
+                        20480,
+                        1024,
+                        defaultEncoding,
+                        false),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480, 1024, otherEncoding),
+                        inputStream,
+                        20480,
+                        1024,
+                        otherEncoding,
+                        false),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480, 1024, otherEncoding, true),
+                        inputStream,
+                        20480,
+                        1024,
+                        otherEncoding,
+                        true),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480, otherEncoding),
+                        inputStream,
+                        20480,
+                        512,
+                        otherEncoding,
+                        false),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, otherEncoding),
+                        inputStream,
+                        10240,
+                        512,
+                        otherEncoding,
+                        false));
+    }
+
+    @ParameterizedTest
+    @MethodSource
+    void testTarContructors(

Review Comment:
   Method name has a typo: 'testTarContructors' should be 'testTarConstructors'.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] tests: Add coverage for deprecated and single-argument constructors [commons-compress]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #708:
URL: https://github.com/apache/commons-compress/pull/708#discussion_r2365549415


##########
src/test/java/org/apache/commons/compress/LegacyConstructorsTest.java:
##########
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress;
+
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField;
+import static org.apache.commons.lang3.reflect.FieldUtils.readField;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.stream.Stream;
+
+import org.apache.commons.compress.archivers.arj.ArjArchiveInputStream;
+import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
+import org.apache.commons.compress.archivers.dump.DumpArchiveInputStream;
+import org.apache.commons.compress.archivers.jar.JarArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+/**
+ * Verifies that deprecated constructors are equivalent to the new builder pattern.
+ */
+@Tag("deprecated")
+@SuppressWarnings("deprecation") // testing deprecated code
+class LegacyConstructorsTest extends AbstractTest {
+
+    @Test
+    void testArjConstructor() throws Exception {
+        try (InputStream inputStream = Files.newInputStream(getPath("bla.arj"));
+                ArjArchiveInputStream archiveInputStream = new ArjArchiveInputStream(inputStream, "US-ASCII")) {
+            // Arj wraps the input stream in a DataInputStream
+            assertEquals(inputStream, getNestedInputStream(getNestedInputStream(archiveInputStream)));
+            assertEquals(US_ASCII, archiveInputStream.getCharset());
+        }
+    }
+
+    static Stream<Arguments> testCpioConstructors() {
+        final InputStream inputStream = mock(InputStream.class);
+        return Stream.of(
+                Arguments.of(new CpioArchiveInputStream(inputStream, 1024), inputStream, "US-ASCII", 1024),
+                Arguments.of(new CpioArchiveInputStream(inputStream, 1024, "UTF-8"), inputStream, "UTF-8", 1024),
+                Arguments.of(new CpioArchiveInputStream(inputStream, "UTF-8"), inputStream, "UTF-8", 512));
+    }
+
+    @ParameterizedTest
+    @MethodSource
+    void testCpioConstructors(
+            CpioArchiveInputStream archiveStream,
+            InputStream expectedInput,
+            String expectedEncoding,
+            int expectedBlockSize)
+            throws Exception {
+        assertEquals(expectedInput, getNestedInputStream(archiveStream));
+        assertEquals(Charset.forName(expectedEncoding), archiveStream.getCharset());
+        assertEquals(expectedBlockSize, readDeclaredField(archiveStream, "blockSize", true));
+    }
+
+    @Test
+    void testDumpConstructor() throws Exception {
+        final String otherEncoding = "UTF-8".equals(Charset.defaultCharset().name()) ? "US-ASCII" : "UTF-8";
+        try (InputStream inputStream = Files.newInputStream(getPath("bla.dump"));
+                DumpArchiveInputStream archiveStream = new DumpArchiveInputStream(inputStream, otherEncoding)) {
+            assertEquals(inputStream, getNestedInputStream(archiveStream));
+            assertEquals(Charset.forName(otherEncoding), archiveStream.getCharset());
+        }
+    }
+
+    @Test
+    void testJarConstructor() throws Exception {
+        final InputStream inputStream = mock(InputStream.class);
+        try (JarArchiveInputStream archiveInputStream = new JarArchiveInputStream(inputStream, "US-ASCII")) {
+            assertEquals(US_ASCII, archiveInputStream.getCharset());
+        }
+    }
+
+    static Stream<Arguments> testTarContructors() {
+        final InputStream inputStream = mock(InputStream.class);
+        final String defaultEncoding = Charset.defaultCharset().name();
+        final String otherEncoding = "UTF-8".equals(defaultEncoding) ? "US-ASCII" : "UTF-8";
+        return Stream.of(
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, true), inputStream, 10240, 512, defaultEncoding, true),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480), inputStream, 20480, 512, defaultEncoding, false),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480, 1024),
+                        inputStream,
+                        20480,
+                        1024,
+                        defaultEncoding,
+                        false),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480, 1024, otherEncoding),
+                        inputStream,
+                        20480,
+                        1024,
+                        otherEncoding,
+                        false),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480, 1024, otherEncoding, true),
+                        inputStream,
+                        20480,
+                        1024,
+                        otherEncoding,
+                        true),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, 20480, otherEncoding),
+                        inputStream,
+                        20480,
+                        512,
+                        otherEncoding,
+                        false),
+                Arguments.of(
+                        new TarArchiveInputStream(inputStream, otherEncoding),
+                        inputStream,
+                        10240,
+                        512,
+                        otherEncoding,
+                        false));
+    }
+
+    @ParameterizedTest
+    @MethodSource
+    void testTarContructors(

Review Comment:
   Fixed in https://github.com/apache/commons-compress/pull/708/commits/afbfc778e1e03106a87ea03a311a660e56604aca



##########
src/test/java/org/apache/commons/compress/LegacyConstructorsTest.java:
##########
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress;
+
+import static java.nio.charset.StandardCharsets.US_ASCII;
+import static org.apache.commons.lang3.reflect.FieldUtils.readDeclaredField;
+import static org.apache.commons.lang3.reflect.FieldUtils.readField;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.stream.Stream;
+
+import org.apache.commons.compress.archivers.arj.ArjArchiveInputStream;
+import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
+import org.apache.commons.compress.archivers.dump.DumpArchiveInputStream;
+import org.apache.commons.compress.archivers.jar.JarArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+/**
+ * Verifies that deprecated constructors are equivalent to the new builder pattern.
+ */
+@Tag("deprecated")
+@SuppressWarnings("deprecation") // testing deprecated code
+class LegacyConstructorsTest extends AbstractTest {
+
+    @Test
+    void testArjConstructor() throws Exception {
+        try (InputStream inputStream = Files.newInputStream(getPath("bla.arj"));
+                ArjArchiveInputStream archiveInputStream = new ArjArchiveInputStream(inputStream, "US-ASCII")) {
+            // Arj wraps the input stream in a DataInputStream
+            assertEquals(inputStream, getNestedInputStream(getNestedInputStream(archiveInputStream)));
+            assertEquals(US_ASCII, archiveInputStream.getCharset());
+        }
+    }
+
+    static Stream<Arguments> testCpioConstructors() {
+        final InputStream inputStream = mock(InputStream.class);
+        return Stream.of(
+                Arguments.of(new CpioArchiveInputStream(inputStream, 1024), inputStream, "US-ASCII", 1024),
+                Arguments.of(new CpioArchiveInputStream(inputStream, 1024, "UTF-8"), inputStream, "UTF-8", 1024),
+                Arguments.of(new CpioArchiveInputStream(inputStream, "UTF-8"), inputStream, "UTF-8", 512));
+    }
+
+    @ParameterizedTest
+    @MethodSource
+    void testCpioConstructors(
+            CpioArchiveInputStream archiveStream,
+            InputStream expectedInput,
+            String expectedEncoding,
+            int expectedBlockSize)
+            throws Exception {
+        assertEquals(expectedInput, getNestedInputStream(archiveStream));
+        assertEquals(Charset.forName(expectedEncoding), archiveStream.getCharset());
+        assertEquals(expectedBlockSize, readDeclaredField(archiveStream, "blockSize", true));
+    }
+
+    @Test
+    void testDumpConstructor() throws Exception {
+        final String otherEncoding = "UTF-8".equals(Charset.defaultCharset().name()) ? "US-ASCII" : "UTF-8";
+        try (InputStream inputStream = Files.newInputStream(getPath("bla.dump"));
+                DumpArchiveInputStream archiveStream = new DumpArchiveInputStream(inputStream, otherEncoding)) {
+            assertEquals(inputStream, getNestedInputStream(archiveStream));
+            assertEquals(Charset.forName(otherEncoding), archiveStream.getCharset());
+        }
+    }
+
+    @Test
+    void testJarConstructor() throws Exception {
+        final InputStream inputStream = mock(InputStream.class);
+        try (JarArchiveInputStream archiveInputStream = new JarArchiveInputStream(inputStream, "US-ASCII")) {
+            assertEquals(US_ASCII, archiveInputStream.getCharset());
+        }
+    }
+
+    static Stream<Arguments> testTarContructors() {

Review Comment:
   Fixed in https://github.com/apache/commons-compress/pull/708/commits/afbfc778e1e03106a87ea03a311a660e56604aca



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org