TimeoutStepExecutor { void runWithinPeriod(Runnable runnable, ExecuteStepMessage executeStepMessage) { runWithinPeriod( runnable, executeStepMessage, executeStepMessage.getTimeoutPeriodSeconds(), TimeUnit.SECONDS ); } TimeoutStepExecutor(BiConsumer<String, ExecuteStepMessage> stepFailureConsumer);   }
@Test public void testAStepExecutionCanBeInterrupted() throws Exception { CountDownLatch countDownLatch = new CountDownLatch(1); TimeoutStepExecutor stepExecutor = new TimeoutStepExecutor((a, b) -> {}); stepExecutor.runWithinPeriod(() -> { try { Thread.sleep(1000); } catch (InterruptedException e) { countDownLatch.countDown(); } }, new ExecuteStepMessage(), 10, TimeUnit.MILLISECONDS); boolean ok = countDownLatch.await(1, TimeUnit.SECONDS); if ( ! ok) { fail("Not interrupted"); } }