BATCH-219 and BATCH-330: Created ExecutionAttributes, which are stored in the table BATCH_STEP_EXECUTION_ATTRIBUTES.
This commit is contained in:
@@ -9,7 +9,8 @@ import junit.framework.TestCase;
|
||||
import org.springframework.batch.io.sample.domain.Foo;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.stream.GenericStreamContext;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -73,7 +74,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
StreamContext streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -95,7 +96,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
StreamContext streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -117,7 +118,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRestoreFromEmptyData() throws Exception {
|
||||
StreamContext streamContext = new StreamContext();
|
||||
ExecutionAttributes streamContext = new GenericStreamContext(new Properties());
|
||||
|
||||
getAsRestartable(source).restoreFrom(streamContext);
|
||||
|
||||
@@ -164,7 +165,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
|
||||
private static class MockKeyGenerator implements KeyGenerator{
|
||||
|
||||
static StreamContext streamContext;
|
||||
static ExecutionAttributes streamContext;
|
||||
List keys;
|
||||
List restartKeys;
|
||||
|
||||
@@ -173,7 +174,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
//restart data properties cannot be empty.
|
||||
props.setProperty("", "");
|
||||
|
||||
streamContext = new StreamContext(props);
|
||||
streamContext = new ExecutionAttributes(props);
|
||||
}
|
||||
|
||||
public MockKeyGenerator() {
|
||||
@@ -191,11 +192,11 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
restartKeys.add(new Foo(5, "5", 5));
|
||||
}
|
||||
|
||||
public StreamContext getKeyAsStreamContext(Object key) {
|
||||
public ExecutionAttributes getKeyAsStreamContext(Object key) {
|
||||
return streamContext;
|
||||
}
|
||||
|
||||
public List restoreKeys(StreamContext streamContext) {
|
||||
public List restoreKeys(ExecutionAttributes streamContext) {
|
||||
|
||||
assertEquals(MockKeyGenerator.streamContext, streamContext);
|
||||
return restartKeys;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.springframework.batch.io.driving;
|
||||
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.reader.AbstractItemReader;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -27,11 +27,11 @@ class FooItemReader extends AbstractItemReader implements ItemStream, ItemReader
|
||||
}
|
||||
}
|
||||
|
||||
public StreamContext getStreamContext() {
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return inputSource.getStreamContext();
|
||||
}
|
||||
|
||||
public void restoreFrom(StreamContext data) {
|
||||
public void restoreFrom(ExecutionAttributes data) {
|
||||
inputSource.restoreFrom(data);
|
||||
}
|
||||
|
||||
@@ -63,14 +63,14 @@ class FooItemReader extends AbstractItemReader implements ItemStream, ItemReader
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.item.ItemStream#mark(org.springframework.batch.item.StreamContext)
|
||||
*/
|
||||
public void mark(StreamContext streamContext) {
|
||||
public void mark(ExecutionAttributes streamContext) {
|
||||
inputSource.mark(streamContext);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.item.ItemStream#reset(org.springframework.batch.item.StreamContext)
|
||||
*/
|
||||
public void reset(StreamContext streamContext) {
|
||||
public void reset(ExecutionAttributes streamContext) {
|
||||
inputSource.reset(streamContext);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import java.util.Properties;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.stream.GenericStreamContext;
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
|
||||
@@ -60,7 +61,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testCreateRestartData() throws Exception {
|
||||
StreamContext streamContext = mapper.createStreamContext(key);
|
||||
ExecutionAttributes streamContext = mapper.createStreamContext(key);
|
||||
Properties props = streamContext.getProperties();
|
||||
assertEquals("1", props.getProperty(KEY + "0"));
|
||||
assertEquals("2", props.getProperty(KEY + "1"));
|
||||
@@ -68,7 +69,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
|
||||
public void testCreateRestartDataFromEmptyKeys() throws Exception {
|
||||
|
||||
StreamContext streamContext = mapper.createStreamContext(new HashMap());
|
||||
ExecutionAttributes streamContext = mapper.createStreamContext(new HashMap());
|
||||
assertEquals(0, streamContext.getProperties().size());
|
||||
}
|
||||
|
||||
@@ -77,7 +78,9 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
Properties props = new Properties();
|
||||
props.setProperty(KEY + "0", "1");
|
||||
props.setProperty(KEY + "1", "2");
|
||||
StreamContext streamContext = new StreamContext(props);
|
||||
ExecutionAttributes streamContext = new ExecutionAttributes();
|
||||
streamContext.putString(KEY + "0", "1");
|
||||
streamContext.putString(KEY + "1", "2");
|
||||
PreparedStatementSetter setter = mapper.createSetter(streamContext);
|
||||
ps = (PreparedStatement)psControl.getMock();
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.stream.GenericStreamContext;
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
|
||||
@@ -45,10 +46,9 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran
|
||||
|
||||
public void testRestoreKeys(){
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty(ColumnMapStreamContextRowMapper.KEY_PREFIX + "0", "3");
|
||||
props.setProperty(ColumnMapStreamContextRowMapper.KEY_PREFIX + "1", "3");
|
||||
StreamContext streamContext = new StreamContext(props);
|
||||
ExecutionAttributes streamContext = new ExecutionAttributes();
|
||||
streamContext.putString(ColumnMapStreamContextRowMapper.KEY_PREFIX + "0", "3");
|
||||
streamContext.putString(ColumnMapStreamContextRowMapper.KEY_PREFIX + "1", "3");
|
||||
|
||||
List keys = keyStrategy.restoreKeys(streamContext);
|
||||
|
||||
@@ -67,7 +67,7 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran
|
||||
key.put("ID", new Long(3));
|
||||
key.put("VALUE", new Integer(3));
|
||||
|
||||
StreamContext streamContext = keyStrategy.getKeyAsStreamContext(key);
|
||||
ExecutionAttributes streamContext = keyStrategy.getKeyAsStreamContext(key);
|
||||
Properties props = streamContext.getProperties();
|
||||
|
||||
assertEquals(2, props.size());
|
||||
|
||||
@@ -3,7 +3,8 @@ package org.springframework.batch.io.driving.support;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.stream.GenericStreamContext;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
|
||||
/**
|
||||
@@ -43,7 +44,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty(SingleColumnJdbcKeyGenerator.RESTART_KEY, "3");
|
||||
StreamContext streamContext = new StreamContext(props);
|
||||
ExecutionAttributes streamContext = new GenericStreamContext(props);
|
||||
|
||||
List keys = keyStrategy.restoreKeys(streamContext);
|
||||
|
||||
@@ -54,7 +55,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa
|
||||
|
||||
public void testGetKeyAsStreamContext(){
|
||||
|
||||
StreamContext streamContext = keyStrategy.getKeyAsStreamContext(new Long(3));
|
||||
ExecutionAttributes streamContext = keyStrategy.getKeyAsStreamContext(new Long(3));
|
||||
Properties props = streamContext.getProperties();
|
||||
|
||||
assertEquals(1, props.size());
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.batch.io.file.mapping.DefaultFieldSet;
|
||||
import org.springframework.batch.io.file.mapping.FieldSet;
|
||||
import org.springframework.batch.io.file.mapping.FieldSetMapper;
|
||||
import org.springframework.batch.io.file.transform.LineTokenizer;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.StreamException;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -179,7 +179,7 @@ public class DefaultFlatFileItemReaderTests extends TestCase {
|
||||
inputSource.read();
|
||||
|
||||
// get restart data
|
||||
StreamContext streamContext = inputSource.getStreamContext();
|
||||
ExecutionAttributes streamContext = inputSource.getStreamContext();
|
||||
assertEquals("4", (String) streamContext.getProperties().getProperty(
|
||||
DefaultFlatFileItemReader.READ_STATISTICS_NAME));
|
||||
// close input
|
||||
@@ -195,7 +195,7 @@ public class DefaultFlatFileItemReaderTests extends TestCase {
|
||||
assertEquals("[testLine5]", inputSource.read().toString());
|
||||
assertEquals("[testLine6]", inputSource.read().toString());
|
||||
|
||||
StreamContext statistics = inputSource.getStreamContext();
|
||||
ExecutionAttributes statistics = inputSource.getStreamContext();
|
||||
assertEquals(6, statistics.getLong(DefaultFlatFileItemReader.READ_STATISTICS_NAME));
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Collections;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.writer.ItemTransformer;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
@@ -309,7 +309,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
commit();
|
||||
|
||||
// get restart data
|
||||
StreamContext streamContext = inputSource.getStreamContext();
|
||||
ExecutionAttributes streamContext = inputSource.getStreamContext();
|
||||
// close template
|
||||
inputSource.close();
|
||||
|
||||
@@ -335,7 +335,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
inputSource.write("testLine8");
|
||||
|
||||
// get statistics
|
||||
StreamContext statistics = inputSource.getStreamContext();
|
||||
ExecutionAttributes statistics = inputSource.getStreamContext();
|
||||
// close template
|
||||
inputSource.close();
|
||||
|
||||
@@ -363,7 +363,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
public void testDefaultStreamContext() throws Exception {
|
||||
inputSource = new FlatFileItemWriter();
|
||||
inputSource.open();
|
||||
StreamContext streamContext = inputSource.getStreamContext();
|
||||
ExecutionAttributes streamContext = inputSource.getStreamContext();
|
||||
assertNotNull(streamContext);
|
||||
assertEquals(3, streamContext.getProperties().size());
|
||||
assertEquals(0, streamContext.getLong(FlatFileItemWriter.RESTART_DATA_NAME));
|
||||
|
||||
@@ -3,7 +3,8 @@ package org.springframework.batch.io.sql;
|
||||
import org.springframework.batch.io.sample.domain.Foo;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.stream.GenericStreamContext;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
@@ -76,7 +77,7 @@ public abstract class AbstractJdbcItemReaderIntegrationTests extends AbstractTra
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
StreamContext streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -98,7 +99,7 @@ public abstract class AbstractJdbcItemReaderIntegrationTests extends AbstractTra
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
StreamContext streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -120,7 +121,7 @@ public abstract class AbstractJdbcItemReaderIntegrationTests extends AbstractTra
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRestoreFromEmptyData() throws Exception {
|
||||
StreamContext streamContext = new StreamContext();
|
||||
ExecutionAttributes streamContext = new ExecutionAttributes();
|
||||
|
||||
getAsRestartable(source).restoreFrom(streamContext);
|
||||
|
||||
|
||||
@@ -4,7 +4,8 @@ import org.springframework.batch.io.Skippable;
|
||||
import org.springframework.batch.io.sample.domain.Foo;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.stream.GenericStreamContext;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
@@ -83,7 +84,7 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends Abstr
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
StreamContext streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -105,7 +106,7 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends Abstr
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
StreamContext streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -127,7 +128,7 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends Abstr
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRestoreFromEmptyData() throws Exception {
|
||||
StreamContext streamContext = new StreamContext();
|
||||
ExecutionAttributes streamContext = new ExecutionAttributes();
|
||||
|
||||
getAsRestartable(source).restoreFrom(streamContext);
|
||||
|
||||
@@ -208,7 +209,7 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends Abstr
|
||||
|
||||
rollback();
|
||||
|
||||
StreamContext streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.batch.io.support;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -57,12 +57,12 @@ public class AbstractTransactionalIoSourceTests extends TestCase {
|
||||
private boolean commitCalled = false;
|
||||
private boolean rollbackCalled = false;
|
||||
|
||||
public void mark(StreamContext streamContext) {
|
||||
public void mark(ExecutionAttributes streamContext) {
|
||||
Assert.isTrue(!commitCalled, "Commit aleady called");
|
||||
commitCalled = true;
|
||||
}
|
||||
|
||||
public void reset(StreamContext streamContext) {
|
||||
public void reset(ExecutionAttributes streamContext) {
|
||||
Assert.isTrue(!rollbackCalled, "Rollback aleady called");
|
||||
rollbackCalled = true;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.core.io.AbstractResource;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -112,7 +112,7 @@ public class StaxEventItemReaderTests extends TestCase {
|
||||
*/
|
||||
public void testRestart() {
|
||||
source.read();
|
||||
StreamContext streamContext = source.getStreamContext();
|
||||
ExecutionAttributes streamContext = source.getStreamContext();
|
||||
assertEquals(1, streamContext.getLong(StaxEventItemReader.READ_COUNT_STATISTICS_NAME));
|
||||
List expectedAfterRestart = (List) source.read();
|
||||
|
||||
@@ -127,7 +127,7 @@ public class StaxEventItemReaderTests extends TestCase {
|
||||
* already initialised when restoring.
|
||||
*/
|
||||
public void testInvalidRestore() {
|
||||
StreamContext context = new StreamContext();
|
||||
ExecutionAttributes context = new ExecutionAttributes();
|
||||
context.putLong(StaxEventItemReader.READ_COUNT_STATISTICS_NAME, 100000);
|
||||
try {
|
||||
source.restoreFrom(context);
|
||||
@@ -140,7 +140,7 @@ public class StaxEventItemReaderTests extends TestCase {
|
||||
source = createNewInputSouce();
|
||||
source.open();
|
||||
try {
|
||||
source.restoreFrom(new StreamContext());
|
||||
source.restoreFrom(new ExecutionAttributes());
|
||||
fail();
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.springframework.batch.io.xml.oxm.MarshallingEventWriterSerializer;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.oxm.Marshaller;
|
||||
@@ -88,7 +88,7 @@ public class StaxEventWriterItemWriterTests extends TestCase {
|
||||
// write records
|
||||
writer.write(record);
|
||||
writer.mark(null);
|
||||
StreamContext streamContext = writer.getStreamContext();
|
||||
ExecutionAttributes streamContext = writer.getStreamContext();
|
||||
|
||||
// create new writer from saved restart data and continue writing
|
||||
writer = createItemWriter();
|
||||
|
||||
@@ -21,14 +21,14 @@ import junit.framework.TestCase;
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class StreamContextTests extends TestCase{
|
||||
public class ExecutionAttributesTests extends TestCase{
|
||||
|
||||
StreamContext context;
|
||||
ExecutionAttributes context;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
context = new StreamContext();
|
||||
context = new ExecutionAttributes();
|
||||
}
|
||||
|
||||
public void testNormalUsage(){
|
||||
@@ -58,30 +58,41 @@ public class StreamContextTests extends TestCase{
|
||||
|
||||
public void testIsEmpty(){
|
||||
assertTrue(context.isEmpty());
|
||||
context.put("1", new Object());
|
||||
context.putString("1", "test");
|
||||
assertFalse(context.isEmpty());
|
||||
}
|
||||
|
||||
public void testDirtyFlag(){
|
||||
assertFalse(context.isDirty());
|
||||
context.put("1", new Object());
|
||||
context.putString("1", "test");
|
||||
assertTrue(context.isDirty());
|
||||
context.clearDirtyFlag();
|
||||
assertFalse(context.isDirty());
|
||||
}
|
||||
|
||||
public void testContains(){
|
||||
context.put("1", "testString");
|
||||
context.putString("1", "testString");
|
||||
assertTrue(context.containsKey("1"));
|
||||
assertTrue(context.containsValue("testString"));
|
||||
}
|
||||
|
||||
public void testEquals(){
|
||||
context.put("1", "testString");
|
||||
StreamContext tempContext = new StreamContext();
|
||||
context.putString("1", "testString");
|
||||
ExecutionAttributes tempContext = new ExecutionAttributes();
|
||||
assertFalse(tempContext.equals(context));
|
||||
tempContext.put("1", "testString");
|
||||
tempContext.putString("1", "testString");
|
||||
assertTrue(tempContext.equals(context));
|
||||
}
|
||||
|
||||
public void testSerializationCheck(){
|
||||
//adding a non serializable object should cause an error.
|
||||
try{
|
||||
context.put("1", new Object());
|
||||
fail();
|
||||
}
|
||||
catch(IllegalArgumentException ex){
|
||||
//expected
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import junit.framework.TestCase;
|
||||
import org.springframework.batch.io.Skippable;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ public class DelegatingItemReaderTests extends TestCase {
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRestoreFrom() throws Exception {
|
||||
itemProvider.restoreFrom(new StreamContext(PropertiesConverter.stringToProperties("value=bar")));
|
||||
itemProvider.restoreFrom(new ExecutionAttributes(PropertiesConverter.stringToProperties("value=bar")));
|
||||
assertEquals("bar", itemProvider.read());
|
||||
}
|
||||
|
||||
@@ -99,11 +99,11 @@ public class DelegatingItemReaderTests extends TestCase {
|
||||
return PropertiesConverter.stringToProperties("a=b");
|
||||
}
|
||||
|
||||
public StreamContext getStreamContext() {
|
||||
return new StreamContext(PropertiesConverter.stringToProperties("value=foo"));
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("value=foo"));
|
||||
}
|
||||
|
||||
public void restoreFrom(StreamContext data) {
|
||||
public void restoreFrom(ExecutionAttributes data) {
|
||||
value = data.getProperties().getProperty("value");
|
||||
}
|
||||
|
||||
@@ -129,10 +129,10 @@ public class DelegatingItemReaderTests extends TestCase {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void mark(StreamContext streamContext) {
|
||||
public void mark(ExecutionAttributes streamContext) {
|
||||
}
|
||||
|
||||
public void reset(StreamContext streamContext) {
|
||||
public void reset(ExecutionAttributes streamContext) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.StreamException;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
@@ -75,7 +76,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getStreamContext(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextEmpty() {
|
||||
StreamContext streamContext = manager.getStreamContext("foo");
|
||||
ExecutionAttributes streamContext = manager.getStreamContext("foo");
|
||||
assertEquals(0, streamContext.entrySet().size());
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
*/
|
||||
public void testGetStreamContextNotEmpty() {
|
||||
manager.register("foo", stream, null);
|
||||
StreamContext streamContext = manager.getStreamContext("foo");
|
||||
ExecutionAttributes streamContext = manager.getStreamContext("foo");
|
||||
assertEquals(1, streamContext.entrySet().size());
|
||||
assertEquals("bar", streamContext.getString(ClassUtils.getQualifiedName(stream.getClass()) + ".foo"));
|
||||
}
|
||||
@@ -96,7 +97,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
*/
|
||||
public void testGetStreamContextNotEmptyAndRestore() {
|
||||
testGetStreamContextNotEmpty();
|
||||
StreamContext context = manager.getStreamContext("foo");
|
||||
ExecutionAttributes context = manager.getStreamContext("foo");
|
||||
// Register again, now with the context that was created from the same
|
||||
// stream...
|
||||
manager.register("foo", stream, context);
|
||||
@@ -110,7 +111,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getStreamContext(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextNotEmptyAndRestoreWithNoPrefix() {
|
||||
StreamContext context = new StreamContext(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
ExecutionAttributes context = new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
manager.setUseClassNameAsPrefix(false);
|
||||
manager.register("foo", stream, context);
|
||||
assertEquals(1, list.size());
|
||||
@@ -125,7 +126,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
public void testGetStreamContextWithNoPrefix() {
|
||||
manager.setUseClassNameAsPrefix(false);
|
||||
manager.register("foo", stream, null);
|
||||
StreamContext context = manager.getStreamContext("foo");
|
||||
ExecutionAttributes context = manager.getStreamContext("foo");
|
||||
assertEquals(1, context.entrySet().size());
|
||||
// The list should have the foo= map value from the sub-context
|
||||
assertEquals("bar", context.getString("foo"));
|
||||
@@ -137,16 +138,16 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
*/
|
||||
public void testGetStreamContextTwoRegistrations() {
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
public StreamContext getStreamContext() {
|
||||
return new StreamContext(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
}
|
||||
}, null);
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
public StreamContext getStreamContext() {
|
||||
return new StreamContext(PropertiesConverter.stringToProperties("foo=spam"));
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=spam"));
|
||||
}
|
||||
}, null);
|
||||
StreamContext streamContext = manager.getStreamContext("foo");
|
||||
ExecutionAttributes streamContext = manager.getStreamContext("foo");
|
||||
assertEquals(2, streamContext.entrySet().size());
|
||||
}
|
||||
|
||||
@@ -234,8 +235,8 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
}
|
||||
|
||||
private final class ItemStreamAdapterExtension extends ItemStreamAdapter {
|
||||
public StreamContext getStreamContext() {
|
||||
return new StreamContext(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
}
|
||||
|
||||
public void restoreFrom(StreamContext context) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.io.Skippable;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.StreamContext;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public class ItemWriterItemProcessorTests extends TestCase {
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRestoreFrom() throws Exception {
|
||||
processor.restoreFrom(new StreamContext(PropertiesConverter.stringToProperties("value=bar")));
|
||||
processor.restoreFrom(new ExecutionAttributes(PropertiesConverter.stringToProperties("value=bar")));
|
||||
processor.write("foo");
|
||||
assertEquals("bar:foo", list.get(0));
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class ItemWriterItemProcessorTests extends TestCase {
|
||||
public void testRestoreFromWithoutRestartable() throws Exception {
|
||||
processor.setDelegate(null);
|
||||
try {
|
||||
processor.restoreFrom(new StreamContext(PropertiesConverter.stringToProperties("value=bar")));
|
||||
processor.restoreFrom(new ExecutionAttributes(PropertiesConverter.stringToProperties("value=bar")));
|
||||
fail("Expected IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
@@ -144,11 +144,11 @@ public class ItemWriterItemProcessorTests extends TestCase {
|
||||
public void open() {
|
||||
}
|
||||
|
||||
public StreamContext getStreamContext() {
|
||||
return new StreamContext(PropertiesConverter.stringToProperties("value=foo"));
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("value=foo"));
|
||||
}
|
||||
|
||||
public void restoreFrom(StreamContext data) {
|
||||
public void restoreFrom(ExecutionAttributes data) {
|
||||
value = data.getProperties().getProperty("value");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user