ContinuouslyRepeatScheduleStrategy implements ISchedulingStrategy { @Override public void processException(final ISchedulerEntry entry, final Throwable e) throws SchedulingStrategyExecutionException { try { entry.cancel(); } catch (EntryStorageAccessException | EntryScheduleException ee) { throw new SchedulingStrategyExecutionException("Error occurred cancelling failed scheduler entry.", ee); } } ContinuouslyRepeatScheduleStrategy(); @Override void init(final ISchedulerEntry entry, final IObject args); @Override void postProcess(final ISchedulerEntry entry); @Override void restore(final ISchedulerEntry entry); @Override void processException(final ISchedulerEntry entry, final Throwable e); @Override void notifyPaused(final ISchedulerEntry entry); @Override void notifyUnPaused(final ISchedulerEntry entry); @Override void processPausedExecution(final ISchedulerEntry entry);  }
@Test public void Should_cancelEntryWhenExceptionOccurs() throws Exception { ISchedulingStrategy strategy = new ContinuouslyRepeatScheduleStrategy(); strategy.processException(entry, mock(Throwable.class)); verify(entry).cancel(); }
@Test(expected = SchedulingStrategyExecutionException.class) public void Should_wrapExceptionWhenEntryCancellationThrows() throws Exception { doThrow(EntryScheduleException.class).when(entry).cancel(); ISchedulingStrategy strategy = new ContinuouslyRepeatScheduleStrategy(); strategy.processException(entry, mock(Throwable.class)); }