BATCH-&*&: work in progress (some tests disabled)

This commit is contained in:
dsyer
2008-08-19 13:49:38 +00:00
parent cfc9529bab
commit 75fca027cb
39 changed files with 276 additions and 362 deletions

View File

@@ -4,7 +4,6 @@ import java.io.File;
import java.io.FileReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
@@ -43,9 +42,7 @@ public abstract class AbstractStaxEventWriterItemWriterTests extends TestCase {
* Write list of domain objects and check the output file.
*/
public void testWrite() throws Exception {
for (Iterator<Trade> iterator = objects.listIterator(); iterator.hasNext();) {
writer.write(iterator.next());
}
writer.write(objects);
writer.close(null);
XMLUnit.setIgnoreWhitespace(true);
XMLAssert.assertXMLEqual(new FileReader(expected.getFile()), new FileReader(resource.getFile()));
@@ -53,7 +50,9 @@ public abstract class AbstractStaxEventWriterItemWriterTests extends TestCase {
}
protected void setUp() throws Exception {
// File outputFile = File.createTempFile("AbstractStaxStreamWriterOutputSourceTests", "xml");
// File outputFile =
// File.createTempFile("AbstractStaxStreamWriterOutputSourceTests",
// "xml");
outputFile = File.createTempFile(ClassUtils.getShortName(this.getClass()), ".xml");
resource = new FileSystemResource(outputFile);
writer.setResource(resource);

View File

@@ -16,13 +16,18 @@
package org.springframework.batch.retry.jms;
import static org.junit.Assert.*;
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;
import org.springframework.batch.item.ItemRecoverer;
import org.springframework.batch.item.support.AbstractItemReader;
import org.springframework.batch.item.support.AbstractItemWriter;
@@ -32,18 +37,15 @@ import org.springframework.batch.retry.RetryContext;
import org.springframework.batch.retry.callback.RecoveryRetryCallback;
import org.springframework.batch.retry.policy.RecoveryCallbackRetryPolicy;
import org.springframework.batch.retry.support.RetryTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.ContextConfiguration;
import org.junit.runner.RunWith;
import org.junit.Before;
import org.junit.Test;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml")
@@ -107,10 +109,16 @@ public class ExternalRetryTests {
retryTemplate.setRetryPolicy(new RecoveryCallbackRetryPolicy());
final AbstractItemWriter<Object> writer = new AbstractItemWriter<Object>() {
public void write(final Object text) {
simpleJdbcTemplate.update("INSERT into T_FOOS (id,name,foo_date) values (?,?,null)", list.size(), text);
if (list.size() == 1) {
throw new RuntimeException("Rollback!");
public void write(final List<? extends Object> texts) {
for (Object text : texts) {
simpleJdbcTemplate.update("INSERT into T_FOOS (id,name,foo_date) values (?,?,null)", list.size(),
text);
if (list.size() == 1) {
throw new RuntimeException("Rollback!");
}
}
}
@@ -123,7 +131,7 @@ public class ExternalRetryTests {
final Object item = provider.read();
RecoveryRetryCallback callback = new RecoveryRetryCallback(item, new RetryCallback() {
public Object doWithRetry(RetryContext context) throws Throwable {
writer.write(item);
writer.write(Collections.singletonList(item));
return null;
}
});
@@ -151,7 +159,7 @@ public class ExternalRetryTests {
final Object item = provider.read();
RecoveryRetryCallback callback = new RecoveryRetryCallback(item, new RetryCallback() {
public Object doWithRetry(RetryContext context) throws Throwable {
writer.write(item);
writer.write(Collections.singletonList(item));
return null;
}
});
@@ -190,7 +198,7 @@ public class ExternalRetryTests {
throw new RuntimeException("Rollback!");
}
});
callback.setRecoveryCallback(new RecoveryCallback() {
public Object recover(RetryContext context) {
return provider.recover(item, context.getLastThrowable());