Collections.<ValueSpecification>emptySet(), Collections.<ValueSpecification>emptySet(), ExecutionLogMode.INDICATORS);
public void testNoAlert() throws Exception {
final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
try {
final MaximumJobItemExecutionWatchdog watchdog = new MaximumJobItemExecutionWatchdog();
watchdog.setMaxJobItemExecutionTime(Timeout.standardTimeoutMillis() / 2);
watchdog.setScheduler(scheduler);
final CyclicBarrier barrier = new CyclicBarrier(2);
(new Thread() {
@Override
public void run() {
try {
barrier.await(Timeout.standardTimeoutMillis(), TimeUnit.MILLISECONDS);
barrier.reset();
watchdog.jobExecutionStarted(JOB);
watchdog.jobExecutionStopped();
barrier.await(Timeout.standardTimeoutMillis() * 2, TimeUnit.MILLISECONDS);
watchdog.jobExecutionStarted(JOB);
watchdog.jobExecutionStopped();
} catch (final Exception e) {
throw new OpenGammaRuntimeException("exception", e);
}
}
}).start();
barrier.await(Timeout.standardTimeoutMillis(), TimeUnit.MILLISECONDS);
Thread.sleep(Timeout.standardTimeoutMillis());
// Watchdog should have run while the thread is alive, but not executing anything
assertTrue(watchdog.areThreadsAlive());
barrier.await(Timeout.standardTimeoutMillis(), TimeUnit.MILLISECONDS);
Thread.sleep(Timeout.standardTimeoutMillis());
// Watchdog should have run with the thread dead
assertFalse(watchdog.areThreadsAlive());
} finally {
scheduler.shutdown();
}
}