Purge StreamContext some more
This commit is contained in:
@@ -191,7 +191,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
restartKeys.add(new Foo(5, "5", 5));
|
||||
}
|
||||
|
||||
public ExecutionAttributes getKeyAsStreamContext(Object key) {
|
||||
public ExecutionAttributes getKeyAsExecutionAttributes(Object key) {
|
||||
return streamContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import org.springframework.jdbc.core.PreparedStatementSetter;
|
||||
*/
|
||||
public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
|
||||
private static final String KEY = ColumnMapStreamContextRowMapper.KEY_PREFIX;
|
||||
private static final String KEY = ColumnMapExecutionAttributesRowMapper.KEY_PREFIX;
|
||||
|
||||
private ColumnMapStreamContextRowMapper mapper;
|
||||
private ColumnMapExecutionAttributesRowMapper mapper;
|
||||
|
||||
private Map key;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
mapper = new ColumnMapStreamContextRowMapper();
|
||||
mapper = new ColumnMapExecutionAttributesRowMapper();
|
||||
|
||||
key = CollectionFactory.createLinkedCaseInsensitiveMapIfPossible(2);
|
||||
key.put("1", new Integer(1));
|
||||
@@ -42,7 +42,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
public void testCreateRestartDataWithInvalidType() throws Exception {
|
||||
|
||||
try{
|
||||
mapper.createStreamContext(new Object());
|
||||
mapper.createExecutionAttributes(new Object());
|
||||
fail();
|
||||
}catch(IllegalArgumentException ex){
|
||||
//expected
|
||||
@@ -52,7 +52,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
public void testCreateRestartDataWithNull(){
|
||||
|
||||
try{
|
||||
mapper.createStreamContext(null);
|
||||
mapper.createExecutionAttributes(null);
|
||||
fail();
|
||||
}catch(IllegalArgumentException ex){
|
||||
//expected
|
||||
@@ -60,7 +60,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testCreateRestartData() throws Exception {
|
||||
ExecutionAttributes streamContext = mapper.createStreamContext(key);
|
||||
ExecutionAttributes streamContext = mapper.createExecutionAttributes(key);
|
||||
Properties props = streamContext.getProperties();
|
||||
assertEquals("1", props.getProperty(KEY + "0"));
|
||||
assertEquals("2", props.getProperty(KEY + "1"));
|
||||
@@ -68,7 +68,7 @@ public class ColumnMapRestartDataRowMapperTests extends TestCase {
|
||||
|
||||
public void testCreateRestartDataFromEmptyKeys() throws Exception {
|
||||
|
||||
ExecutionAttributes streamContext = mapper.createStreamContext(new HashMap());
|
||||
ExecutionAttributes streamContext = mapper.createExecutionAttributes(new HashMap());
|
||||
assertEquals(0, streamContext.getProperties().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran
|
||||
public void testRestoreKeys(){
|
||||
|
||||
ExecutionAttributes streamContext = new ExecutionAttributes();
|
||||
streamContext.putString(ColumnMapStreamContextRowMapper.KEY_PREFIX + "0", "3");
|
||||
streamContext.putString(ColumnMapStreamContextRowMapper.KEY_PREFIX + "1", "3");
|
||||
streamContext.putString(ColumnMapExecutionAttributesRowMapper.KEY_PREFIX + "0", "3");
|
||||
streamContext.putString(ColumnMapExecutionAttributesRowMapper.KEY_PREFIX + "1", "3");
|
||||
|
||||
List keys = keyStrategy.restoreKeys(streamContext);
|
||||
|
||||
@@ -66,18 +66,18 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran
|
||||
key.put("ID", new Long(3));
|
||||
key.put("VALUE", new Integer(3));
|
||||
|
||||
ExecutionAttributes streamContext = keyStrategy.getKeyAsStreamContext(key);
|
||||
ExecutionAttributes streamContext = keyStrategy.getKeyAsExecutionAttributes(key);
|
||||
Properties props = streamContext.getProperties();
|
||||
|
||||
assertEquals(2, props.size());
|
||||
assertEquals("3", props.get(ColumnMapStreamContextRowMapper.KEY_PREFIX + "0"));
|
||||
assertEquals("3", props.get(ColumnMapStreamContextRowMapper.KEY_PREFIX + "1"));
|
||||
assertEquals("3", props.get(ColumnMapExecutionAttributesRowMapper.KEY_PREFIX + "0"));
|
||||
assertEquals("3", props.get(ColumnMapExecutionAttributesRowMapper.KEY_PREFIX + "1"));
|
||||
}
|
||||
|
||||
public void testGetNullKeyAsStreamContext(){
|
||||
|
||||
try{
|
||||
keyStrategy.getKeyAsStreamContext(null);
|
||||
keyStrategy.getKeyAsExecutionAttributes(null);
|
||||
fail();
|
||||
}catch(IllegalArgumentException ex){
|
||||
//expected
|
||||
@@ -87,7 +87,7 @@ public class MultipleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTran
|
||||
public void testRestoreKeysFromNull(){
|
||||
|
||||
try{
|
||||
keyStrategy.getKeyAsStreamContext(null);
|
||||
keyStrategy.getKeyAsExecutionAttributes(null);
|
||||
}catch(IllegalArgumentException ex){
|
||||
//expected
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa
|
||||
|
||||
public void testGetKeyAsStreamContext(){
|
||||
|
||||
ExecutionAttributes streamContext = keyStrategy.getKeyAsStreamContext(new Long(3));
|
||||
ExecutionAttributes streamContext = keyStrategy.getKeyAsExecutionAttributes(new Long(3));
|
||||
Properties props = streamContext.getProperties();
|
||||
|
||||
assertEquals(1, props.size());
|
||||
@@ -64,7 +64,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa
|
||||
public void testGetNullKeyAsStreamContext(){
|
||||
|
||||
try{
|
||||
keyStrategy.getKeyAsStreamContext(null);
|
||||
keyStrategy.getKeyAsExecutionAttributes(null);
|
||||
fail();
|
||||
}catch(IllegalArgumentException ex){
|
||||
//expected
|
||||
@@ -74,7 +74,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa
|
||||
public void testRestoreKeysFromNull(){
|
||||
|
||||
try{
|
||||
keyStrategy.getKeyAsStreamContext(null);
|
||||
keyStrategy.getKeyAsExecutionAttributes(null);
|
||||
}catch(IllegalArgumentException ex){
|
||||
//expected
|
||||
}
|
||||
|
||||
@@ -17,13 +17,12 @@ package org.springframework.batch.item.writer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.io.Skippable;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.ExecutionAttributes;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
/**
|
||||
@@ -52,54 +51,6 @@ public class ItemWriterItemProcessorTests extends TestCase {
|
||||
assertEquals("test:foo", list.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets restart data from the input template
|
||||
*/
|
||||
public void testGetStreamContext() {
|
||||
Properties props = processor.getStreamContext().getProperties();
|
||||
assertEquals("foo", props.getProperty("value"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward restart data to input template
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRestoreFrom() throws Exception {
|
||||
processor.restoreFrom(new ExecutionAttributes(PropertiesConverter.stringToProperties("value=bar")));
|
||||
processor.write("foo");
|
||||
assertEquals("bar:foo", list.get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward restart data to input template
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testGetStreamContextWithoutItemStream() throws Exception {
|
||||
processor.setDelegate(null);
|
||||
try {
|
||||
processor.getStreamContext();
|
||||
fail("Expected IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward restart data to input template
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testRestoreFromWithoutRestartable() throws Exception {
|
||||
processor.setDelegate(null);
|
||||
try {
|
||||
processor.restoreFrom(new ExecutionAttributes(PropertiesConverter.stringToProperties("value=bar")));
|
||||
fail("Expected IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testSkip() {
|
||||
processor.skip();
|
||||
assertEquals(1, list.size());
|
||||
|
||||
Reference in New Issue
Block a user