Purge StreamContext
This commit is contained in:
@@ -73,7 +73,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getExecutionAttributes();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -95,7 +95,7 @@ public class DrivingQueryItemReaderTests extends TestCase {
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getExecutionAttributes();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
|
||||
@@ -27,8 +27,8 @@ class FooItemReader extends AbstractItemReader implements ItemStream, ItemReader
|
||||
}
|
||||
}
|
||||
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
return inputSource.getStreamContext();
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
return inputSource.getExecutionAttributes();
|
||||
}
|
||||
|
||||
public void restoreFrom(ExecutionAttributes data) {
|
||||
|
||||
@@ -156,7 +156,7 @@ public class DefaultFlatFileItemReaderTests extends TestCase {
|
||||
inputSource.setFieldSetMapper(fieldSetMapper);
|
||||
// do not open the template...
|
||||
try {
|
||||
inputSource.restoreFrom(inputSource.getStreamContext());
|
||||
inputSource.restoreFrom(inputSource.getExecutionAttributes());
|
||||
} catch (StreamException e) {
|
||||
assertTrue("Message does not contain open: "+e.getMessage(), e.getMessage().contains("open"));
|
||||
}
|
||||
@@ -179,7 +179,7 @@ public class DefaultFlatFileItemReaderTests extends TestCase {
|
||||
inputSource.read();
|
||||
|
||||
// get restart data
|
||||
ExecutionAttributes streamContext = inputSource.getStreamContext();
|
||||
ExecutionAttributes streamContext = inputSource.getExecutionAttributes();
|
||||
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());
|
||||
|
||||
ExecutionAttributes statistics = inputSource.getStreamContext();
|
||||
ExecutionAttributes statistics = inputSource.getExecutionAttributes();
|
||||
assertEquals(6, statistics.getLong(DefaultFlatFileItemReader.READ_STATISTICS_NAME));
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
commit();
|
||||
|
||||
// get restart data
|
||||
ExecutionAttributes streamContext = inputSource.getStreamContext();
|
||||
ExecutionAttributes streamContext = inputSource.getExecutionAttributes();
|
||||
// close template
|
||||
inputSource.close();
|
||||
|
||||
@@ -335,7 +335,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
inputSource.write("testLine8");
|
||||
|
||||
// get statistics
|
||||
ExecutionAttributes statistics = inputSource.getStreamContext();
|
||||
ExecutionAttributes statistics = inputSource.getExecutionAttributes();
|
||||
// close template
|
||||
inputSource.close();
|
||||
|
||||
@@ -363,7 +363,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
public void testDefaultStreamContext() throws Exception {
|
||||
inputSource = new FlatFileItemWriter();
|
||||
inputSource.open();
|
||||
ExecutionAttributes streamContext = inputSource.getStreamContext();
|
||||
ExecutionAttributes streamContext = inputSource.getExecutionAttributes();
|
||||
assertNotNull(streamContext);
|
||||
assertEquals(3, streamContext.getProperties().size());
|
||||
assertEquals(0, streamContext.getLong(FlatFileItemWriter.RESTART_DATA_NAME));
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract class AbstractJdbcItemReaderIntegrationTests extends AbstractTra
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getExecutionAttributes();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractJdbcItemReaderIntegrationTests extends AbstractTra
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getExecutionAttributes();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends Abstr
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getExecutionAttributes();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -105,7 +105,7 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends Abstr
|
||||
Foo foo2 = (Foo) source.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getExecutionAttributes();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -208,7 +208,7 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends Abstr
|
||||
|
||||
rollback();
|
||||
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getStreamContext();
|
||||
ExecutionAttributes streamContext = getAsRestartable(source).getExecutionAttributes();
|
||||
|
||||
// create new input source
|
||||
source = createItemReader();
|
||||
@@ -221,11 +221,11 @@ public abstract class AbstractDataSourceItemReaderIntegrationTests extends Abstr
|
||||
}
|
||||
|
||||
private void commit() {
|
||||
((ItemStream) source).mark(((ItemStream) source).getStreamContext());
|
||||
((ItemStream) source).mark(((ItemStream) source).getExecutionAttributes());
|
||||
}
|
||||
|
||||
private void rollback() {
|
||||
((ItemStream) source).reset(((ItemStream) source).getStreamContext());
|
||||
((ItemStream) source).reset(((ItemStream) source).getExecutionAttributes());
|
||||
}
|
||||
|
||||
private Skippable getAsSkippable(ItemReader source) {
|
||||
|
||||
@@ -112,7 +112,7 @@ public class StaxEventItemReaderTests extends TestCase {
|
||||
*/
|
||||
public void testRestart() {
|
||||
source.read();
|
||||
ExecutionAttributes streamContext = source.getStreamContext();
|
||||
ExecutionAttributes streamContext = source.getExecutionAttributes();
|
||||
assertEquals(1, streamContext.getLong(StaxEventItemReader.READ_COUNT_STATISTICS_NAME));
|
||||
List expectedAfterRestart = (List) source.read();
|
||||
|
||||
@@ -208,7 +208,7 @@ public class StaxEventItemReaderTests extends TestCase {
|
||||
}
|
||||
|
||||
private long extractRecordCount() {
|
||||
return source.getStreamContext().getLong(StaxEventItemReader.READ_COUNT_STATISTICS_NAME);
|
||||
return source.getExecutionAttributes().getLong(StaxEventItemReader.READ_COUNT_STATISTICS_NAME);
|
||||
}
|
||||
|
||||
public void testCloseWithoutOpen() throws Exception {
|
||||
|
||||
@@ -88,7 +88,7 @@ public class StaxEventWriterItemWriterTests extends TestCase {
|
||||
// write records
|
||||
writer.write(record);
|
||||
writer.mark(null);
|
||||
ExecutionAttributes streamContext = writer.getStreamContext();
|
||||
ExecutionAttributes streamContext = writer.getExecutionAttributes();
|
||||
|
||||
// create new writer from saved restart data and continue writing
|
||||
writer = createItemWriter();
|
||||
@@ -116,7 +116,7 @@ public class StaxEventWriterItemWriterTests extends TestCase {
|
||||
for (int i = 1; i <= NUMBER_OF_RECORDS; i++) {
|
||||
writer.write(record);
|
||||
long writeStatistics =
|
||||
writer.getStreamContext().getLong(StaxEventItemWriter.WRITE_STATISTICS_NAME);
|
||||
writer.getExecutionAttributes().getLong(StaxEventItemWriter.WRITE_STATISTICS_NAME);
|
||||
|
||||
assertEquals(i, writeStatistics);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class DelegatingItemReaderTests extends TestCase {
|
||||
* Gets restart data from the input template
|
||||
*/
|
||||
public void testGetStreamContext() {
|
||||
Properties props = itemProvider.getStreamContext().getProperties();
|
||||
Properties props = itemProvider.getExecutionAttributes().getProperties();
|
||||
assertEquals("foo", props.getProperty("value"));
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public class DelegatingItemReaderTests extends TestCase {
|
||||
return PropertiesConverter.stringToProperties("a=b");
|
||||
}
|
||||
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("value=foo"));
|
||||
}
|
||||
|
||||
|
||||
@@ -72,31 +72,31 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getStreamContext(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getExecutionAttributes(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextEmpty() {
|
||||
ExecutionAttributes streamContext = manager.getStreamContext("foo");
|
||||
ExecutionAttributes streamContext = manager.getExecutionAttributes("foo");
|
||||
assertEquals(0, streamContext.entrySet().size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getStreamContext(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getExecutionAttributes(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextNotEmpty() {
|
||||
manager.register("foo", stream, null);
|
||||
ExecutionAttributes streamContext = manager.getStreamContext("foo");
|
||||
ExecutionAttributes streamContext = manager.getExecutionAttributes("foo");
|
||||
assertEquals(1, streamContext.entrySet().size());
|
||||
assertEquals("bar", streamContext.getString(ClassUtils.getQualifiedName(stream.getClass()) + ".foo"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getStreamContext(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getExecutionAttributes(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextNotEmptyAndRestore() {
|
||||
testGetStreamContextNotEmpty();
|
||||
ExecutionAttributes context = manager.getStreamContext("foo");
|
||||
ExecutionAttributes context = manager.getExecutionAttributes("foo");
|
||||
// Register again, now with the context that was created from the same
|
||||
// stream...
|
||||
manager.register("foo", stream, context);
|
||||
@@ -107,7 +107,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getStreamContext(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getExecutionAttributes(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextNotEmptyAndRestoreWithNoPrefix() {
|
||||
ExecutionAttributes context = new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
@@ -120,12 +120,12 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getStreamContext(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getExecutionAttributes(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextWithNoPrefix() {
|
||||
manager.setUseClassNameAsPrefix(false);
|
||||
manager.register("foo", stream, null);
|
||||
ExecutionAttributes context = manager.getStreamContext("foo");
|
||||
ExecutionAttributes context = manager.getExecutionAttributes("foo");
|
||||
assertEquals(1, context.entrySet().size());
|
||||
// The list should have the foo= map value from the sub-context
|
||||
assertEquals("bar", context.getString("foo"));
|
||||
@@ -133,20 +133,20 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getStreamContext(java.lang.Object)}.
|
||||
* {@link org.springframework.batch.item.stream.SimpleStreamManager#getExecutionAttributes(java.lang.Object)}.
|
||||
*/
|
||||
public void testGetStreamContextTwoRegistrations() {
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
}
|
||||
}, null);
|
||||
manager.register("foo", new ItemStreamAdapter() {
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=spam"));
|
||||
}
|
||||
}, null);
|
||||
ExecutionAttributes streamContext = manager.getStreamContext("foo");
|
||||
ExecutionAttributes streamContext = manager.getExecutionAttributes("foo");
|
||||
assertEquals(2, streamContext.entrySet().size());
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public class SimpleStreamManagerTests extends TestCase {
|
||||
}
|
||||
|
||||
private final class ItemStreamAdapterExtension extends ItemStreamAdapter {
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("foo=bar"));
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public class ItemWriterItemProcessorTests extends TestCase {
|
||||
public void open() {
|
||||
}
|
||||
|
||||
public ExecutionAttributes getStreamContext() {
|
||||
public ExecutionAttributes getExecutionAttributes() {
|
||||
return new ExecutionAttributes(PropertiesConverter.stringToProperties("value=foo"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user