Skip to content

Commit

Permalink
#19725 more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wezell committed Dec 22, 2020
1 parent 6836518 commit 515c10d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dotCMS/src/main/java/com/dotcms/concurrent/Debouncer.java
Expand Up @@ -45,7 +45,7 @@ public void run() {
++runCount;
Logger.info(Debouncer.class, () -> "Debouncer has run : " + runCount + " times");
}
Logger.info(Debouncer.class, () -> "Debouncer Runnning : " + key + " after " + delay + " " + unit);
Logger.info(Debouncer.class, () -> "Debouncing : " + key + " after " + delay + " " + unit);

runnable.run();
} finally {
Expand Down
13 changes: 9 additions & 4 deletions dotCMS/src/test/java/com/dotcms/concurrent/DebouncerTest.java
Expand Up @@ -39,13 +39,18 @@ public void test_that_debouncer_reschedules_the_runnable() throws InterruptedExc


debouncer.debounce("testingKey", ()->{Logger.info("DebouncerTest","running debouncer test" );}, 1, TimeUnit.SECONDS);
Thread.sleep(300);
debouncer.debounce("testingKey", ()->{Logger.info("DebouncerTest","running debouncer test" );}, 1, TimeUnit.SECONDS);
Thread.sleep(2000);
Thread.sleep(100);
debouncer.debounce("testingKey", ()->{Logger.info("DebouncerTest","running debouncer test" );}, 5, TimeUnit.SECONDS);

Thread.sleep(3000);
assertTrue("assert that we have not run yet", debouncer.runCount==0);

Thread.sleep(4000);
assertTrue("assert that we have only run once", debouncer.runCount==1);

debouncer.debounce("testingKey", ()->{Logger.info("DebouncerTest","running debouncer test" );}, 1, TimeUnit.SECONDS);
Thread.sleep(300);
Thread.sleep(100);

debouncer.debounce("testingKey", ()->{Logger.info("DebouncerTest","running debouncer test" );}, 1, TimeUnit.SECONDS);
Thread.sleep(2000);

Expand Down

0 comments on commit 515c10d

Please sign in to comment.