From 8741c4c38ae1743475b1336c630f13de9c5b59da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Alcarraz?= Date: Thu, 8 Feb 2024 18:49:13 -0500 Subject: [PATCH] Don`t reuse filename in different tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So it does not fail on windows. Signed-off-by: Andrés Alcarraz #580 About the rotation of q2 logs --- .../test/java/org/jpos/util/DailyLogListenerTest.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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);