Skip to content

Commit

Permalink
Also test level 0 files.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrés Alcarraz <[email protected]>
  • Loading branch information
alcarraz committed Feb 9, 2024
1 parent 0cea909 commit aa6f836
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions jpos/src/test/java/org/jpos/util/LogRotationTestDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

0 comments on commit aa6f836

Please sign in to comment.