@Test
public void testScheduledExecutorServiceCancelWithFixedDelay() throws InterruptedException {

	ScheduledExecutor scheduledExecutor = akkaRpcService.getScheduledExecutor();
	long delay = 10L;
	final OneShotLatch futureTask = new OneShotLatch();
	final OneShotLatch latch = new OneShotLatch();
	final OneShotLatch shouldNotBeTriggeredLatch = new OneShotLatch();
	ScheduledFuture<?> future = scheduledExecutor.scheduleWithFixedDelay(
		new Runnable() {
			@Override
			public void run() {
				try {
					if (!futureTask.isTriggered()) {
						// first run
						futureTask.trigger();
						latch.await();
					} else {
						shouldNotBeTriggeredLatch.trigger();
					}
				} catch (InterruptedException e) {
					// ignore
				}
			}
		},
		delay,
		delay,
		TimeUnit.MILLISECONDS);
	// wait until we're in the runnable
	futureTask.await();
	// cancel the scheduled future
	future.cancel(false);
	latch.trigger();
	try {
		shouldNotBeTriggeredLatch.await(5 * delay, TimeUnit.MILLISECONDS);
		fail("The shouldNotBeTriggeredLatch should never be triggered.");
	} catch (TimeoutException e) {
		// expected
	}
}