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 2024/05/17 18:32:41 UTC
(commons-compress) branch master updated (52ba5cfd7 -> 5602d0d84)
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 52ba5cfd7 Use try-with-resources
new 1c314a2d1 Add @SuppressWarnings
new 13b6fbacd Use try-with-resources
new b41a81845 Use try-with-resources
new fc506b78c Use try-with-resources
new 2f5419b9f Remove unused exceptions in method signatures
new 5602d0d84 Fix test
The 6 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:
.../archivers/tar/TarArchiveInputStreamTest.java | 5 ++--
.../compress/archivers/zip/ZipIoUtilTest.java | 8 ++++--
.../commons/compress/compressors/GZipTest.java | 7 ++---
.../compressors/z/ZCompressorInputStreamTest.java | 7 +++--
.../compress/harmony/unpack200/SegmentTest.java | 32 ++++++++++------------
5 files changed, 31 insertions(+), 28 deletions(-)
(commons-compress) 02/06: Use try-with-resources
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 13b6fbacda935c8aae98ad9cef98fe9d7a1feda4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 17 14:00:44 2024 -0400
Use try-with-resources
Internal refactoring
---
.../commons/compress/archivers/tar/TarArchiveInputStreamTest.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
index 50b02c1fd..8ad695beb 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
@@ -151,8 +151,8 @@ public class TarArchiveInputStreamTest extends AbstractTest {
// tar these dirs
final String fileName = "/" + dirDirectory + "/" + subDir;
final File tarF = new File(rootPath + "/tar" + i + ".tar");
- try (OutputStream dest = Files.newOutputStream(tarF.toPath())) {
- final TarArchiveOutputStream out = new TarArchiveOutputStream(new BufferedOutputStream(dest));
+ try (OutputStream dest = Files.newOutputStream(tarF.toPath());
+ TarArchiveOutputStream out = new TarArchiveOutputStream(new BufferedOutputStream(dest))) {
out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
out.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
(commons-compress) 03/06: Use try-with-resources
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 b41a81845f3fd6603f7a58f94bb3d31274182541
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 17 14:03:22 2024 -0400
Use try-with-resources
---
.../compress/harmony/unpack200/SegmentTest.java | 32 ++++++++++------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/harmony/unpack200/SegmentTest.java b/src/test/java/org/apache/commons/compress/harmony/unpack200/SegmentTest.java
index f4ba3d671..0a838c93b 100644
--- a/src/test/java/org/apache/commons/compress/harmony/unpack200/SegmentTest.java
+++ b/src/test/java/org/apache/commons/compress/harmony/unpack200/SegmentTest.java
@@ -54,23 +54,21 @@ public class SegmentTest extends AbstractTempDirTest {
final JarEntry entry = jarFile.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
assertNotNull(entry);
final InputStream ours = jarFile.getInputStream(entry);
-
- final JarFile jarFile2 = new JarFile(new File(Segment.class.getResource("/pack200/hw.jar").toURI()));
- final JarEntry entry2 = jarFile2.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
- assertNotNull(entry2);
-
- final InputStream expected = jarFile2.getInputStream(entry2);
-
- try (BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
- BufferedReader reader2 = new BufferedReader(new InputStreamReader(expected))) {
- String line1 = reader1.readLine();
- String line2 = reader2.readLine();
- int i = 1;
- while (line1 != null || line2 != null) {
- assertEquals(line2, line1, "Unpacked class files differ ar line " + i);
- line1 = reader1.readLine();
- line2 = reader2.readLine();
- i++;
+ try (JarFile jarFile2 = new JarFile(new File(Segment.class.getResource("/pack200/hw.jar").toURI()))) {
+ final JarEntry entry2 = jarFile2.getJarEntry("org/apache/harmony/archive/tests/internal/pack200/HelloWorld.class");
+ assertNotNull(entry2);
+ final InputStream expected = jarFile2.getInputStream(entry2);
+ try (BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
+ BufferedReader reader2 = new BufferedReader(new InputStreamReader(expected))) {
+ String line1 = reader1.readLine();
+ String line2 = reader2.readLine();
+ int i = 1;
+ while (line1 != null || line2 != null) {
+ assertEquals(line2, line1, "Unpacked class files differ ar line " + i);
+ line1 = reader1.readLine();
+ line2 = reader2.readLine();
+ i++;
+ }
}
}
}
(commons-compress) 04/06: Use try-with-resources
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 fc506b78cf21e507c1b8c103cb638a74aa1f62ba
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 17 14:04:18 2024 -0400
Use try-with-resources
---
.../commons/compress/compressors/z/ZCompressorInputStreamTest.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
index 1790d00ab..991a9a725 100644
--- a/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/z/ZCompressorInputStreamTest.java
@@ -43,9 +43,10 @@ import org.junit.jupiter.api.Test;
public class ZCompressorInputStreamTest {
@Test
- public void testFailsToCreateZCompressorInputStreamAndThrowsIOException() {
- final SequenceInputStream sequenceInputStream = new SequenceInputStream(Collections.emptyEnumeration());
- assertThrows(IOException.class, () -> new ZCompressorInputStream(sequenceInputStream));
+ public void testFailsToCreateZCompressorInputStreamAndThrowsIOException() throws IOException {
+ try (SequenceInputStream sequenceInputStream = new SequenceInputStream(Collections.emptyEnumeration())) {
+ assertThrows(IOException.class, () -> new ZCompressorInputStream(sequenceInputStream));
+ }
}
@Test
(commons-compress) 05/06: Remove unused exceptions in method signatures
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 2f5419b9f5b3f53ab9b3a30c7c89cfc7487c32ac
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 17 14:06:05 2024 -0400
Remove unused exceptions in method signatures
---
.../java/org/apache/commons/compress/compressors/GZipTest.java | 7 +++----
1 file changed, 3 insertions(+), 4 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 65649ab45..075298aa5 100644
--- a/src/test/java/org/apache/commons/compress/compressors/GZipTest.java
+++ b/src/test/java/org/apache/commons/compress/compressors/GZipTest.java
@@ -35,7 +35,6 @@ import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -58,7 +57,7 @@ import org.junit.jupiter.params.provider.ValueSource;
public final class GZipTest extends AbstractTest {
- private void testCompress666(final int factor, final boolean bufferInputStream, final String localPath) throws ExecutionException, InterruptedException {
+ private void testCompress666(final int factor, final boolean bufferInputStream, final String localPath) {
final ExecutorService executorService = Executors.newFixedThreadPool(10);
try {
final List<Future<?>> tasks = IntStream.range(0, 200).mapToObj(index -> executorService.submit(() -> {
@@ -100,7 +99,7 @@ public final class GZipTest extends AbstractTest {
*/
@ParameterizedTest
@ValueSource(ints = { 1, 2, 4, 8, 16, 20, 32, 64, 128 })
- public void testCompress666Buffered(final int factor) throws ExecutionException, InterruptedException {
+ public void testCompress666Buffered(final int factor) {
testCompress666(factor, true, "/COMPRESS-666/compress-666.tar.gz");
}
@@ -111,7 +110,7 @@ public final class GZipTest extends AbstractTest {
*/
@ParameterizedTest
@ValueSource(ints = { 1, 2, 4, 8, 16, 20, 32, 64, 128 })
- public void testCompress666Unbuffered(final int factor) throws ExecutionException, InterruptedException {
+ public void testCompress666Unbuffered(final int factor) {
testCompress666(factor, false, "/COMPRESS-666/compress-666.tar.gz");
}
(commons-compress) 06/06: Fix test
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 5602d0d84b2a2e5840a69854bcec0bbb2794f766
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 17 14:32:36 2024 -0400
Fix test
---
.../org/apache/commons/compress/archivers/zip/ZipIoUtilTest.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipIoUtilTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipIoUtilTest.java
index a963b5bf8..6c4c4f2ea 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipIoUtilTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipIoUtilTest.java
@@ -19,7 +19,9 @@ package org.apache.commons.compress.archivers.zip;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -38,8 +40,10 @@ import org.junit.jupiter.api.Test;
*/
public class ZipIoUtilTest extends AbstractTempDirTest {
- private FileChannel mockFileChannel() {
- return mock(FileChannel.class);
+ private FileChannel mockFileChannel() throws IOException {
+ final FileChannel spy = spy(FileChannel.class);
+ doNothing().when(spy).close();
+ return spy;
}
private SeekableByteChannel mockSeekableByteChannel() {
(commons-compress) 01/06: Add @SuppressWarnings
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 1c314a2d18c7630011f01e27e681c774100aba4f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 17 13:59:45 2024 -0400
Add @SuppressWarnings
---
.../apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
index 2ee14f95e..50b02c1fd 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java
@@ -72,6 +72,7 @@ public class TarArchiveInputStreamTest extends AbstractTest {
});
}
+ @SuppressWarnings("resource") // Caller closes
private TarArchiveInputStream getTestStream(final String name) {
return new TarArchiveInputStream(TarArchiveInputStreamTest.class.getResourceAsStream(name));
}