RESOLVED - issue BATCH-371: FlatFileItemWriter no longer uses LineAggregator
http://jira.springframework.org/browse/BATCH-371 OPEN - issue BATCH-349: ItemStreamAdapter isn't an Adapter http://jira.springframework.org/browse/BATCH-349 Use *CReator instead of *Unmapper Adapter -> Support
This commit is contained in:
@@ -25,7 +25,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.io.file.mapping.DefaultFieldSet;
|
||||
import org.springframework.batch.io.file.mapping.FieldSet;
|
||||
import org.springframework.batch.io.file.mapping.FieldSetUnmapper;
|
||||
import org.springframework.batch.io.file.mapping.FieldSetCreator;
|
||||
import org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
@@ -117,8 +117,8 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testWriteWithConverter() throws Exception {
|
||||
inputSource.setFieldSetUnmapper(new FieldSetUnmapper() {
|
||||
public FieldSet unmapItem(Object data) {
|
||||
inputSource.setFieldSetUnmapper(new FieldSetCreator() {
|
||||
public FieldSet mapItem(Object data) {
|
||||
return new DefaultFieldSet(new String[] { "FOO:" + data });
|
||||
}
|
||||
});
|
||||
@@ -135,8 +135,8 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testWriteWithConverterAndInfiniteLoop() throws Exception {
|
||||
inputSource.setFieldSetUnmapper(new FieldSetUnmapper() {
|
||||
public FieldSet unmapItem(Object data) {
|
||||
inputSource.setFieldSetUnmapper(new FieldSetCreator() {
|
||||
public FieldSet mapItem(Object data) {
|
||||
return new DefaultFieldSet(new String[] { "FOO:" + data });
|
||||
}
|
||||
});
|
||||
@@ -153,8 +153,8 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testWriteWithConverterAndString() throws Exception {
|
||||
inputSource.setFieldSetUnmapper(new FieldSetUnmapper() {
|
||||
public FieldSet unmapItem(Object data) {
|
||||
inputSource.setFieldSetUnmapper(new FieldSetCreator() {
|
||||
public FieldSet mapItem(Object data) {
|
||||
return new DefaultFieldSet(new String[] { "FOO:" + data });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -36,27 +36,27 @@ public class PassThroughFieldSetMapperTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper#unmapItem(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper#mapItem(java.lang.Object)}.
|
||||
*/
|
||||
public void testUnmapItemAsFieldSet() {
|
||||
FieldSet fieldSet = new DefaultFieldSet(new String[] { "foo", "bar" });
|
||||
assertEquals(fieldSet, mapper.unmapItem(fieldSet));
|
||||
assertEquals(fieldSet, mapper.mapItem(fieldSet));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper#unmapItem(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper#mapItem(java.lang.Object)}.
|
||||
*/
|
||||
public void testUnmapItemAsString() {
|
||||
assertEquals(new DefaultFieldSet(new String[] { "foo" }), mapper.unmapItem("foo"));
|
||||
assertEquals(new DefaultFieldSet(new String[] { "foo" }), mapper.mapItem("foo"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper#unmapItem(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.io.file.mapping.PassThroughFieldSetMapper#mapItem(java.lang.Object)}.
|
||||
*/
|
||||
public void testUnmapItemAsNonString() {
|
||||
Object object = new Object();
|
||||
assertEquals(new DefaultFieldSet(new String[] { "" + object }), mapper.unmapItem(object));
|
||||
assertEquals(new DefaultFieldSet(new String[] { "" + object }), mapper.mapItem(object));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
|
||||
private SimpleStreamManager manager = new SimpleStreamManager(new ResourcelessTransactionManager());
|
||||
|
||||
private ItemStreamAdapter stream = new ItemStreamAdapterExtension();
|
||||
private ItemStreamSupport stream = new StubItemStream();
|
||||
|
||||
private List list = new ArrayList();
|
||||
|
||||
@@ -139,12 +139,12 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getExecutionContext(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextTwoRegistrations() {
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
manager.register("foo", new ItemStreamSupport() {
|
||||
public ExecutionContext getExecutionContext() {
|
||||
return new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
}
|
||||
});
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
manager.register("foo", new ItemStreamSupport() {
|
||||
public ExecutionContext getExecutionContext() {
|
||||
return new ExecutionContext(PropertiesConverter.stringToProperties("foo=spam"));
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#close(java.lang.Object)}.
|
||||
*/
|
||||
public void testClose() {
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
manager.register("foo", new ItemStreamSupport() {
|
||||
public void close() throws StreamException {
|
||||
list.add("bar");
|
||||
super.close();
|
||||
@@ -173,7 +173,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#commit(org.springframework.transaction.TransactionStatus)}.
|
||||
*/
|
||||
public void testCommitWithoutMark() {
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
manager.register("foo", new ItemStreamSupport() {
|
||||
public void mark() {
|
||||
list.add("bar");
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#rollback(org.springframework.transaction.TransactionStatus)}.
|
||||
*/
|
||||
public void testRollbackWithoutMark() {
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
manager.register("foo", new ItemStreamSupport() {
|
||||
public void reset() {
|
||||
list.add("bar");
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
* manager's execution context.
|
||||
*/
|
||||
public void testGetExecutionContextPreservesValues() {
|
||||
stream = new ItemStreamAdapter() {
|
||||
stream = new ItemStreamSupport() {
|
||||
public ExecutionContext getExecutionContext() {
|
||||
ExecutionContext ctx = new ExecutionContext();
|
||||
ctx.putString("string", "testString");
|
||||
@@ -221,7 +221,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
}
|
||||
|
||||
}
|
||||
private final class ItemStreamAdapterExtension extends ItemStreamAdapter {
|
||||
private final class StubItemStream extends ItemStreamSupport {
|
||||
public ExecutionContext getExecutionContext() {
|
||||
return new ExecutionContext(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class ItemWriterAdapterIntegrationTests extends AbstractDependencyInjectionSpringContextTests {
|
||||
public class ItemWriterAdapterTests extends AbstractDependencyInjectionSpringContextTests {
|
||||
|
||||
private ItemWriter processor;
|
||||
|
||||
@@ -36,11 +36,11 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testBeforeInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List calls = new ArrayList();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerAdapter() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
public void before(RepeatContext context) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerAdapter() {
|
||||
}, new RepeatListenerSupport() {
|
||||
public void before(RepeatContext context) {
|
||||
calls.add("2");
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testBeforeInterceptorCanVeto() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List calls = new ArrayList();
|
||||
template.setListener(new RepeatListenerAdapter() {
|
||||
template.setListener(new RepeatListenerSupport() {
|
||||
public void before(RepeatContext context) {
|
||||
calls.add("1");
|
||||
context.setCompleteOnly();
|
||||
@@ -82,11 +82,11 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testAfterInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List calls = new ArrayList();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerAdapter() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
public void after(RepeatContext context, ExitStatus result) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerAdapter() {
|
||||
}, new RepeatListenerSupport() {
|
||||
public void after(RepeatContext context, ExitStatus result) {
|
||||
calls.add("2");
|
||||
}
|
||||
@@ -106,11 +106,11 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testOpenInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List calls = new ArrayList();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerAdapter() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
public void open(RepeatContext context) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerAdapter() {
|
||||
}, new RepeatListenerSupport() {
|
||||
public void open(RepeatContext context) {
|
||||
calls.add("2");
|
||||
context.setCompleteOnly();
|
||||
@@ -129,7 +129,7 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testSingleOpenInterceptor() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List calls = new ArrayList();
|
||||
template.setListener(new RepeatListenerAdapter() {
|
||||
template.setListener(new RepeatListenerSupport() {
|
||||
public void open(RepeatContext context) {
|
||||
calls.add("1");
|
||||
}
|
||||
@@ -148,11 +148,11 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testCloseInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List calls = new ArrayList();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerAdapter() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
public void close(RepeatContext context) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerAdapter() {
|
||||
}, new RepeatListenerSupport() {
|
||||
public void close(RepeatContext context) {
|
||||
calls.add("2");
|
||||
}
|
||||
@@ -173,11 +173,11 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testOnErrorInterceptors() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List calls = new ArrayList();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerAdapter() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
public void onError(RepeatContext context, Throwable t) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerAdapter() {
|
||||
}, new RepeatListenerSupport() {
|
||||
public void onError(RepeatContext context, Throwable t) {
|
||||
calls.add("2");
|
||||
}
|
||||
@@ -200,11 +200,11 @@ public class RepeatListenerTests extends TestCase {
|
||||
public void testOnErrorInterceptorsPrecedence() throws Exception {
|
||||
RepeatTemplate template = new RepeatTemplate();
|
||||
final List calls = new ArrayList();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerAdapter() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
public void after(RepeatContext context, ExitStatus result) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerAdapter() {
|
||||
}, new RepeatListenerSupport() {
|
||||
public void onError(RepeatContext context, Throwable t) {
|
||||
calls.add("2");
|
||||
}
|
||||
@@ -230,11 +230,11 @@ public class RepeatListenerTests extends TestCase {
|
||||
template.setTaskExecutor(new SimpleAsyncTaskExecutor());
|
||||
final List calls = new ArrayList();
|
||||
final List fails = new ArrayList();
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerAdapter() {
|
||||
template.setListeners(new RepeatListener[] { new RepeatListenerSupport() {
|
||||
public void after(RepeatContext context, ExitStatus result) {
|
||||
calls.add("1");
|
||||
}
|
||||
}, new RepeatListenerAdapter() {
|
||||
}, new RepeatListenerSupport() {
|
||||
public void onError(RepeatContext context, Throwable t) {
|
||||
calls.add("2");
|
||||
fails.add("2");
|
||||
|
||||
@@ -18,10 +18,10 @@ package org.springframework.batch.retry.interceptor;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class RetryListenerAdapterTests extends TestCase {
|
||||
public class RetryListenerSupportTests extends TestCase {
|
||||
|
||||
public void testClose() {
|
||||
RetryListenerAdapter support = new RetryListenerAdapter();
|
||||
RetryListenerSupport support = new RetryListenerSupport();
|
||||
try {
|
||||
support.close(null, null, null);
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class RetryListenerAdapterTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testOnError() {
|
||||
RetryListenerAdapter support = new RetryListenerAdapter();
|
||||
RetryListenerSupport support = new RetryListenerSupport();
|
||||
try {
|
||||
support.onError(null, null, null);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class RetryListenerAdapterTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testOpen() {
|
||||
RetryListenerAdapter support = new RetryListenerAdapter();
|
||||
RetryListenerSupport support = new RetryListenerSupport();
|
||||
assertTrue(support.open(null, null));
|
||||
}
|
||||
|
||||
@@ -37,13 +37,13 @@ public class RetryListenerTests extends TestCase {
|
||||
List list = new ArrayList();
|
||||
|
||||
public void testOpenInterceptors() throws Exception {
|
||||
template.setListeners(new RetryListener[] { new RetryListenerAdapter() {
|
||||
template.setListeners(new RetryListener[] { new RetryListenerSupport() {
|
||||
public boolean open(RetryContext context, RetryCallback callback) {
|
||||
count++;
|
||||
list.add("1:" + count);
|
||||
return true;
|
||||
}
|
||||
}, new RetryListenerAdapter() {
|
||||
}, new RetryListenerSupport() {
|
||||
public boolean open(RetryContext context, RetryCallback callback) {
|
||||
count++;
|
||||
list.add("2:" + count);
|
||||
@@ -61,7 +61,7 @@ public class RetryListenerTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testOpenCanVetoRetry() throws Exception {
|
||||
template.setListener(new RetryListenerAdapter() {
|
||||
template.setListener(new RetryListenerSupport() {
|
||||
public boolean open(RetryContext context, RetryCallback callback) {
|
||||
list.add("1");
|
||||
return false;
|
||||
@@ -85,12 +85,12 @@ public class RetryListenerTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testCloseInterceptors() throws Exception {
|
||||
template.setListeners(new RetryListener[] { new RetryListenerAdapter() {
|
||||
template.setListeners(new RetryListener[] { new RetryListenerSupport() {
|
||||
public void close(RetryContext context, RetryCallback callback, Throwable t) {
|
||||
count++;
|
||||
list.add("1:" + count);
|
||||
}
|
||||
}, new RetryListenerAdapter() {
|
||||
}, new RetryListenerSupport() {
|
||||
public void close(RetryContext context, RetryCallback callback, Throwable t) {
|
||||
count++;
|
||||
list.add("2:" + count);
|
||||
@@ -109,11 +109,11 @@ public class RetryListenerTests extends TestCase {
|
||||
|
||||
public void testOnError() throws Exception {
|
||||
template.setRetryPolicy(new NeverRetryPolicy());
|
||||
template.setListeners(new RetryListener[] { new RetryListenerAdapter() {
|
||||
template.setListeners(new RetryListener[] { new RetryListenerSupport() {
|
||||
public void onError(RetryContext context, RetryCallback callback, Throwable throwable) {
|
||||
list.add("1");
|
||||
}
|
||||
}, new RetryListenerAdapter() {
|
||||
}, new RetryListenerSupport() {
|
||||
public void onError(RetryContext context, RetryCallback callback, Throwable throwable) {
|
||||
list.add("2");
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class RetryListenerTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testCloseInterceptorsAfterRetry() throws Exception {
|
||||
template.setListener(new RetryListenerAdapter() {
|
||||
template.setListener(new RetryListenerSupport() {
|
||||
public void close(RetryContext context, RetryCallback callback, Throwable t) {
|
||||
list.add("" + count);
|
||||
// The last attempt should have been successful:
|
||||
|
||||
Reference in New Issue
Block a user