Merging changes from branch...

BATCH-1323: Modify skip/retry/no-rollback exception class configurations to allow for include/exclude
BATCH-1339: Move task-executor attribute up from <chunk/> to <tasklet/>
BATCH-1348: Allow inlining of reader/writer/processor into <chunk/>
BATCH-1357: Allow empty <listeners/>, <retry-listeners/>, and <streams/> lists
BATCH-1358: Move InfiniteLoopIncrementer into core, and rename it to RunIdIncrementer
BATCH-1367: Syntactic sugar for Item*Adapter in namespace
BATCH-1375: Give CompositeItemProcessor's and CompositeItemWriter's property the same name (delegates)
This commit is contained in:
dhgarrette
2009-08-23 15:17:20 +00:00
parent 9e8bdba83d
commit 8146e55503
72 changed files with 1168 additions and 902 deletions

View File

@@ -16,15 +16,14 @@
package org.springframework.batch.classify;
import java.util.Collection;
import java.util.Collections;
import org.springframework.batch.classify.BinaryExceptionClassifier;
import junit.framework.TestCase;
public class BinaryExceptionClassifierTests extends TestCase {
BinaryExceptionClassifier classifier = new BinaryExceptionClassifier();
BinaryExceptionClassifier classifier = new BinaryExceptionClassifier(false);
public void testClassifyNullIsDefault() {
assertFalse(classifier.classify(null));
@@ -44,8 +43,9 @@ public class BinaryExceptionClassifierTests extends TestCase {
}
public void testClassifyExactMatch() {
classifier.setTypes(Collections.<Class<? extends Throwable>> singleton(IllegalStateException.class));
assertTrue(classifier.classify(new IllegalStateException("Foo")));
Collection<Class<? extends Throwable>> set = Collections
.<Class<? extends Throwable>> singleton(IllegalStateException.class);
assertTrue(new BinaryExceptionClassifier(set).classify(new IllegalStateException("Foo")));
}
public void testTypesProvidedInConstructor() {

View File

@@ -33,7 +33,7 @@ public class CompositeItemProcessorTests {
processor1 = createMock(ItemProcessor.class);
processor2 = createMock(ItemProcessor.class);
composite.setItemProcessors(new ArrayList<ItemProcessor>() {{
composite.setDelegates(new ArrayList<ItemProcessor<Object,Object>>() {{
add(processor1); add(processor2);
}});
@@ -67,12 +67,11 @@ public class CompositeItemProcessorTests {
* The list of transformers must not be null or empty and
* can contain only instances of {@link ItemProcessor}.
*/
@SuppressWarnings("unchecked")
@Test
public void testAfterPropertiesSet() throws Exception {
// value not set
composite.setItemProcessors(null);
composite.setDelegates(null);
try {
composite.afterPropertiesSet();
fail();
@@ -82,7 +81,7 @@ public class CompositeItemProcessorTests {
}
// empty list
composite.setItemProcessors(new ArrayList<ItemProcessor>());
composite.setDelegates(new ArrayList<ItemProcessor<Object,Object>>());
try {
composite.afterPropertiesSet();
fail();

View File

@@ -5,6 +5,7 @@ import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -21,37 +22,35 @@ public class CompositeItemWriterTests extends TestCase {
// object under test
private CompositeItemWriter<Object> itemProcessor = new CompositeItemWriter<Object>();
/**
* Regular usage scenario.
* All injected processors should be called.
* Regular usage scenario. All injected processors should be called.
*/
public void testProcess() throws Exception {
final int NUMBER_OF_WRITERS = 10;
List<Object> data = Collections.singletonList(new Object());
@SuppressWarnings("unchecked")
ItemWriter<Object>[] writers = new ItemWriter[NUMBER_OF_WRITERS];
List<ItemWriter<? super Object>> writers = new ArrayList<ItemWriter<? super Object>>();
for (int i = 0; i < NUMBER_OF_WRITERS; i++) {
@SuppressWarnings("unchecked")
ItemWriter<Object> writer = createStrictMock(ItemWriter.class);
writer.write(data);
expectLastCall().once();
replay(writer);
writers[i] = writer;
writers.add(writer);
}
itemProcessor.setDelegates(writers);
itemProcessor.write(data);
for (ItemWriter<Object> writer : writers) {
verify(writer);
}
}
}

View File

@@ -19,6 +19,7 @@ package org.springframework.batch.retry.interceptor;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import junit.framework.TestCase;
@@ -28,7 +29,6 @@ import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.target.SingletonTargetSource;
import org.springframework.batch.retry.interceptor.RetryOperationsInterceptor;
import org.springframework.batch.retry.policy.NeverRetryPolicy;
import org.springframework.batch.retry.policy.SimpleRetryPolicy;
import org.springframework.batch.retry.support.RetryTemplate;
@@ -44,7 +44,7 @@ public class RetryOperationsInterceptorTests extends TestCase {
private Service service;
private ServiceImpl target;
private static int count;
private static int transactionCount;
@@ -53,8 +53,7 @@ public class RetryOperationsInterceptorTests extends TestCase {
super.setUp();
interceptor = new RetryOperationsInterceptor();
target = new ServiceImpl();
service = (Service) ProxyFactory.getProxy(Service.class,
new SingletonTargetSource(target));
service = (Service) ProxyFactory.getProxy(Service.class, new SingletonTargetSource(target));
count = 0;
transactionCount = 0;
}
@@ -75,7 +74,8 @@ public class RetryOperationsInterceptorTests extends TestCase {
}
});
RetryTemplate template = new RetryTemplate();
template.setRetryPolicy(new SimpleRetryPolicy(2));
template.setRetryPolicy(new SimpleRetryPolicy(2, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
interceptor.setRetryOperations(template);
service.service();
assertEquals(2, count);
@@ -90,20 +90,20 @@ public class RetryOperationsInterceptorTests extends TestCase {
try {
service.service();
fail("Expected Exception.");
} catch (Exception e) {
}
catch (Exception e) {
assertTrue(e.getMessage().startsWith("Not enough calls"));
}
assertEquals(1, count);
}
public void testOutsideTransaction() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
ClassUtils.addResourcePathToPackagePath(getClass(),
"retry-transaction-test.xml"));
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(ClassUtils
.addResourcePathToPackagePath(getClass(), "retry-transaction-test.xml"));
Object object = context.getBean("bean");
assertNotNull(object);
assertTrue(object instanceof Service);
Service bean = (Service) object ;
Service bean = (Service) object;
bean.doTansactional();
assertEquals(2, count);
// Expect 2 separate transactions...
@@ -134,20 +134,21 @@ public class RetryOperationsInterceptorTests extends TestCase {
}
});
fail("IllegalStateException expected");
} catch (IllegalStateException e) {
assertTrue("Exception message should contain MethodInvocation: "
+ e.getMessage(), e.getMessage()
.indexOf("MethodInvocation") >= 0);
}
catch (IllegalStateException e) {
assertTrue("Exception message should contain MethodInvocation: " + e.getMessage(), e.getMessage().indexOf(
"MethodInvocation") >= 0);
}
}
public static interface Service {
void service() throws Exception;
void doTansactional() throws Exception;
}
public static class ServiceImpl implements Service {
private boolean enteredTransaction = false;
public void service() throws Exception {
@@ -156,6 +157,7 @@ public class RetryOperationsInterceptorTests extends TestCase {
throw new Exception("Not enough calls: " + count);
}
}
public void doTansactional() throws Exception {
if (TransactionSynchronizationManager.isActualTransactionActive() && !enteredTransaction) {
transactionCount++;
@@ -164,10 +166,10 @@ public class RetryOperationsInterceptorTests extends TestCase {
enteredTransaction = false;
}
});
enteredTransaction = true;
enteredTransaction = true;
}
count++;
if (count==1) {
if (count == 1) {
throw new RuntimeException("Rollback please");
}
}

View File

@@ -108,7 +108,8 @@ public class StatefulRetryOperationsInterceptorTests extends TestCase {
}
});
interceptor.setRetryOperations(retryTemplate);
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
try {
service.service("foo");
fail("Expected Exception.");
@@ -126,7 +127,8 @@ public class StatefulRetryOperationsInterceptorTests extends TestCase {
public void testTransformerWithSuccessfulRetry() throws Exception {
((Advised) transformer).addAdvice(interceptor);
interceptor.setRetryOperations(retryTemplate);
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
try {
transformer.transform("foo");
fail("Expected Exception.");

View File

@@ -16,8 +16,8 @@
package org.springframework.batch.retry.policy;
import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
@@ -34,15 +34,15 @@ public class FatalExceptionRetryPolicyTests extends TestCase {
callback.setExceptionToThrow(new IllegalArgumentException());
RetryTemplate retryTemplate = new RetryTemplate();
// Allow multiple attempts in general...
SimpleRetryPolicy policy = new SimpleRetryPolicy(3);
retryTemplate.setRetryPolicy(policy);
// ...but make sure certain exceptions are fatal
@SuppressWarnings("unchecked")
List<Class<? extends Throwable>> list = Arrays.<Class<? extends Throwable>> asList(IllegalArgumentException.class,
IllegalStateException.class);
policy.setFatalExceptionClasses(list);
// Make sure certain exceptions are fatal...
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
map.put(IllegalArgumentException.class, false);
map.put(IllegalStateException.class, false);
// ... and allow multiple attempts
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, map);
retryTemplate.setRetryPolicy(policy);
RecoveryCallback<String> recoveryCallback = new RecoveryCallback<String>() {
public String recover(RetryContext context) throws Exception {
return "bar";
@@ -67,13 +67,14 @@ public class FatalExceptionRetryPolicyTests extends TestCase {
callback.setExceptionToThrow(new IllegalArgumentException());
RetryTemplate retryTemplate = new RetryTemplate();
SimpleRetryPolicy policy = new SimpleRetryPolicy(3);
Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
map.put(IllegalArgumentException.class, false);
map.put(IllegalStateException.class, false);
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, map);
retryTemplate.setRetryPolicy(policy);
@SuppressWarnings("unchecked")
List<Class<? extends Throwable>> list = Arrays.<Class<? extends Throwable>> asList(
IllegalArgumentException.class, IllegalStateException.class);
policy.setFatalExceptionClasses(list);
RecoveryCallback<String> recoveryCallback = new RecoveryCallback<String>() {
public String recover(RetryContext context) throws Exception {
return "bar";

View File

@@ -16,11 +16,16 @@
package org.springframework.batch.retry.policy;
import static org.junit.Assert.*;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.springframework.batch.retry.RetryContext;
@@ -29,7 +34,8 @@ public class SimpleRetryPolicyTests {
@Test
public void testCanRetryIfNoException() throws Exception {
SimpleRetryPolicy policy = new SimpleRetryPolicy();
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
RetryContext context = policy.open(null);
assertTrue(policy.canRetry(context));
}
@@ -37,12 +43,10 @@ public class SimpleRetryPolicyTests {
@Test
public void testEmptyExceptionsNeverRetry() throws Exception {
SimpleRetryPolicy policy = new SimpleRetryPolicy();
RetryContext context = policy.open(null);
// We can't retry any exceptions...
Collection<Class<? extends Throwable>> empty = Collections.emptySet();
policy.setRetryableExceptionClasses(empty);
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, Collections
.<Class<? extends Throwable>, Boolean> emptyMap());
RetryContext context = policy.open(null);
// ...so we can't retry this one...
policy.registerThrowable(context, new IllegalStateException());
@@ -51,7 +55,8 @@ public class SimpleRetryPolicyTests {
@Test
public void testRetryLimitInitialState() throws Exception {
SimpleRetryPolicy policy = new SimpleRetryPolicy();
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
RetryContext context = policy.open(null);
assertTrue(policy.canRetry(context));
policy.setMaxAttempts(0);
@@ -61,7 +66,8 @@ public class SimpleRetryPolicyTests {
@Test
public void testRetryLimitSubsequentState() throws Exception {
SimpleRetryPolicy policy = new SimpleRetryPolicy();
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
RetryContext context = policy.open(null);
policy.setMaxAttempts(2);
assertTrue(policy.canRetry(context));
@@ -73,7 +79,8 @@ public class SimpleRetryPolicyTests {
@Test
public void testRetryCount() throws Exception {
SimpleRetryPolicy policy = new SimpleRetryPolicy();
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
RetryContext context = policy.open(null);
assertNotNull(context);
policy.registerThrowable(context, null);
@@ -85,28 +92,20 @@ public class SimpleRetryPolicyTests {
@Test
public void testFatalOverridesRetryable() throws Exception {
SimpleRetryPolicy policy = new SimpleRetryPolicy();
policy.setFatalExceptionClasses(getClasses(Exception.class));
policy.setRetryableExceptionClasses(getClasses(RuntimeException.class));
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"));
assertFalse(policy.canRetry(context));
}
/**
* @param cls
* @return
*/
private Collection<Class<? extends Throwable>> getClasses(Class<? extends Throwable> cls) {
Collection<Class<? extends Throwable>> classes = new HashSet<Class<? extends Throwable>>();
classes.add(cls);
return classes;
assertTrue(policy.canRetry(context));
}
@Test
public void testParent() throws Exception {
SimpleRetryPolicy policy = new SimpleRetryPolicy();
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
RetryContext context = policy.open(null);
RetryContext child = policy.open(context);
assertNotSame(child, context);

View File

@@ -22,6 +22,8 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Collections;
import org.junit.Test;
import org.springframework.batch.retry.ExhaustedRetryException;
import org.springframework.batch.retry.RetryState;
@@ -45,7 +47,8 @@ public class StatefulRetryIntegrationTests {
RetryTemplate retryTemplate = new RetryTemplate();
MapRetryContextCache cache = new MapRetryContextCache();
retryTemplate.setRetryContextCache(cache);
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
assertFalse(cache.containsKey("foo"));
@@ -86,7 +89,8 @@ public class StatefulRetryIntegrationTests {
RetryTemplate retryTemplate = new RetryTemplate();
MapRetryContextCache cache = new MapRetryContextCache();
retryTemplate.setRetryContextCache(cache);
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
assertFalse(cache.containsKey("foo"));

View File

@@ -55,7 +55,8 @@ public class RetryTemplateTests {
MockRetryCallback callback = new MockRetryCallback();
callback.setAttemptsBeforeSuccess(x);
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(x));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(x, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
retryTemplate.execute(callback);
assertEquals(x, callback.attempts);
}
@@ -66,7 +67,8 @@ public class RetryTemplateTests {
MockRetryCallback callback = new MockRetryCallback();
callback.setAttemptsBeforeSuccess(3);
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(2, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
final Object value = new Object();
Object result = retryTemplate.execute(callback, new RecoveryCallback<Object>() {
public Object recover(RetryContext context) throws Exception {
@@ -94,7 +96,8 @@ public class RetryTemplateTests {
callback.setAttemptsBeforeSuccess(Integer.MAX_VALUE);
RetryTemplate retryTemplate = new RetryTemplate();
int retryAttempts = 2;
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(retryAttempts));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(retryAttempts, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
try {
retryTemplate.execute(callback);
fail("Expected IllegalArgumentException");
@@ -115,7 +118,8 @@ public class RetryTemplateTests {
callback.setExceptionToThrow(new IllegalArgumentException());
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(attempts));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(attempts, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
retryTemplate.execute(callback);
assertEquals(attempts, callback.attempts);
}
@@ -128,7 +132,8 @@ public class RetryTemplateTests {
callback.setExceptionToThrow(new IllegalArgumentException());
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(attempts));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(attempts, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
BinaryExceptionClassifier classifier = new BinaryExceptionClassifier(Collections
.<Class<? extends Throwable>> singleton(IllegalArgumentException.class), false);
retryTemplate.execute(callback, new DefaultRetryState("foo", classifier));
@@ -138,9 +143,9 @@ public class RetryTemplateTests {
@Test
public void testSetExceptions() throws Exception {
RetryTemplate template = new RetryTemplate();
SimpleRetryPolicy policy = new SimpleRetryPolicy();
SimpleRetryPolicy policy = new SimpleRetryPolicy(3, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(RuntimeException.class, true));
template.setRetryPolicy(policy);
policy.setRetryableExceptionClasses(Collections.<Class<? extends Throwable>> singleton(RuntimeException.class));
int attempts = 3;
@@ -168,7 +173,8 @@ public class RetryTemplateTests {
callback.setAttemptsBeforeSuccess(x);
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setBackOffPolicy(backOff);
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(x));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(x, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
retryTemplate.execute(callback);
assertEquals(x, callback.attempts);
assertEquals(1, backOff.startCalls);
@@ -264,9 +270,10 @@ public class RetryTemplateTests {
*/
@Test
public void testBackOffForRethrownException() throws Exception {
RetryTemplate tested = new RetryTemplate();
tested.setRetryPolicy(new SimpleRetryPolicy(1));
tested.setRetryPolicy(new SimpleRetryPolicy(1, Collections.<Class<? extends Throwable>, Boolean> singletonMap(
Exception.class, true)));
BackOffPolicy bop = createStrictMock(BackOffPolicy.class);
BackOffContext backOffContext = new BackOffContext() {
@@ -298,7 +305,7 @@ public class RetryTemplateTests {
catch (Exception expected) {
assertEquals("maybe next time!", expected.getMessage());
}
verify(bop);
}

View File

@@ -94,7 +94,8 @@ public class StatefulRecoveryRetryTests {
@Test
public void testRecover() throws Exception {
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
final String input = "foo";
RetryState state = new DefaultRetryState(input);
RetryCallback<String> callback = new RetryCallback<String>() {
@@ -126,14 +127,15 @@ public class StatefulRecoveryRetryTests {
@Test
public void testSwitchToStatelessForNoRollback() throws Exception {
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
// Roll back for these:
BinaryExceptionClassifier classifier = new BinaryExceptionClassifier(Collections
.<Class<? extends Throwable>> singleton(DataAccessException.class));
// ...but not these:
assertFalse(classifier.classify(new RuntimeException()));
final String input = "foo";
RetryState state = new DefaultRetryState(input,classifier);
RetryState state = new DefaultRetryState(input, classifier);
RetryCallback<String> callback = new RetryCallback<String>() {
public String doWithRetry(RetryContext context) throws Exception {
throw new RuntimeException("Barf!");
@@ -156,7 +158,8 @@ public class StatefulRecoveryRetryTests {
@Test
public void testExhaustedClearsHistoryAfterLastAttempt() throws Exception {
RetryPolicy retryPolicy = new SimpleRetryPolicy(1);
RetryPolicy retryPolicy = new SimpleRetryPolicy(1, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
retryTemplate.setRetryPolicy(retryPolicy);
final String input = "foo";
@@ -191,7 +194,8 @@ public class StatefulRecoveryRetryTests {
@Test
public void testKeyGeneratorNotConsistentAfterFailure() throws Throwable {
RetryPolicy retryPolicy = new SimpleRetryPolicy(3);
RetryPolicy retryPolicy = new SimpleRetryPolicy(3, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
retryTemplate.setRetryPolicy(retryPolicy);
final StringHolder item = new StringHolder("bar");
RetryState state = new DefaultRetryState(item);
@@ -235,7 +239,8 @@ public class StatefulRecoveryRetryTests {
@Test
public void testCacheCapacity() throws Exception {
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1));
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(1, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true)));
retryTemplate.setRetryContextCache(new MapRetryContextCache(1));
RetryCallback<Object> callback = new RetryCallback<Object>() {
@@ -266,7 +271,8 @@ public class StatefulRecoveryRetryTests {
@Test
public void testCacheCapacityNotReachedIfRecovered() throws Exception {
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(1);
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(1, Collections
.<Class<? extends Throwable>, Boolean> singletonMap(Exception.class, true));
retryTemplate.setRetryPolicy(retryPolicy);
retryTemplate.setRetryContextCache(new MapRetryContextCache(2));
final StringHolder item = new StringHolder("foo");