use of cn.taketoday.retry.backoff.StatelessBackOffPolicy in project today-infrastructure by TAKETODAY.
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());
}
}
use of cn.taketoday.retry.backoff.StatelessBackOffPolicy in project today-framework by TAKETODAY.
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