Skip to content

Commit

Permalink
more robust logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ceki committed Mar 16, 2016
1 parent c5dde75 commit 355642a
Showing 1 changed file with 7 additions and 8 deletions.
Expand Up @@ -181,17 +181,17 @@ public void fallbackToSafe_FollowedByRecovery() throws IOException, JoranExcepti
File topLevelFile = new File(path);
writeToFile(topLevelFile, "<configuration scan=\"true\" scanPeriod=\"5 millisecond\"><root level=\"ERROR\"/></configuration> ");
configure(topLevelFile);
CountDownLatch changeDetectedLatch = waitForTaskAndAttachReconfigDoneListener(null);
writeToFile(topLevelFile, "<configuration scan=\"true\" scanPeriod=\"5 millisecond\">\n" + " <root></configuration>");
CountDownLatch changeDetectedLatch = waitForReconfigurationToBeDone(null);
ReconfigureOnChangeTask oldRoct = getRegisteredReconfigureTask();
writeToFile(topLevelFile, "<configuration scan=\"true\" scanPeriod=\"5 millisecond\">\n" + " <root></configuration>");
changeDetectedLatch.await();

statusChecker.assertContainsMatch(Status.WARN, FALLING_BACK_TO_SAFE_CONFIGURATION);
statusChecker.assertContainsMatch(Status.INFO, RE_REGISTERING_PREVIOUS_SAFE_CONFIGURATION);

loggerContext.getStatusManager().clear();

CountDownLatch secondDoneLatch = waitForTaskAndAttachReconfigDoneListener(oldRoct);
CountDownLatch secondDoneLatch = waitForReconfigurationToBeDone(oldRoct);
writeToFile(topLevelFile, "<configuration scan=\"true\" scanPeriod=\"5 millisecond\"><root level=\"ERROR\"/></configuration> ");
secondDoneLatch.await();

Expand All @@ -211,17 +211,17 @@ public void fallbackToSafeWithIncludedFile_FollowedByRecovery() throws IOExcepti
writeToFile(innerFile, "<included><root level=\"ERROR\"/></included> ");
configure(topLevelFile);

CountDownLatch doneLatch = waitForTaskAndAttachReconfigDoneListener(null);
writeToFile(innerFile, "<included>\n<root>\n</included>");
CountDownLatch doneLatch = waitForReconfigurationToBeDone(null);
ReconfigureOnChangeTask oldRoct = getRegisteredReconfigureTask();
writeToFile(innerFile, "<included>\n<root>\n</included>");
doneLatch.await();

statusChecker.assertContainsMatch(Status.WARN, FALLING_BACK_TO_SAFE_CONFIGURATION);
statusChecker.assertContainsMatch(Status.INFO, RE_REGISTERING_PREVIOUS_SAFE_CONFIGURATION);

loggerContext.getStatusManager().clear();

CountDownLatch secondDoneLatch = waitForTaskAndAttachReconfigDoneListener(oldRoct);
CountDownLatch secondDoneLatch = waitForReconfigurationToBeDone(oldRoct);
writeToFile(innerFile, "<included><root level=\"ERROR\"/></included> ");
secondDoneLatch.await();

Expand Down Expand Up @@ -285,7 +285,7 @@ private ReconfigureOnChangeTask waitForReconfigureOnChangeTaskToRun() throws Int
return roct;
}

private CountDownLatch waitForTaskAndAttachReconfigDoneListener(ReconfigureOnChangeTask oldTask) throws InterruptedException {
private CountDownLatch waitForReconfigurationToBeDone(ReconfigureOnChangeTask oldTask) throws InterruptedException {
ReconfigureOnChangeTask roct = oldTask;
while (roct == oldTask) {
roct = getRegisteredReconfigureTask();
Expand All @@ -294,7 +294,6 @@ private CountDownLatch waitForTaskAndAttachReconfigDoneListener(ReconfigureOnCha

CountDownLatch countDownLatch = new CountDownLatch(1);
roct.addListener(new ReconfigurationDoneListener(countDownLatch));
System.out.println("added ReconfigurationDoneListener");
return countDownLatch;
}

Expand Down

0 comments on commit 355642a

Please sign in to comment.