}
}
@Test(timeOut = 5000)
public void testExceptionInScheduleWithFixedDelayRunnableIncludesSubmissionTrace() throws Exception {
ListeningScheduledExecutorService sched = injector.getInstance(Key.get(ListeningScheduledExecutorService.class,
named(PROPERTY_SCHEDULER_THREADS)));
String submission = null;
try {
// this is sensitive to formatting as we are looking for the stack traces to match. if you wrap the below
// line again, you'll need to change incrementInitialElement to 3 line numbers instead of 2.
submission = getStackTraceAsString(incrementInitialElement(new RuntimeException(), 2))
.replaceFirst(format(".*%s", LINE_SEPARATOR), "");
sched.scheduleWithFixedDelay(runnableThrowsRTE(), 0, 1, TimeUnit.MICROSECONDS).get();
} catch (ExecutionException e) {
assertTraceHasSubmission(getStackTraceAsString(e), submission);
assertTraceHasSubmission(getStackTraceAsString(e.getCause()), submission);
}
}