public void testExternalRetryWithFailAndNoRetry() throws Throwable {
MockRetryCallback callback = new MockRetryCallback();
RetryState retryState = new DefaultRetryState("foo");
RetryTemplate retryTemplate = new RetryTemplate();
MapRetryContextCache cache = new MapRetryContextCache();
retryTemplate.setRetryContextCache(cache);
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
assertFalse(cache.containsKey("foo"));
try {
retryTemplate.execute(callback, retryState);
// The first failed attempt we expect to retry...
fail("Expected RuntimeException");
}
catch (RuntimeException e) {
assertEquals(null, e.getMessage());
}
assertTrue(cache.containsKey("foo"));
try {
retryTemplate.execute(callback, retryState);
// We don't get a second attempt...
fail("Expected ExhaustedRetryException");
}
catch (ExhaustedRetryException e) {
// This is now the "exhausted" message: