use of org.springframework.retry.backoff.StatelessBackOffPolicy in project spring-retry by spring-projects.
the class RetryTemplateTests method testBackOffInterrupted.
@Test
public void testBackOffInterrupted() throws Throwable {
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setBackOffPolicy(new StatelessBackOffPolicy() {
@Override
protected void doBackOff() throws BackOffInterruptedException {
throw new BackOffInterruptedException("foo");
}
});
try {
retryTemplate.execute(new RetryCallback<Object, Exception>() {
@Override
public Object doWithRetry(RetryContext context) throws Exception {
throw new RuntimeException("Bad!");
}
});
fail("Expected RuntimeException");
} catch (BackOffInterruptedException e) {
assertEquals("foo", e.getMessage());
}
}
Aggregations