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 5c56df2c Start using JUnit to manage temporary directories for tests
     new a11fa2e3 Merge branch 'master' of 
https://gitbox.apache.org/repos/asf/commons-compress.git
5c56df2c is described below

commit 5c56df2cad1096e4531e18e60450047d1ff44414
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Nov 3 08:04:34 2023 -0400

    Start using JUnit to manage temporary directories for tests
    
    Better test method names
---
 .../apache/commons/compress/AbstractTestCase.java  | 69 ++++++++++------------
 .../commons/compress/archivers/ArTestCase.java     | 30 +++++-----
 .../commons/compress/archivers/CpioTestCase.java   | 24 ++++----
 .../commons/compress/archivers/TarTestCase.java    | 48 +++++++--------
 .../commons/compress/archivers/ZipTestCase.java    | 30 +++++-----
 .../archivers/ar/ArArchiveOutputStreamTest.java    |  2 +-
 .../compress/archivers/examples/ExpanderTest.java  |  2 +-
 .../archivers/jar/JarArchiveOutputStreamTest.java  |  2 +-
 .../archivers/tar/TarArchiveEntryTest.java         |  2 +-
 .../archivers/tar/TarArchiveInputStreamTest.java   |  2 +-
 .../compress/archivers/tar/TarFileTest.java        |  2 +-
 .../compress/archivers/zip/DataDescriptorTest.java | 50 ++++++----------
 .../zip/ParallelScatterZipCreatorTest.java         |  6 +-
 .../archivers/zip/ScatterZipOutputStreamTest.java  |  6 +-
 .../compress/archivers/zip/UTF8ZipFilesTest.java   |  6 +-
 .../archivers/zip/X5455_ExtendedTimestampTest.java | 12 ++--
 .../compress/archivers/zip/Zip64SupportIT.java     |  7 ++-
 .../zip/ZipFileIgnoringLocalFileHeaderTest.java    | 34 ++++-------
 .../compress/changes/ChangeSetRawTypesTest.java    | 40 ++++++-------
 .../compress/changes/ChangeSetSafeTypesTest.java   |  2 +-
 .../lz4/CompressionDegradationTest.java            | 34 +++++------
 21 files changed, 190 insertions(+), 220 deletions(-)

diff --git a/src/test/java/org/apache/commons/compress/AbstractTestCase.java 
b/src/test/java/org/apache/commons/compress/AbstractTestCase.java
index e481a0b6..72ce37f1 100644
--- a/src/test/java/org/apache/commons/compress/AbstractTestCase.java
+++ b/src/test/java/org/apache/commons/compress/AbstractTestCase.java
@@ -45,6 +45,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.io.TempDir;
 
 public abstract class AbstractTestCase {
 
@@ -52,41 +53,13 @@ public abstract class AbstractTestCase {
         I wrap(InputStream inputStream) throws Exception;
     }
 
-    public static File getFile(final String path) throws IOException {
-        final URL url = 
AbstractTestCase.class.getClassLoader().getResource(path);
-        if (url == null) {
-            throw new FileNotFoundException("couldn't find " + path);
-        }
-        try {
-            return new File(url.toURI());
-        } catch (final URISyntaxException ex) {
-            throw new IOException(ex);
-        }
-    }
-
-    public static Path getPath(final String path) throws IOException {
-        return getFile(path).toPath();
-    }
-
-    public static File mkdir(final String prefix) throws IOException {
-        return Files.createTempDirectory(prefix).toFile();
-    }
-
-    public static InputStream newInputStream(final String path) throws 
IOException {
-        return Files.newInputStream(getPath(path));
-    }
-
-    public static void rmdir(final File directory) {
-        tryHardToDelete(directory);
-    }
-
     /**
      * Deletes a file or directory. For a directory, delete it and all 
subdirectories.
      *
      * @param file a file or directory.
      * @return whether deletion was successful
      */
-    public static boolean tryHardToDelete(final File file) {
+    public static boolean forceDelete(final File file) {
         try {
             if (file != null && file.exists()) {
                 FileUtils.forceDelete(file);
@@ -105,12 +78,38 @@ public abstract class AbstractTestCase {
      * @param path a file or directory
      * @return whether deletion was successful
      */
-    public static boolean tryHardToDelete(final Path path) {
-        return tryHardToDelete(path != null ? path.toFile() : null);
+    public static boolean forceDelete(final Path path) {
+        return forceDelete(path != null ? path.toFile() : null);
+    }
+
+    public static File getFile(final String path) throws IOException {
+        final URL url = 
AbstractTestCase.class.getClassLoader().getResource(path);
+        if (url == null) {
+            throw new FileNotFoundException("couldn't find " + path);
+        }
+        try {
+            return new File(url.toURI());
+        } catch (final URISyntaxException ex) {
+            throw new IOException(ex);
+        }
+    }
+
+    public static Path getPath(final String path) throws IOException {
+        return getFile(path).toPath();
+    }
+
+    public static File mkdir(final String prefix) throws IOException {
+        return Files.createTempDirectory(prefix).toFile();
+    }
+
+    public static InputStream newInputStream(final String path) throws 
IOException {
+        return Files.newInputStream(getPath(path));
     }
 
+    @TempDir
     protected File dir;
 
+    @TempDir
     protected File resultDir;
 
     /** Used to delete the archive in {@link #tearDown()}. */
@@ -197,7 +196,7 @@ public abstract class AbstractTestCase {
             }
         } finally {
             if (cleanUp) {
-                rmdir(result);
+                forceDelete(result);
             }
         }
         return result;
@@ -365,17 +364,13 @@ public abstract class AbstractTestCase {
 
     @BeforeEach
     public void setUp() throws Exception {
-        dir = mkdir("dir");
-        resultDir = mkdir("dir-result");
         archivePath = null;
     }
 
     @AfterEach
     public void tearDown() throws Exception {
-        rmdir(dir);
-        rmdir(resultDir);
         dir = resultDir = null;
-        if (!tryHardToDelete(archivePath)) {
+        if (!forceDelete(archivePath)) {
             // Note: this exception won't be shown if the test has already 
failed
             throw new Exception("Could not delete " + archivePath);
         }
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java 
b/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
index d5cceb18..613de5f3 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ArTestCase.java
@@ -196,9 +196,9 @@ public final class ArTestCase extends AbstractTestCase {
             assertEquals(tmp[1].lastModified() / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertFalse(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -233,9 +233,9 @@ public final class ArTestCase extends AbstractTestCase {
             assertEquals(file.lastModified() / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertFalse(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(file);
-            rmdir(directory);
+            forceDelete(archive);
+            forceDelete(file);
+            forceDelete(directory);
         }
     }
 
@@ -270,9 +270,9 @@ public final class ArTestCase extends AbstractTestCase {
             assertEquals(file.lastModified() / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertFalse(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(file);
-            rmdir(directory);
+            forceDelete(archive);
+            forceDelete(file);
+            forceDelete(directory);
         }
     }
 
@@ -303,9 +303,9 @@ public final class ArTestCase extends AbstractTestCase {
             assertEquals(beforeArchiveWrite / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertTrue(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -335,9 +335,9 @@ public final class ArTestCase extends AbstractTestCase {
             assertEquals(beforeArchiveWrite / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertTrue(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 }
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java 
b/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java
index 6b73158d..e582cc8b 100644
--- a/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/CpioTestCase.java
@@ -130,9 +130,9 @@ public final class CpioTestCase extends AbstractTestCase {
             assertEquals(beforeArchiveWrite / 1000, 
entryOut.getLastModifiedDate().getTime() / 1000);
             assertTrue(entryOut.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -162,9 +162,9 @@ public final class CpioTestCase extends AbstractTestCase {
             assertEquals(beforeArchiveWrite / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertTrue(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -199,9 +199,9 @@ public final class CpioTestCase extends AbstractTestCase {
             assertEquals(tmp[1].lastModified() / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertFalse(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -233,9 +233,9 @@ public final class CpioTestCase extends AbstractTestCase {
             assertEquals(tmp[1].lastModified() / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertFalse(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 }
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java 
b/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
index eb5eef50..e241dd9e 100644
--- a/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/TarTestCase.java
@@ -138,9 +138,9 @@ public final class TarTestCase extends AbstractTestCase {
             if (tos != null) {
                 tos.close();
             }
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -193,9 +193,9 @@ public final class TarTestCase extends AbstractTestCase {
             if (tos != null) {
                 tos.close();
             }
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -239,9 +239,9 @@ public final class TarTestCase extends AbstractTestCase {
             if (tos != null) {
                 tos.close();
             }
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -274,9 +274,9 @@ public final class TarTestCase extends AbstractTestCase {
             assertEquals(tmp[1].lastModified() / 1000, 
out.getLastModifiedDate().getTime() / 1000);
             assertFalse(out.isDirectory());
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -414,9 +414,9 @@ public final class TarTestCase extends AbstractTestCase {
                 assertEquals(beforeArchiveWrite / 1000, 
entry.getLastModifiedDate().getTime() / 1000);
                 assertTrue(entry.isDirectory());
             } finally {
-                tryHardToDelete(archive);
-                tryHardToDelete(tmp[1]);
-                rmdir(tmp[0]);
+                forceDelete(archive);
+                forceDelete(tmp[1]);
+                forceDelete(tmp[0]);
             }
         }
     }
@@ -462,9 +462,9 @@ public final class TarTestCase extends AbstractTestCase {
                 assertFalse(entry.isDirectory());
             }
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -490,9 +490,9 @@ public final class TarTestCase extends AbstractTestCase {
                 assertTrue(entry.isDirectory());
             }
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -524,9 +524,9 @@ public final class TarTestCase extends AbstractTestCase {
                 assertFalse(entry.isDirectory());
             }
         } finally {
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
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 8aae84b9..a9e4f3d0 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
@@ -428,9 +428,9 @@ public final class ZipTestCase extends AbstractTestCase {
             if (zos != null) {
                 zos.close();
             }
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -464,9 +464,9 @@ public final class ZipTestCase extends AbstractTestCase {
             if (zos != null) {
                 zos.close();
             }
-            tryHardToDelete(archive);
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(archive);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -508,12 +508,12 @@ public final class ZipTestCase extends AbstractTestCase {
             if (zos != null) {
                 zos.close();
             }
-            tryHardToDelete(archive);
+            forceDelete(archive);
             if (fis != null) {
                 fis.close();
             }
-            tryHardToDelete(tmp[1]);
-            rmdir(tmp[0]);
+            forceDelete(tmp[1]);
+            forceDelete(tmp[0]);
         }
     }
 
@@ -555,12 +555,12 @@ public final class ZipTestCase extends AbstractTestCase {
             if (zos != null) {
                 zos.close();
             }
-            tryHardToDelete(archive);
+            forceDelete(archive);
             if (fis != null) {
                 fis.close();
             }
-            tryHardToDelete(tmpFile);
-            rmdir(tmpDir);
+            forceDelete(tmpFile);
+            forceDelete(tmpDir);
         }
     }
 
@@ -848,12 +848,12 @@ public final class ZipTestCase extends AbstractTestCase {
             if (zos != null) {
                 zos.close();
             }
-            tryHardToDelete(archiveFile);
+            forceDelete(archiveFile);
             if (fis != null) {
                 fis.close();
             }
-            tryHardToDelete(tmpFile);
-            rmdir(tmpDir);
+            forceDelete(tmpFile);
+            forceDelete(tmpDir);
         }
     }
 
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java
index 81d8e25e..acef80ed 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/ar/ArArchiveOutputStreamTest.java
@@ -58,7 +58,7 @@ public class ArArchiveOutputStreamTest extends 
AbstractTestCase {
             expected.add("this_is_a_long_name.txt");
             checkArchiveContent(df[1], expected);
         } finally {
-            rmdir(df[0]);
+            forceDelete(df[0]);
         }
     }
 }
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java
index 4d1a4603..4d73ade2 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java
@@ -84,7 +84,7 @@ public class ExpanderTest extends AbstractTestCase {
                 assertThrows(IOException.class, () -> new Expander().expand(f, 
resultDir));
             }
         } finally {
-            tryHardToDelete(s);
+            forceDelete(s);
         }
     }
 
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
index 433f3371..5168b1b8 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/jar/JarArchiveOutputStreamTest.java
@@ -65,7 +65,7 @@ public class JarArchiveOutputStreamTest {
             fes = ze.getExtraFields();
             assertEquals(0, fes.length);
         } finally {
-            AbstractTestCase.tryHardToDelete(testArchive);
+            AbstractTestCase.forceDelete(testArchive);
         }
     }
 
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
index d12c3bae..6ba2c686 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveEntryTest.java
@@ -490,7 +490,7 @@ public class TarArchiveEntryTest implements TarConstants {
             if (tout != null) {
                 tout.close();
             }
-            AbstractTestCase.tryHardToDelete(f);
+            AbstractTestCase.forceDelete(f);
         }
     }
 
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 b969d85f..5af4f26e 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
@@ -189,7 +189,7 @@ public class TarArchiveInputStreamTest extends 
AbstractTestCase {
                 }
             });
         } finally {
-            rmdir(dir);
+            forceDelete(dir);
         }
     }
 
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java 
b/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java
index d777ae7a..b6ca2e75 100644
--- a/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java
@@ -151,7 +151,7 @@ public class TarFileTest extends AbstractTestCase {
     public void shouldThrowAnExceptionOnTruncatedEntries() throws Exception {
         final File dir = mkdir("COMPRESS-279");
         assertThrows(IOException.class, () -> new 
TarFile(getPath("COMPRESS-279.tar")));
-        rmdir(dir);
+        forceDelete(dir);
     }
 
     @Test
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java
index ce640359..ce143409 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/DataDescriptorTest.java
@@ -17,8 +17,6 @@
 package org.apache.commons.compress.archivers.zip;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.apache.commons.compress.AbstractTestCase.mkdir;
-import static org.apache.commons.compress.AbstractTestCase.rmdir;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -30,24 +28,29 @@ import java.io.OutputStream;
 import java.nio.file.Files;
 import java.util.Arrays;
 
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class DataDescriptorTest {
 
+    @TempDir
     private File dir;
 
+    private int findCentralDirectory(final byte[] data) {
+        // not a ZIP64 archive, no comment, "End of central directory record" 
at the end
+        return (int) ZipLong.getValue(data, data.length - 22 + 16);
+    }
+
     @Test
-    public void doesntWriteDataDescriptorForDeflatedEntryOnSeekableOutput() 
throws IOException {
-        final File f = new File(dir, "test.zip");
-        try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(f)) {
+    public void 
testDoesntWriteDataDescriptorForDeflatedEntryOnSeekableOutput() throws 
IOException {
+        final File file = new File(dir, "test.zip");
+        try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(file)) {
             zos.putArchiveEntry(new ZipArchiveEntry("test1.txt"));
             zos.write("foo".getBytes(UTF_8));
             zos.closeArchiveEntry();
         }
 
-        final byte[] data = Files.readAllBytes(f.toPath());
+        final byte[] data = Files.readAllBytes(file.toPath());
 
         final byte[] versionInLFH = Arrays.copyOfRange(data, 4, 6);
         // still 2.0 because of Deflate
@@ -78,7 +81,7 @@ public class DataDescriptorTest {
     }
 
     @Test
-    public void doesntWriteDataDescriptorWhenAddingRawEntries() throws 
IOException {
+    public void testDoesntWriteDataDescriptorWhenAddingRawEntries() throws 
IOException {
         final ByteArrayOutputStream init = new ByteArrayOutputStream();
         try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(init)) {
             zos.putArchiveEntry(new ZipArchiveEntry("test1.txt"));
@@ -91,15 +94,15 @@ public class DataDescriptorTest {
             fos.write(init.toByteArray());
         }
 
-        final ByteArrayOutputStream o = new ByteArrayOutputStream();
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         final ZipArchiveEntry zae;
         try (ZipFile zf = new ZipFile(f);
-             ZipArchiveOutputStream zos = new ZipArchiveOutputStream(o)) {
+             ZipArchiveOutputStream zos = new ZipArchiveOutputStream(baos)) {
             zae = zf.getEntry("test1.txt");
             zos.addRawArchiveEntry(zae, zf.getRawInputStream(zae));
         }
 
-        final byte[] data = o.toByteArray();
+        final byte[] data = baos.toByteArray();
         final byte[] versionInLFH = Arrays.copyOfRange(data, 4, 6);
         // still 2.0 because of Deflate
         assertArrayEquals(new byte[] { 20, 0 }, versionInLFH);
@@ -128,30 +131,15 @@ public class DataDescriptorTest {
         assertEquals(sizeFromLFH, sizeFromCDH);
     }
 
-    private int findCentralDirectory(final byte[] data) {
-        // not a ZIP64 archive, no comment, "End of central directory record" 
at the end
-        return (int) ZipLong.getValue(data, data.length - 22 + 16);
-    }
-
-    @BeforeEach
-    public void setUp() throws Exception {
-        dir = mkdir("ddtest");
-    }
-
-    @AfterEach
-    public void tearDown() {
-        rmdir(dir);
-    }
-
     @Test
-    public void writesDataDescriptorForDeflatedEntryOnUnseekableOutput() 
throws IOException {
-        final ByteArrayOutputStream o = new ByteArrayOutputStream();
-        try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(o)) {
+    public void testWritesDataDescriptorForDeflatedEntryOnUnseekableOutput() 
throws IOException {
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(baos)) {
             zos.putArchiveEntry(new ZipArchiveEntry("test1.txt"));
             zos.write("foo".getBytes(UTF_8));
             zos.closeArchiveEntry();
         }
-        final byte[] data = o.toByteArray();
+        final byte[] data = baos.toByteArray();
 
         final byte[] versionInLFH = Arrays.copyOfRange(data, 4, 6);
         // 2.0 because of DD
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
index aa4c3690..cc7de0b9 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/ParallelScatterZipCreatorTest.java
@@ -17,7 +17,7 @@
 package org.apache.commons.compress.archivers.zip;
 
 import static org.apache.commons.compress.AbstractTestCase.getFile;
-import static org.apache.commons.compress.AbstractTestCase.tryHardToDelete;
+import static org.apache.commons.compress.AbstractTestCase.forceDelete;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -152,8 +152,8 @@ public class ParallelScatterZipCreatorTest {
 
     @AfterEach
     public void cleanup() {
-        tryHardToDelete(result);
-        tryHardToDelete(tmp);
+        forceDelete(result);
+        forceDelete(tmp);
     }
 
     @Test
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 2b0f65f8..8c7e9e9a 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,7 @@
  */
 package org.apache.commons.compress.archivers.zip;
 
-import static org.apache.commons.compress.AbstractTestCase.tryHardToDelete;
+import static org.apache.commons.compress.AbstractTestCase.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;
@@ -38,8 +38,8 @@ public class ScatterZipOutputStreamTest {
 
     @AfterEach
     public void cleanup() {
-        tryHardToDelete(scatterFile);
-        tryHardToDelete(target);
+        forceDelete(scatterFile);
+        forceDelete(target);
     }
 
     private InputStreamSupplier createPayloadSupplier(final 
ByteArrayInputStream payload) {
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java 
b/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
index f91d9d23..5aed4731 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/UTF8ZipFilesTest.java
@@ -186,7 +186,7 @@ public class UTF8ZipFilesTest extends AbstractTestCase {
             createTestFile(file, encoding, withEFS, withExplicitUnicodeExtra);
             testFile(file, encoding);
         } finally {
-            tryHardToDelete(file);
+            forceDelete(file);
         }
     }
 
@@ -372,7 +372,7 @@ public class UTF8ZipFilesTest extends AbstractTestCase {
             assertNotNull(zf.getEntry(OIL_BARREL_TXT));
         } finally {
             ZipFile.closeQuietly(zf);
-            tryHardToDelete(file);
+            forceDelete(file);
         }
     }
 
@@ -391,7 +391,7 @@ public class UTF8ZipFilesTest extends AbstractTestCase {
             if (zi != null) {
                 zi.close();
             }
-            tryHardToDelete(file);
+            forceDelete(file);
         }
     }
 
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
index 1bf6278f..5649f4a4 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/X5455_ExtendedTimestampTest.java
@@ -16,9 +16,6 @@
  */
 package org.apache.commons.compress.archivers.zip;
 
-import static org.apache.commons.compress.AbstractTestCase.getFile;
-import static org.apache.commons.compress.AbstractTestCase.mkdir;
-import static org.apache.commons.compress.AbstractTestCase.rmdir;
 import static 
org.apache.commons.compress.archivers.zip.X5455_ExtendedTimestamp.ACCESS_TIME_BIT;
 import static 
org.apache.commons.compress.archivers.zip.X5455_ExtendedTimestamp.CREATE_TIME_BIT;
 import static 
org.apache.commons.compress.archivers.zip.X5455_ExtendedTimestamp.MODIFY_TIME_BIT;
@@ -43,6 +40,7 @@ import java.util.Enumeration;
 import java.util.TimeZone;
 import java.util.zip.ZipException;
 
+import org.apache.commons.compress.AbstractTestCase;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -58,7 +56,6 @@ public class X5455_ExtendedTimestampTest {
         DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
     }
 
-
     /**
      * InfoZIP seems to adjust the time stored inside the LFH and CD
      * to GMT when writing ZIPs while java.util.zip.ZipEntry thinks it
@@ -92,7 +89,6 @@ public class X5455_ExtendedTimestampTest {
         xf = new X5455_ExtendedTimestamp();
     }
 
-
     private void parseReparse(
             final byte providedFlags,
             final ZipLong time,
@@ -159,7 +155,7 @@ public class X5455_ExtendedTimestampTest {
     @AfterEach
     public void removeTempFiles() {
         if (tmpDir != null) {
-            rmdir(tmpDir);
+            AbstractTestCase.forceDelete(tmpDir);
         }
     }
 
@@ -507,7 +503,7 @@ public class X5455_ExtendedTimestampTest {
         well.
          */
 
-        final File archive = getFile("COMPRESS-210_unix_time_zip_test.zip");
+        final File archive = 
AbstractTestCase.getFile("COMPRESS-210_unix_time_zip_test.zip");
 
         try (ZipFile zf = new ZipFile(archive)) {
             final Enumeration<ZipArchiveEntry> en = zf.getEntries();
@@ -585,7 +581,7 @@ public class X5455_ExtendedTimestampTest {
 
     @Test
     public void testWriteReadRoundtrip() throws IOException {
-        tmpDir = mkdir("X5455");
+        tmpDir = AbstractTestCase.mkdir("X5455");
         final File output = new File(tmpDir, "write_rewrite.zip");
         final Date d = new Date(97, 8, 24, 15, 10, 2);
         try (final OutputStream out = Files.newOutputStream(output.toPath());
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java 
b/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
index 89da791e..c4826aa4 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/Zip64SupportIT.java
@@ -289,10 +289,11 @@ public class Zip64SupportIT {
                     if (os != null) {
                         os.close();
                     }
-                    AbstractTestCase.tryHardToDelete(f);
+                    AbstractTestCase.forceDelete(f);
                 } finally {
                     if (dir != null) {
-                        AbstractTestCase.rmdir(dir);
+                        final File directory = dir;
+                        AbstractTestCase.forceDelete(directory);
                     }
                 }
             }
@@ -2327,7 +2328,7 @@ public class Zip64SupportIT {
             read5GBOfZerosUsingZipFileImpl(f, "5GB_of_Zeros");
         } finally {
             if (f != null) {
-                AbstractTestCase.tryHardToDelete(f);
+                AbstractTestCase.forceDelete(f);
             }
         }
     }
diff --git 
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileIgnoringLocalFileHeaderTest.java
 
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileIgnoringLocalFileHeaderTest.java
index 73ec86ce..a6330fbe 100644
--- 
a/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileIgnoringLocalFileHeaderTest.java
+++ 
b/src/test/java/org/apache/commons/compress/archivers/zip/ZipFileIgnoringLocalFileHeaderTest.java
@@ -27,9 +27,8 @@ import java.nio.file.Files;
 import java.util.Enumeration;
 
 import org.apache.commons.compress.AbstractTestCase;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 public class ZipFileIgnoringLocalFileHeaderTest {
 
@@ -37,6 +36,7 @@ public class ZipFileIgnoringLocalFileHeaderTest {
         return new ZipFile(AbstractTestCase.getFile(fileName), 
ZipEncodingHelper.UTF8, true, true);
     }
 
+    @TempDir
     private File dir;
 
     @Test
@@ -47,26 +47,6 @@ public class ZipFileIgnoringLocalFileHeaderTest {
         }
     }
 
-    @Test
-    public void getRawInputStreamReturnsNotNull() throws IOException {
-        try (final ZipFile zf = openZipWithoutLFH("bla.zip")) {
-            final ZipArchiveEntry ze = zf.getEntry("test1.xml");
-            try (InputStream rawInputStream = zf.getRawInputStream(ze)) {
-                assertNotNull(rawInputStream);
-            }
-        }
-    }
-
-    @BeforeEach
-    public void setUp() throws Exception {
-        dir = AbstractTestCase.mkdir("dir");
-    }
-
-    @AfterEach
-    public void tearDown() {
-        AbstractTestCase.rmdir(dir);
-    }
-
     @Test
     public void testDuplicateEntry() throws Exception {
         try (final ZipFile zf = openZipWithoutLFH("COMPRESS-227.zip")) {
@@ -81,6 +61,16 @@ public class ZipFileIgnoringLocalFileHeaderTest {
         }
     }
 
+    @Test
+    public void testGetRawInputStreamReturnsNotNull() throws IOException {
+        try (final ZipFile zf = openZipWithoutLFH("bla.zip")) {
+            final ZipArchiveEntry ze = zf.getEntry("test1.xml");
+            try (InputStream rawInputStream = zf.getRawInputStream(ze)) {
+                assertNotNull(rawInputStream);
+            }
+        }
+    }
+
     @Test
     public void testPhysicalOrder() throws IOException {
         try (final ZipFile zf = openZipWithoutLFH("ordertest.zip")) {
diff --git 
a/src/test/java/org/apache/commons/compress/changes/ChangeSetRawTypesTest.java 
b/src/test/java/org/apache/commons/compress/changes/ChangeSetRawTypesTest.java
index 58b8c4b5..8603efac 100644
--- 
a/src/test/java/org/apache/commons/compress/changes/ChangeSetRawTypesTest.java
+++ 
b/src/test/java/org/apache/commons/compress/changes/ChangeSetRawTypesTest.java
@@ -91,8 +91,8 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             assertTrue(results.getDeleted().isEmpty());
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(inputPath);
-            tryHardToDelete(result);
+            forceDelete(inputPath);
+            forceDelete(result);
         }
     }
 
@@ -121,7 +121,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             
assertTrue(results.getAddedFromChangeSet().contains("testdata/test1.xml"));
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -200,7 +200,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
 
     }
@@ -233,7 +233,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -275,7 +275,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -324,7 +324,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             assertEquals(6, results.getAddedFromStream().size());
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
 
     }
@@ -356,7 +356,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
 
     }
@@ -389,7 +389,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
 
     }
@@ -418,7 +418,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -445,7 +445,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -472,7 +472,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -499,7 +499,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -526,7 +526,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -651,7 +651,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -680,7 +680,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -786,7 +786,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             final List<String> expected = new ArrayList<>();
             expected.add("test1.xml");
             checkArchiveContent(result, expected);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -820,7 +820,7 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
             new ChangeSetPerformer(changeSet).perform(archiveInputStream, 
archiveOutputStream);
         } finally {
             checkArchiveContent(result, archiveList);
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
@@ -867,10 +867,10 @@ public final class ChangeSetRawTypesTest extends 
AbstractTestCase {
                         "111111111111111111111111111000101011".equals(str);
                     }
                 }
-                rmdir(check);
+                forceDelete(check);
             }
         } finally {
-            tryHardToDelete(result);
+            forceDelete(result);
         }
     }
 
diff --git 
a/src/test/java/org/apache/commons/compress/changes/ChangeSetSafeTypesTest.java 
b/src/test/java/org/apache/commons/compress/changes/ChangeSetSafeTypesTest.java
index de9c702a..7c7471e9 100644
--- 
a/src/test/java/org/apache/commons/compress/changes/ChangeSetSafeTypesTest.java
+++ 
b/src/test/java/org/apache/commons/compress/changes/ChangeSetSafeTypesTest.java
@@ -878,7 +878,7 @@ public final class ChangeSetSafeTypesTest<I extends 
ArchiveInputStream<E>, O ext
                     "111111111111111111111111111000101011".equals(str);
                 }
             }
-            rmdir(check);
+            forceDelete(check);
         }
     }
 
diff --git 
a/src/test/java/org/apache/commons/compress/compressors/lz4/CompressionDegradationTest.java
 
b/src/test/java/org/apache/commons/compress/compressors/lz4/CompressionDegradationTest.java
index 653825dc..4311c4cb 100644
--- 
a/src/test/java/org/apache/commons/compress/compressors/lz4/CompressionDegradationTest.java
+++ 
b/src/test/java/org/apache/commons/compress/compressors/lz4/CompressionDegradationTest.java
@@ -34,6 +34,23 @@ import java.util.Base64;
  */
 public class CompressionDegradationTest {
 
+    private static String compress(final String value) throws IOException {
+        try (ByteArrayOutputStream byteStream = new 
ByteArrayOutputStream(value.length());
+                FramedLZ4CompressorOutputStream compress = new 
FramedLZ4CompressorOutputStream(byteStream)) {
+            String compressedValue = null;
+            try {
+                compress.write(value.getBytes(StandardCharsets.UTF_8));
+                compress.finish();
+                compressedValue = 
Base64.getEncoder().encodeToString(byteStream.toByteArray());
+            } finally {
+                compress.close();
+                byteStream.close();
+            }
+
+            return compressedValue;
+        }
+    }
+
     public static void main(final String[] args) throws Exception {
         try (RandomAccessFile aFile = new 
RandomAccessFile("src/test/resources/org/apache/commons/compress/COMPRESS-649/some-900kb-text.txt",
 "r");
                 FileChannel inChannel = aFile.getChannel()) {
@@ -53,21 +70,4 @@ public class CompressionDegradationTest {
             System.out.println(sec + " seconds");
         }
     }
-
-    private static String compress(final String value) throws IOException {
-        try (ByteArrayOutputStream byteStream = new 
ByteArrayOutputStream(value.length());
-                FramedLZ4CompressorOutputStream compress = new 
FramedLZ4CompressorOutputStream(byteStream)) {
-            String compressedValue = null;
-            try {
-                compress.write(value.getBytes(StandardCharsets.UTF_8));
-                compress.finish();
-                compressedValue = 
Base64.getEncoder().encodeToString(byteStream.toByteArray());
-            } finally {
-                compress.close();
-                byteStream.close();
-            }
-
-            return compressedValue;
-        }
-    }
 }
\ No newline at end of file


Reply via email to