From a7eb9bc8fab7011f5c9c4bd31cb5470cee6f9586 Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Tue, 9 Aug 2022 10:35:18 +0200 Subject: [PATCH] minor refactoring in /ReconfigureOnChangeTaskTest Signed-off-by: Ceki Gulcu --- .../joran/ReconfigureOnChangeTaskTest.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/ReconfigureOnChangeTaskTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/ReconfigureOnChangeTaskTest.java index 3b763677ed..1bf8793be3 100755 --- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/ReconfigureOnChangeTaskTest.java +++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/ReconfigureOnChangeTaskTest.java @@ -34,7 +34,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -99,6 +101,11 @@ void configure(InputStream is) throws JoranException { jc.doConfigure(is); } + + @Before + public void before() { + System.out.println(this.getClass().getName()+"#before"); + } // void gConfigure(File file) throws JoranException { // GafferConfigurator gc = new GafferConfigurator(loggerContext); // gc.run(file); @@ -179,7 +186,7 @@ public void fallbackToSafe_FollowedByRecovery() throws IOException, JoranExcepti " "); configure(topLevelFile); StatusPrinter.print(loggerContext); - CountDownLatch changeDetectedLatch = waitForReconfigurationToBeDone(null); + CountDownLatch changeDetectedLatch = registerNewReconfigurationDoneListener_WithNewROCT(null); ReconfigureOnChangeTask oldRoct = getRegisteredReconfigureTask(); addInfo("registered ReconfigureOnChangeTask ", oldRoct); @@ -199,7 +206,7 @@ public void fallbackToSafe_FollowedByRecovery() throws IOException, JoranExcepti loggerContext.getStatusManager().clear(); addInfo("after loggerContext.getStatusManager().clear() oldRoct="+ oldRoct, this); - CountDownLatch secondDoneLatch = waitForReconfigurationToBeDone(oldRoct); + CountDownLatch secondDoneLatch = registerNewReconfigurationDoneListener_WithNewROCT(oldRoct); writeToFile(topLevelFile, " "); @@ -213,7 +220,7 @@ public void fallbackToSafe_FollowedByRecovery() throws IOException, JoranExcepti } } - @Test(timeout = 4000L) + @Test(timeout = 3000L) public void fallbackToSafeWithIncludedFile_FollowedByRecovery() throws IOException, JoranException, InterruptedException, ExecutionException { String topLevelFileAsStr = CoreTestConstants.OUTPUT_DIR_PREFIX + "reconfigureOnChangeConfig_top-" + diff @@ -229,12 +236,12 @@ public void fallbackToSafeWithIncludedFile_FollowedByRecovery() writeToFile(innerFile, " "); configure(topLevelFile); - CountDownLatch doneLatch = waitForReconfigurationToBeDone(null); + CountDownLatch doneLatch = registerNewReconfigurationDoneListener_WithNewROCT(null); ReconfigureOnChangeTask oldRoct = getRegisteredReconfigureTask(); assertNotNull(oldRoct); writeToFile(innerFile, "\n\n"); - doneLatch.await(); + doneLatch.await(2000, TimeUnit.MILLISECONDS); statusChecker.assertContainsMatch(Status.WARN, FALLING_BACK_TO_SAFE_CONFIGURATION); statusChecker.assertContainsMatch(Status.INFO, RE_REGISTERING_PREVIOUS_SAFE_CONFIGURATION); @@ -242,7 +249,7 @@ public void fallbackToSafeWithIncludedFile_FollowedByRecovery() loggerContext.getStatusManager().clear(); try { - CountDownLatch secondDoneLatch = waitForReconfigurationToBeDone(oldRoct); + CountDownLatch secondDoneLatch = registerNewReconfigurationDoneListener_WithNewROCT(oldRoct); writeToFile(innerFile, " "); secondDoneLatch.await(); @@ -311,7 +318,7 @@ private ReconfigureOnChangeTask waitForReconfigureOnChangeTaskToRun() throws Int return roct; } - private CountDownLatch waitForReconfigurationToBeDone(ReconfigureOnChangeTask oldTask) throws InterruptedException { + private CountDownLatch registerNewReconfigurationDoneListener_WithNewROCT(ReconfigureOnChangeTask oldTask) throws InterruptedException { addInfo("waitForReconfigurationToBeDone oldTask=" + oldTask, this); ReconfigureOnChangeTask roct = oldTask;