diff --git a/jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java b/jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java index 2b921fb689..aafdd55fd2 100644 --- a/jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java +++ b/jpos/src/test/java/org/jpos/util/DailyLogListenerTest.java @@ -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); @@ -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);