@Test
  public void testExecuteOnlyOnce() throws Exception {
    ScheduledExecutorService ex = Executors.newScheduledThreadPool(1);

    MyConflationListener listener = new MyConflationListener();
    OneTaskOnlyExecutor decorator = new OneTaskOnlyExecutor(ex, listener, null);

    final CountDownLatch latch = new CountDownLatch(1);
    ex.submit((Callable) () -> {
      latch.await();
      return null;
    });

    final AtomicInteger counter = new AtomicInteger();

    Runnable increment = counter::incrementAndGet;

    for (int i = 0; i < 50; i++) {
      decorator.schedule(increment, 0, TimeUnit.SECONDS);
    }

    assertEquals(0, counter.get());
    latch.countDown();
    ex.shutdown();
    ex.awaitTermination(60, TimeUnit.SECONDS);
    assertEquals(1, counter.get());
    assertEquals(49, listener.getDropCount());
  }
Test to make sure we only execute the task once no matter how many times we schedule it.
geode-core/src/test/java/org/apache/geode/internal/OneTaskOnlyDecoratorJUnitTest.java