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/04 13:17:33 UTC

(commons-compress) branch master updated (55340a37 -> 9f46121a)

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 55340a37 Let JUnit manage temporary files
     new ea12355d Delete temp file
     new 2250b7e4 Let JUnit manage temporary files
     new 9f46121a Let JUnit manage temporary files

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/tar/TarMemoryFileSystemTest.java         |  3 +++
 .../compress/archivers/zip/ScatterSampleTest.java      |  6 +++---
 .../archivers/zip/ScatterZipOutputStreamTest.java      | 18 ++++--------------
 3 files changed, 10 insertions(+), 17 deletions(-)


(commons-compress) 02/03: Let JUnit manage temporary files

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 2250b7e461c27ef77cc9badd3b5cdafa3a8efc16
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 4 09:15:45 2023 -0400

    Let JUnit manage temporary files
---
 .../apache/commons/compress/archivers/zip/ScatterSampleTest.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ScatterSampleTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ScatterSampleTest.java
index e3b9cda2..2aca014d 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ScatterSampleTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ScatterSampleTest.java
@@ -25,11 +25,12 @@ import java.io.InputStream;
 import java.util.concurrent.ExecutionException;
 import java.util.zip.ZipEntry;
 
+import org.apache.commons.compress.AbstractTempDirTest;
 import org.apache.commons.compress.parallel.InputStreamSupplier;
 import org.apache.commons.compress.utils.IOUtils;
 import org.junit.jupiter.api.Test;
 
-public class ScatterSampleTest {
+public class ScatterSampleTest extends AbstractTempDirTest {
 
     private void checkFile(final File result) throws IOException {
         try (final ZipFile zipFile = new ZipFile(result)) {
@@ -60,8 +61,7 @@ public class ScatterSampleTest {
 
     @Test
     public void testSample() throws Exception {
-        final File result = File.createTempFile("testSample", "fe");
-
+        final File result = createTempFile("testSample", "fe");
         createFile(result);
         checkFile(result);
     }


(commons-compress) 03/03: Let JUnit manage temporary files

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 9f46121a851037f7e36e47dce1d9013bef099fe7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 4 09:17:07 2023 -0400

    Let JUnit manage temporary files
---
 .../archivers/zip/ScatterZipOutputStreamTest.java      | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
index ace594fa..692cf0f1 100644
--- a/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/zip/ScatterZipOutputStreamTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.compress.archivers.zip;
 
-import static org.apache.commons.compress.AbstractTest.forceDelete;
 import static org.apache.commons.compress.archivers.zip.ZipArchiveEntryRequest.createZipArchiveEntryRequest;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -26,21 +25,12 @@ import java.io.File;
 import java.io.InputStream;
 import java.util.zip.ZipEntry;
 
+import org.apache.commons.compress.AbstractTempDirTest;
 import org.apache.commons.compress.parallel.InputStreamSupplier;
 import org.apache.commons.compress.utils.IOUtils;
-import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 
-public class ScatterZipOutputStreamTest {
-
-    private File scatterFile;
-    private File target;
-
-    @AfterEach
-    public void cleanup() {
-        forceDelete(scatterFile);
-        forceDelete(target);
-    }
+public class ScatterZipOutputStreamTest extends AbstractTempDirTest {
 
     private InputStreamSupplier createPayloadSupplier(final ByteArrayInputStream payload) {
         return () -> payload;
@@ -48,7 +38,8 @@ public class ScatterZipOutputStreamTest {
 
     @Test
     public void testPutArchiveEntry() throws Exception {
-        scatterFile = File.createTempFile("scattertest", ".notzip");
+        final File scatterFile = createTempFile("scattertest", ".notzip");
+        final File target = createTempFile("scattertest", ".zip");
         final byte[] B_PAYLOAD = "RBBBBBBS".getBytes();
         final byte[] A_PAYLOAD = "XAAY".getBytes();
         try (ScatterZipOutputStream scatterZipOutputStream = ScatterZipOutputStream.fileBased(scatterFile)) {
@@ -63,7 +54,6 @@ public class ScatterZipOutputStreamTest {
             final ByteArrayInputStream payload1 = new ByteArrayInputStream(A_PAYLOAD);
             scatterZipOutputStream.addArchiveEntry(createZipArchiveEntryRequest(zae, createPayloadSupplier(payload1)));
 
-            target = File.createTempFile("scattertest", ".zip");
             try (ZipArchiveOutputStream outputStream = new ZipArchiveOutputStream(target)) {
                 scatterZipOutputStream.writeTo(outputStream);
             }


(commons-compress) 01/03: Delete temp file

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 ea12355d1b7db74e1d06ffa5b86e9acecb16eeeb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Nov 4 09:15:08 2023 -0400

    Delete temp file
---
 .../apache/commons/compress/archivers/tar/TarMemoryFileSystemTest.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarMemoryFileSystemTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarMemoryFileSystemTest.java
index 5bace5ee..4afe2ceb 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarMemoryFileSystemTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarMemoryFileSystemTest.java
@@ -31,6 +31,7 @@ import java.nio.file.Path;
 import java.nio.file.attribute.GroupPrincipal;
 import java.nio.file.attribute.UserPrincipal;
 
+import org.apache.commons.compress.AbstractTest;
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.ArchiveException;
 import org.apache.commons.compress.archivers.ArchiveOutputStream;
@@ -56,6 +57,8 @@ public class TarMemoryFileSystemTest {
                 Files.copy(p, tarOut);
                 tarOut.closeArchiveEntry();
                 assertEquals(f.length(), tarOut.getBytesWritten());
+            } finally {
+                AbstractTest.forceDelete(f);
             }
         }
     }