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 2022/05/05 18:29:15 UTC

[commons-compress] branch master updated (271f3155 -> 2c022b98)

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 271f3155 Fix broken tests.
     new abf6a755 Fix broken tests.
     new 2c022b98 Fix broken tests.

The 2 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:
 .../compress/archivers/ArchiveStreamFactoryTest.java   | 11 +++++------
 .../apache/commons/compress/archivers/ZipTestCase.java | 18 +++++++++++++-----
 2 files changed, 18 insertions(+), 11 deletions(-)


[commons-compress] 01/02: Fix broken 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 abf6a7551a3b60a280d221ace486df9800b4eaf8
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:16:38 2022 -0400

    Fix broken tests.
---
 .../commons/compress/archivers/ArchiveStreamFactoryTest.java  | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java b/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
index 33deb04d..3ac43f94 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ArchiveStreamFactoryTest.java
@@ -21,6 +21,7 @@ package org.apache.commons.compress.archivers;
 import static org.apache.commons.compress.AbstractTestCase.getFile;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -90,16 +91,14 @@ public class ArchiveStreamFactoryTest {
 
     @Test
     public void cantRead7zFromStream() throws Exception {
-        ArchiveStreamFactory.DEFAULT
-            .createArchiveInputStream(ArchiveStreamFactory.SEVEN_Z,
-                                      new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY));
+        assertThrows(StreamingNotSupportedException.class,
+            () -> ArchiveStreamFactory.DEFAULT.createArchiveInputStream(ArchiveStreamFactory.SEVEN_Z, new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY)));
     }
 
     @Test
     public void cantWrite7zToStream() throws Exception {
-        ArchiveStreamFactory.DEFAULT
-            .createArchiveOutputStream(ArchiveStreamFactory.SEVEN_Z,
-                                       new ByteArrayOutputStream());
+        assertThrows(StreamingNotSupportedException.class,
+            () -> ArchiveStreamFactory.DEFAULT.createArchiveOutputStream(ArchiveStreamFactory.SEVEN_Z, new ByteArrayOutputStream()));
     }
 
     /**


[commons-compress] 02/02: Fix broken 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 2c022b98c62a084e86f1286634c7dd5a28928cd7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:29:10 2022 -0400

    Fix broken tests.
---
 .../apache/commons/compress/archivers/ZipTestCase.java | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
index 2ed7b48a..e4f3ead3 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
@@ -18,12 +18,13 @@
  */
 package org.apache.commons.compress.archivers;
 
-import static java.nio.charset.StandardCharsets.*;
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -690,12 +691,12 @@ public final class ZipTestCase extends AbstractTestCase {
 
     @Test
     public void buildSplitZipWithTooSmallSizeThrowsException() throws IOException {
-        new ZipArchiveOutputStream(File.createTempFile("temp", "zip"), 64 * 1024 - 1);
+        assertThrows(IllegalArgumentException.class, () -> new ZipArchiveOutputStream(File.createTempFile("temp", "zip"), 64 * 1024 - 1));
     }
 
     @Test
     public void buildSplitZipWithTooLargeSizeThrowsException() throws IOException {
-        new ZipArchiveOutputStream(File.createTempFile("temp", "zip"), 4294967295L + 1);
+        assertThrows(IllegalArgumentException.class, () -> new ZipArchiveOutputStream(File.createTempFile("temp", "zip"), 4294967295L + 1));
     }
 
     @Test
@@ -710,7 +711,13 @@ public final class ZipTestCase extends AbstractTestCase {
             final File sameNameFile = new File(dir, "splitZip.z01");
             sameNameFile.createNewFile();
 
-            addFilesToZip(zipArchiveOutputStream, directoryToZip);
+            assertThrows(IOException.class, () -> addFilesToZip(zipArchiveOutputStream, directoryToZip));
+        } catch (Exception e) {
+            // Ignore:
+            // java.io.IOException: This archive contains unclosed entries.
+            //   at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.finish(ZipArchiveOutputStream.java:563)
+            //   at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.close(ZipArchiveOutputStream.java:1119)
+            //   at org.apache.commons.compress.archivers.ZipTestCase.buildSplitZipWithSegmentAlreadyExistThrowsException(ZipTestCase.java:715)
         }
     }
 
@@ -857,8 +864,9 @@ public final class ZipTestCase extends AbstractTestCase {
             zipArchiveOutputStream.putArchiveEntry(zipArchiveEntry);
             try (final InputStream input = Files.newInputStream(fileToAdd.toPath())) {
                 IOUtils.copy(input, zipArchiveOutputStream);
+            } finally {
+                zipArchiveOutputStream.closeArchiveEntry();
             }
-            zipArchiveOutputStream.closeArchiveEntry();
         }
     }