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
The following commit(s) were added to refs/heads/master by this push: new 04c27a3b1 [COMPRESS-666] Refactor test 04c27a3b1 is described below commit 04c27a3b108f7e777c7013c1528775066508433e Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Fri Mar 1 14:42:36 2024 -0500 [COMPRESS-666] Refactor test --- .../commons/compress/compressors/GZipTest.java | 34 +++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/apache/commons/compress/compressors/GZipTest.java b/src/test/java/org/apache/commons/compress/compressors/GZipTest.java index 66fa47115..a6f3cf89f 100644 --- a/src/test/java/org/apache/commons/compress/compressors/GZipTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/GZipTest.java @@ -52,24 +52,21 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream; import org.apache.commons.compress.compressors.gzip.GzipParameters; import org.apache.commons.io.IOUtils; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; public final class GZipTest extends AbstractTest { - /** - * Tests https://issues.apache.org/jira/browse/COMPRESS-666 - */ - @ParameterizedTest - @ValueSource(ints = { 1, 2, 4, 8, 16, 32, 64, 128 }) - public void testCompress666(final int factor) throws ExecutionException, InterruptedException { + private void testCompress666(final int factor, final boolean bufferInputStream) throws ExecutionException, InterruptedException { final ExecutorService executorService = Executors.newFixedThreadPool(10); try { final List<Future<?>> tasks = IntStream.range(0, 200).mapToObj(index -> executorService.submit(() -> { TarArchiveEntry tarEntry = null; try (InputStream inputStream = getClass().getResourceAsStream("/COMPRESS-666/compress-666.tar.gz"); - TarArchiveInputStream tarInputStream = new TarArchiveInputStream(new BufferedInputStream(new GZIPInputStream(inputStream)), + TarArchiveInputStream tarInputStream = new TarArchiveInputStream( + bufferInputStream ? new BufferedInputStream(new GZIPInputStream(inputStream)) : new GZIPInputStream(inputStream), TarConstants.DEFAULT_RCDSIZE * factor, TarConstants.DEFAULT_RCDSIZE)) { while ((tarEntry = tarInputStream.getNextEntry()) != null) { assertNotNull(tarEntry); @@ -97,6 +94,29 @@ public final class GZipTest extends AbstractTest { } } + /** + * Tests https://issues.apache.org/jira/browse/COMPRESS-666 + * + * A factor of 20 is the default. + */ + @ParameterizedTest + @ValueSource(ints = { 1, 2, 4, 8, 16, 20, 32, 64, 128 }) + public void testCompress666Buffered(final int factor) throws ExecutionException, InterruptedException { + testCompress666(factor, true); + } + + /** + * Tests https://issues.apache.org/jira/browse/COMPRESS-666 + * + * A factor of 20 is the default. + */ + @Disabled + @ParameterizedTest + @ValueSource(ints = { 1, 2, 4, 8, 16, 20, 32, 64, 128 }) + public void testCompress666Unbuffered(final int factor) throws ExecutionException, InterruptedException { + testCompress666(factor, false); + } + @Test public void testConcatenatedStreamsReadFirstOnly() throws Exception { final File input = getFile("multiple.gz");