Updated Spring Retry to 1.1.0.RC1

This commit is contained in:
Michael Minella
2014-05-02 13:04:31 -05:00
parent bd01760466
commit 6913f5c022
13 changed files with 112 additions and 117 deletions

View File

@@ -15,36 +15,35 @@
*/
package org.springframework.batch.container.jms;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.retry.RecoveryCallback;
import org.springframework.retry.RetryCallback;
import org.springframework.retry.RetryContext;
import org.springframework.retry.policy.NeverRetryPolicy;
import org.springframework.retry.support.DefaultRetryState;
import org.springframework.retry.support.RetryTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author Dave Syer
*
@@ -137,7 +136,7 @@ public class BatchMessageListenerContainerIntegrationTests {
@Override
public void onMessage(final Message msg) {
try {
RetryCallback<Message> callback = new RetryCallback<Message>() {
RetryCallback<Message, Exception> callback = new RetryCallback<Message, Exception>() {
@Override
public Message doWithRetry(RetryContext context) throws Exception {
try {

View File

@@ -16,14 +16,6 @@
package org.springframework.batch.jms;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.sql.DataSource;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -51,6 +43,13 @@ import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
public class ExternalRetryInBatchTests {
@@ -136,7 +135,7 @@ public class ExternalRetryInBatchTests {
return RepeatStatus.FINISHED;
}
RetryCallback<String> callback = new RetryCallback<String>() {
RetryCallback<String, Exception> callback = new RetryCallback<String, Exception>() {
@Override
public String doWithRetry(RetryContext context) throws Exception {
// No need for transaction here: the whole batch will roll

View File

@@ -16,15 +16,6 @@
package org.springframework.batch.retry.jms;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.sql.DataSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,6 +36,14 @@ import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
public class ExternalRetryTests {
@@ -102,7 +101,7 @@ public class ExternalRetryTests {
final ItemWriter<Object> writer = new ItemWriter<Object>() {
@Override
public void write(final List<? extends Object> texts) {
public void write(final List<?> texts) {
for (Object text : texts) {
@@ -123,7 +122,7 @@ public class ExternalRetryTests {
public Object doInTransaction(TransactionStatus status) {
try {
final Object item = provider.read();
RetryCallback<Object> callback = new RetryCallback<Object>() {
RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
@Override
public Object doWithRetry(RetryContext context) throws Exception {
writer.write(Collections.singletonList(item));
@@ -153,7 +152,7 @@ public class ExternalRetryTests {
public Object doInTransaction(TransactionStatus status) {
try {
final String item = provider.read();
RetryCallback<Object> callback = new RetryCallback<Object>() {
RetryCallback<Object, Exception> callback = new RetryCallback<Object, Exception>() {
@Override
public Object doWithRetry(RetryContext context) throws Exception {
writer.write(Collections.singletonList(item));
@@ -187,7 +186,7 @@ public class ExternalRetryTests {
assertInitialState();
final String item = provider.read();
final RetryCallback<String> callback = new RetryCallback<String>() {
final RetryCallback<String, Exception> callback = new RetryCallback<String, Exception>() {
@Override
public String doWithRetry(RetryContext context) throws Exception {
jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), item);

View File

@@ -16,16 +16,6 @@
package org.springframework.batch.retry.jms;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import javax.sql.DataSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,6 +38,15 @@ import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.ClassUtils;
import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
public class SynchronousTests {
@@ -124,7 +123,7 @@ public class SynchronousTests {
final String text = (String) jmsTemplate.receiveAndConvert("queue");
assertNotNull(text);
retryTemplate.execute(new RetryCallback<String>() {
retryTemplate.execute(new RetryCallback<String, Exception>() {
@Override
public String doWithRetry(RetryContext status) throws Exception {
@@ -176,7 +175,7 @@ public class SynchronousTests {
final String item = (String) provider.read();
retryTemplate.execute(new RetryCallback<String>() {
retryTemplate.execute(new RetryCallback<String, Exception>() {
@Override
public String doWithRetry(RetryContext context) throws Exception {
@@ -240,7 +239,7 @@ public class SynchronousTests {
final String text = (String) jmsTemplate.receiveAndConvert("queue");
try {
retryTemplate.execute(new RetryCallback<String>() {
retryTemplate.execute(new RetryCallback<String, Exception>() {
@Override
public String doWithRetry(RetryContext status) throws Exception {
@@ -297,7 +296,7 @@ public class SynchronousTests {
assertInitialState();
retryTemplate.execute(new RetryCallback<String>() {
retryTemplate.execute(new RetryCallback<String, Exception>() {
@Override
public String doWithRetry(RetryContext status) throws Exception {
@@ -347,7 +346,7 @@ public class SynchronousTests {
try {
retryTemplate.execute(new RetryCallback<String>() {
retryTemplate.execute(new RetryCallback<String, Exception>() {
@Override
public String doWithRetry(RetryContext status) throws Exception {