From aa6f836270f7c3ab00df1dc38ddebf2eb257633f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Alcarraz?= Date: Fri, 9 Feb 2024 10:11:09 -0500 Subject: [PATCH] Also test level 0 files. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrés Alcarraz --- .../test/java/org/jpos/util/DailyLogListenerTest.java | 5 +++++ .../java/org/jpos/util/LogRotationTestDirectory.java | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java b/jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java index 6a5ad7988c..84086a29d3 100644 --- a/jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java +++ b/jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java @@ -48,6 +48,7 @@ import org.jpos.core.SimpleConfiguration; import org.jpos.core.SubConfiguration; import org.jpos.q2.QFactory; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -62,6 +63,10 @@ public void createLogRotateAbortsTestDir(@TempDir Path tempDir) throws IOExcepti logRotationTestDirectory = new LogRotationTestDirectory(tempDir); } + @AfterEach + public void cleanLogRotateDir() throws IOException { + logRotationTestDirectory.delete(); + } @Test public void testCheckSize() { DailyLogListener dailyLogListener = new DailyLogListener(); diff --git a/jpos/src/test/java/org/jpos/util/LogRotationTestDirectory.java b/jpos/src/test/java/org/jpos/util/LogRotationTestDirectory.java index c241d180ff..c4fb0e053d 100644 --- a/jpos/src/test/java/org/jpos/util/LogRotationTestDirectory.java +++ b/jpos/src/test/java/org/jpos/util/LogRotationTestDirectory.java @@ -18,6 +18,7 @@ package org.jpos.util; +import java.io.File; import java.io.IOException; import java.nio.file.FileStore; import java.nio.file.Files; @@ -87,4 +88,14 @@ public void allowNewFileCreation() throws IOException { throw new IOException("Directory " + directory.toString() + " has unsupported FileStore type: " + filestore.type()); } } + + /** + * Deletes the directory and its content. + * @throws IOException if an exception is thrown while walking the directory + */ + public void delete() throws IOException { + Files.walk(directory) + .map(Path::toFile) + .forEach(File::delete); + } }