use of cn.taketoday.retry.support.RetryTemplate in project today-infrastructure by TAKETODAY.
the class RetryOperationsInterceptorTests method testDefaultInterceptorWithRecovery.
@Test
public void testDefaultInterceptorWithRecovery() throws Exception {
RetryTemplate template = new RetryTemplate();
template.setRetryPolicy(new SimpleRetryPolicy(1));
this.interceptor.setRetryOperations(template);
this.interceptor.setRecoverer(new MethodInvocationRecoverer<Void>() {
@Override
public Void recover(Object[] args, Throwable cause) {
return null;
}
});
((Advised) this.service).addAdvice(this.interceptor);
this.service.service();
assertEquals(1, count);
}
use of cn.taketoday.retry.support.RetryTemplate in project today-infrastructure by TAKETODAY.
the class RetryOperationsInterceptorTests method testInterceptorChainWithRetry.
@Test
public void testInterceptorChainWithRetry() throws Exception {
((Advised) this.service).addAdvice(this.interceptor);
final List<String> list = new ArrayList<String>();
((Advised) this.service).addAdvice(new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
list.add("chain");
return invocation.proceed();
}
});
RetryTemplate template = new RetryTemplate();
template.setRetryPolicy(new SimpleRetryPolicy(2));
this.interceptor.setRetryOperations(template);
this.service.service();
assertEquals(2, count);
assertEquals(2, list.size());
}
Aggregations