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/04/17 20:40:18 UTC

[commons-io] branch master updated: USe JUnit TempDir instead of custom code.

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-io.git


The following commit(s) were added to refs/heads/master by this push:
     new 79465833 USe JUnit TempDir instead of custom code.
79465833 is described below

commit 794658337ff5a74ca0accc1f14530c82b0d9e55d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Apr 17 16:40:10 2022 -0400

    USe JUnit TempDir instead of custom code.
---
 .../io/file/PathUtilsCleanDirectoryTest.java        | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/src/test/java/org/apache/commons/io/file/PathUtilsCleanDirectoryTest.java b/src/test/java/org/apache/commons/io/file/PathUtilsCleanDirectoryTest.java
index 351a53bb..d8bccb1e 100644
--- a/src/test/java/org/apache/commons/io/file/PathUtilsCleanDirectoryTest.java
+++ b/src/test/java/org/apache/commons/io/file/PathUtilsCleanDirectoryTest.java
@@ -18,39 +18,22 @@
 package org.apache.commons.io.file;
 
 import static org.apache.commons.io.file.CounterAssertions.assertCounts;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.IOException;
-import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-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;
 
 /**
  * Tests {@link DeletingPathVisitor}.
  */
 public class PathUtilsCleanDirectoryTest {
 
+    @TempDir
     private Path tempDir;
 
-    @AfterEach
-    public void afterEach() throws IOException {
-        // temp dir should still exist since we are cleaning and not deleting.
-        assertTrue(Files.exists(tempDir));
-        // backstop
-        if (Files.exists(tempDir) && PathUtils.isEmptyDirectory(tempDir)) {
-            Files.deleteIfExists(tempDir);
-        }
-    }
-
-    @BeforeEach
-    public void beforeEach() throws IOException {
-        tempDir = Files.createTempDirectory(getClass().getCanonicalName());
-    }
-
     /**
      * Tests a directory with one file of size 0.
      */