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 2023/11/28 13:00:24 UTC

(commons-compress) branch master updated (2fba0703d -> f95733778)

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 2fba0703d Address compiler warnings in ArjArchiveInputStreamTest
     new 2d9979614 Address compiler warnings in ArArchiveInputStreamTest
     new d526709cb Use try-with-resources
     new f95733778 Address compiler warnings in ArArchiveInputStreamTest

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:
 .../archivers/ar/ArArchiveInputStreamTest.java     | 53 +++++++++++++++++-----
 1 file changed, 42 insertions(+), 11 deletions(-)


(commons-compress) 01/03: Address compiler warnings in ArArchiveInputStreamTest

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 2d99796141a652155c526e77663c21f152ee3dcc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Nov 28 07:58:19 2023 -0500

    Address compiler warnings in ArArchiveInputStreamTest
---
 .../commons/compress/archivers/ar/ArArchiveInputStreamTest.java      | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
index ff876d570..b073388b0 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
@@ -22,6 +22,7 @@ import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
@@ -107,7 +108,7 @@ public class ArArchiveInputStreamTest extends AbstractTest {
         final byte[] buf = new byte[2];
         try (InputStream in = newInputStream("bla.ar");
                 ArArchiveInputStream archive = new ArArchiveInputStream(in)) {
-            final ArchiveEntry e = archive.getNextEntry();
+            assertNotNull(archive.getNextEntry());
             IOUtils.toByteArray(archive);
             assertEquals(-1, archive.read(buf));
             assertEquals(-1, archive.read(buf));
@@ -157,7 +158,7 @@ public class ArArchiveInputStreamTest extends AbstractTest {
     public void testSingleByteReadConsistentlyReturnsMinusOneAtEof() throws Exception {
         try (InputStream in = newInputStream("bla.ar");
                 ArArchiveInputStream archive = new ArArchiveInputStream(in)) {
-            final ArchiveEntry e = archive.getNextEntry();
+            assertNotNull(archive.getNextEntry());
             IOUtils.toByteArray(archive);
             assertEquals(-1, archive.read());
             assertEquals(-1, archive.read());


(commons-compress) 02/03: 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 d526709cbbb6e7f619078a2566a228c103ce2306
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Nov 28 07:59:12 2023 -0500

    Use try-with-resources
---
 .../archivers/ar/ArArchiveInputStreamTest.java         | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
index b073388b0..bd7638c83 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
@@ -127,17 +127,17 @@ public class ArArchiveInputStreamTest extends AbstractTest {
 
     @Test
     public void testSimpleInputStream() throws IOException {
-        try (InputStream fileInputStream = newInputStream("bla.ar")) {
+        try (InputStream fileInputStream = newInputStream("bla.ar");
 
-            // This default implementation of InputStream.available() always returns zero,
-            // and there are many streams in practice where the total length of the stream is not known.
+                // This default implementation of InputStream.available() always returns zero,
+                // and there are many streams in practice where the total length of the stream is not known.
 
-            final InputStream simpleInputStream = new InputStream() {
-                @Override
-                public int read() throws IOException {
-                    return fileInputStream.read();
-                }
-            };
+                InputStream simpleInputStream = new InputStream() {
+                    @Override
+                    public int read() throws IOException {
+                        return fileInputStream.read();
+                    }
+                }) {
 
             try (ArArchiveInputStream archiveInputStream = new ArArchiveInputStream(simpleInputStream)) {
                 final ArArchiveEntry entry1 = archiveInputStream.getNextArEntry();


(commons-compress) 03/03: Address compiler warnings in ArArchiveInputStreamTest

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 f95733778128985ce66dd5f76d848c4f06230425
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Nov 28 08:00:19 2023 -0500

    Address compiler warnings in ArArchiveInputStreamTest
    
    Add test
---
 .../archivers/ar/ArArchiveInputStreamTest.java     | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
index bd7638c83..cd81f44df 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStreamTest.java
@@ -127,6 +127,36 @@ public class ArArchiveInputStreamTest extends AbstractTest {
 
     @Test
     public void testSimpleInputStream() throws IOException {
+        try (InputStream fileInputStream = newInputStream("bla.ar");
+
+                // This default implementation of InputStream.available() always returns zero,
+                // and there are many streams in practice where the total length of the stream is not known.
+
+                InputStream simpleInputStream = new InputStream() {
+                    @Override
+                    public int read() throws IOException {
+                        return fileInputStream.read();
+                    }
+                }) {
+
+            try (ArArchiveInputStream archiveInputStream = new ArArchiveInputStream(simpleInputStream)) {
+                final ArArchiveEntry entry1 = archiveInputStream.getNextEntry();
+                assertThat(entry1, not(nullValue()));
+                assertThat(entry1.getName(), equalTo("test1.xml"));
+                assertThat(entry1.getLength(), equalTo(610L));
+
+                final ArArchiveEntry entry2 = archiveInputStream.getNextEntry();
+                assertThat(entry2.getName(), equalTo("test2.xml"));
+                assertThat(entry2.getLength(), equalTo(82L));
+
+                assertThat(archiveInputStream.getNextEntry(), nullValue());
+            }
+        }
+    }
+
+    @SuppressWarnings("deprecation")
+    @Test
+    public void testSimpleInputStreamDeprecated() throws IOException {
         try (InputStream fileInputStream = newInputStream("bla.ar");
 
                 // This default implementation of InputStream.available() always returns zero,