use of cn.taketoday.retry.RetryContext in project today-framework by TAKETODAY.
the class SimpleRetryPolicyTests method testFatalOverridesRetryable.
@Test
public void testFatalOverridesRetryable() throws Exception {
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
map.put(Exception.class, false);
map.put(RuntimeException.class, true);
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, map);
RetryContext context = policy.open(null);
assertNotNull(context);
policy.registerThrowable(context, new RuntimeException("foo"));
assertTrue(policy.canRetry(context));
}
use of cn.taketoday.retry.RetryContext in project today-framework by TAKETODAY.
the class RetrySynchronizationManagerTests method setUp.
@Before
public void setUp() throws Exception {
RetrySynchronizationManagerTests.clearAll();
RetryContext status = RetrySynchronizationManager.getContext();
assertNull(status);
}
use of cn.taketoday.retry.RetryContext in project today-framework by TAKETODAY.
the class RetrySynchronizationManagerTests method testStatusRegistration.
@Test
public void testStatusRegistration() throws Exception {
RetryContext status = new RetryContextSupport(null);
RetryContext value = RetrySynchronizationManager.register(status);
assertNull(value);
value = RetrySynchronizationManager.register(status);
assertEquals(status, value);
}
use of cn.taketoday.retry.RetryContext in project today-framework by TAKETODAY.
the class RetrySynchronizationManagerTests method testParent.
@Test
public void testParent() throws Exception {
RetryContext parent = new RetryContextSupport(null);
RetryContext child = new RetryContextSupport(parent);
assertSame(parent, child.getParent());
}
use of cn.taketoday.retry.RetryContext in project today-framework by TAKETODAY.
the class RetryTemplateTests method testFailedPolicy.
@SuppressWarnings("serial")
@Test
public void testFailedPolicy() throws Throwable {
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(new NeverRetryPolicy() {
@Override
public void registerThrowable(RetryContext context, Throwable throwable) {
throw new RuntimeException("Planned");
}
});
try {
retryTemplate.execute(new RetryCallback<Object, Exception>() {
@Override
public Object doWithRetry(RetryContext context) throws Exception {
throw new RuntimeException("Realllly bad!");
}
});
fail("Expected Error");
} catch (TerminatedRetryException e) {
assertEquals("Planned", e.getCause().getMessage());
}
}
Aggregations