Skip to content

Commit

Permalink
Don`t reuse filename in different tests.
Browse files Browse the repository at this point in the history
So it does not fail on windows.

Signed-off-by: Andrés Alcarraz <[email protected]>

jpos#580 About the rotation of q2 logs
  • Loading branch information
alcarraz committed Feb 8, 2024
1 parent c0f6a79 commit 8741c4c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,14 @@ public void testMaxAgeFeatureWhenThereIsNonLogFiles() throws Exception {
public void testDeleteOldLogsWithCustomMaxDepth() throws ConfigurationException, IOException, IllegalAccessException {
Path parent = logRotationTestDirectory.getDirectory().resolve("parent");
Files.createDirectory(parent);
Path child = parent.resolve("child");
Files.createFile(child);
Path child = Files.createTempFile(parent, "child", ".log");
assertThat("file should have been created", child.toFile(), is(anExistingFile()));
Files.setLastModifiedTime(child, FileTime.from(Instant.now().minus(1, ChronoUnit.DAYS))); //old enough
DailyLogListener listener = new DailyLogListener();
SimpleConfiguration cfg = new SimpleConfiguration();
cfg.put("prefix", child.toAbsolutePath().toString());
cfg.put("max-depth-deletion", "2");
cfg.put("delete-regex", "^child$");
cfg.put("delete-regex", "^child.*\\.log");
cfg.put("maxage", "1000");
QFactory.autoconfigure(listener, cfg);
listener.setConfiguration(cfg);
Expand All @@ -459,14 +458,13 @@ public void testDeleteOldLogsWithCustomMaxDepth() throws ConfigurationException,
public void testDeleteOldLogsWithoutCustomMaxDepth() throws ConfigurationException, IOException, IllegalAccessException {
Path parent = logRotationTestDirectory.getDirectory().resolve("parent");
Files.createDirectory(parent);
Path child = parent.resolve("child");
Files.createFile(child);
Path child = Files.createTempFile(parent, "child", ".log");
assertThat("file should have been created", child.toFile(), is(anExistingFile()));
Files.setLastModifiedTime(child, FileTime.from(Instant.now().minus(1, ChronoUnit.DAYS))); //old enough
DailyLogListener listener = new DailyLogListener();
SimpleConfiguration cfg = new SimpleConfiguration();
cfg.put("prefix", child.toAbsolutePath().toString());
cfg.put("delete-regex", "^child$");
cfg.put("delete-regex", "^child.*\\.log");
cfg.put("maxage", "1000");
QFactory.autoconfigure(listener, cfg);
listener.setConfiguration(cfg);
Expand Down

0 comments on commit 8741c4c

Please sign in to comment.