use of cn.taketoday.retry.interceptor.MethodInvocationRetryCallback in project today-infrastructure by TAKETODAY.
the class MethodInvocationRetryListenerSupportTests method testCloseWithRetryCallbackShouldntCallDoCloseMethod.
@Test
public void testCloseWithRetryCallbackShouldntCallDoCloseMethod() {
final AtomicInteger callsOnDoCloseMethod = new AtomicInteger(0);
MethodInvocationRetryListenerSupport support = new MethodInvocationRetryListenerSupport() {
@Override
protected <T, E extends Throwable> void doClose(RetryContext context, MethodInvocationRetryCallback<T, E> callback, Throwable throwable) {
callsOnDoCloseMethod.incrementAndGet();
}
};
RetryContext context = mock(RetryContext.class);
RetryCallback callback = mock(RetryCallback.class);
support.close(context, callback, null);
assertEquals(0, callsOnDoCloseMethod.get());
}
use of cn.taketoday.retry.interceptor.MethodInvocationRetryCallback in project today-infrastructure by TAKETODAY.
the class MethodInvocationRetryListenerSupportTests method testOpenWithMethodInvocationRetryCallbackShouldCallDoCloseMethod.
@Test
public void testOpenWithMethodInvocationRetryCallbackShouldCallDoCloseMethod() {
final AtomicInteger callsOnDoOpenMethod = new AtomicInteger(0);
MethodInvocationRetryListenerSupport support = new MethodInvocationRetryListenerSupport() {
@Override
protected <T, E extends Throwable> boolean doOpen(RetryContext context, MethodInvocationRetryCallback<T, E> callback) {
callsOnDoOpenMethod.incrementAndGet();
return true;
}
};
RetryContext context = mock(RetryContext.class);
MethodInvocationRetryCallback callback = mock(MethodInvocationRetryCallback.class);
assertTrue(support.open(context, callback));
assertEquals(1, callsOnDoOpenMethod.get());
}
use of cn.taketoday.retry.interceptor.MethodInvocationRetryCallback in project today-infrastructure by TAKETODAY.
the class MethodInvocationRetryListenerSupportTests method testCloseWithMethodInvocationRetryCallbackShouldCallDoCloseMethod.
@Test
public void testCloseWithMethodInvocationRetryCallbackShouldCallDoCloseMethod() {
final AtomicInteger callsOnDoCloseMethod = new AtomicInteger(0);
MethodInvocationRetryListenerSupport support = new MethodInvocationRetryListenerSupport() {
@Override
protected <T, E extends Throwable> void doClose(RetryContext context, MethodInvocationRetryCallback<T, E> callback, Throwable throwable) {
callsOnDoCloseMethod.incrementAndGet();
}
};
RetryContext context = mock(RetryContext.class);
MethodInvocationRetryCallback callback = mock(MethodInvocationRetryCallback.class);
support.close(context, callback, null);
assertEquals(1, callsOnDoCloseMethod.get());
}
use of cn.taketoday.retry.interceptor.MethodInvocationRetryCallback in project today-framework by TAKETODAY.
the class MethodInvocationRetryListenerSupportTests method testCloseWithMethodInvocationRetryCallbackShouldCallDoCloseMethod.
@Test
public void testCloseWithMethodInvocationRetryCallbackShouldCallDoCloseMethod() {
final AtomicInteger callsOnDoCloseMethod = new AtomicInteger(0);
MethodInvocationRetryListenerSupport support = new MethodInvocationRetryListenerSupport() {
@Override
protected <T, E extends Throwable> void doClose(RetryContext context, MethodInvocationRetryCallback<T, E> callback, Throwable throwable) {
callsOnDoCloseMethod.incrementAndGet();
}
};
RetryContext context = mock(RetryContext.class);
MethodInvocationRetryCallback callback = mock(MethodInvocationRetryCallback.class);
support.close(context, callback, null);
assertEquals(1, callsOnDoCloseMethod.get());
}
use of cn.taketoday.retry.interceptor.MethodInvocationRetryCallback in project today-framework by TAKETODAY.
the class MethodInvocationRetryListenerSupportTests method testOnErrorWithMethodInvocationRetryCallbackShouldCallDoOnErrorMethod.
@Test
public void testOnErrorWithMethodInvocationRetryCallbackShouldCallDoOnErrorMethod() {
final AtomicInteger callsOnDoOnErrorMethod = new AtomicInteger(0);
MethodInvocationRetryListenerSupport support = new MethodInvocationRetryListenerSupport() {
@Override
protected <T, E extends Throwable> void doOnError(RetryContext context, MethodInvocationRetryCallback<T, E> callback, Throwable throwable) {
callsOnDoOnErrorMethod.incrementAndGet();
}
};
RetryContext context = mock(RetryContext.class);
MethodInvocationRetryCallback callback = mock(MethodInvocationRetryCallback.class);
support.onError(context, callback, null);
assertEquals(1, callsOnDoOnErrorMethod.get());
}
Aggregations