BATCH-1943: Added ChunkContext to all ChunkListener calls
This commit is contained in:
@@ -33,9 +33,11 @@ public class CompositeChunkListenerTests {
|
||||
|
||||
ChunkListener listener;
|
||||
CompositeChunkListener compositeListener;
|
||||
ChunkContext chunkContext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
chunkContext = new ChunkContext(null);
|
||||
listener = createMock(ChunkListener.class);
|
||||
compositeListener = new CompositeChunkListener();
|
||||
compositeListener.register(listener);
|
||||
@@ -43,19 +45,18 @@ public class CompositeChunkListenerTests {
|
||||
|
||||
@Test
|
||||
public void testBeforeChunk(){
|
||||
|
||||
listener.beforeChunk();
|
||||
listener.beforeChunk(chunkContext);
|
||||
replay(listener);
|
||||
compositeListener.beforeChunk();
|
||||
compositeListener.beforeChunk(chunkContext);
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterChunk(){
|
||||
|
||||
listener.afterChunk();
|
||||
listener.afterChunk(chunkContext);
|
||||
replay(listener);
|
||||
compositeListener.afterChunk();
|
||||
compositeListener.afterChunk(chunkContext);
|
||||
verify(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -128,25 +129,25 @@ public class MulticasterBatchListenerTests {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.listener.MulticasterBatchListener#afterChunk()}
|
||||
* {@link org.springframework.batch.core.listener.MulticasterBatchListener#afterChunk(ChunkContext context)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAfterChunk() {
|
||||
multicast.afterChunk();
|
||||
multicast.afterChunk(null);
|
||||
assertEquals(1, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.listener.MulticasterBatchListener#afterChunk()}
|
||||
* {@link org.springframework.batch.core.listener.MulticasterBatchListener#afterChunk(ChunkContext context)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAfterChunkFails() {
|
||||
error = true;
|
||||
try {
|
||||
multicast.afterChunk();
|
||||
multicast.afterChunk(null);
|
||||
fail("Expected StepListenerFailedException");
|
||||
}
|
||||
catch (StepListenerFailedException e) {
|
||||
@@ -159,25 +160,25 @@ public class MulticasterBatchListenerTests {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.listener.MulticasterBatchListener#beforeChunk()}
|
||||
* {@link org.springframework.batch.core.listener.MulticasterBatchListener#beforeChunk(ChunkContext context)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testBeforeChunk() {
|
||||
multicast.beforeChunk();
|
||||
multicast.beforeChunk(null);
|
||||
assertEquals(1, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.listener.MulticasterBatchListener#beforeChunk()}
|
||||
* {@link org.springframework.batch.core.listener.MulticasterBatchListener#beforeChunk(ChunkContext context)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testBeforeChunkFails() {
|
||||
error = true;
|
||||
try {
|
||||
multicast.beforeChunk();
|
||||
multicast.beforeChunk(null);
|
||||
fail("Expected StepListenerFailedException");
|
||||
}
|
||||
catch (StepListenerFailedException e) {
|
||||
@@ -528,12 +529,12 @@ public class MulticasterBatchListenerTests {
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public void afterChunk() {
|
||||
public void afterChunk(ChunkContext context) {
|
||||
count++;
|
||||
if (error) {
|
||||
throw new RuntimeException("listener error");
|
||||
}
|
||||
super.afterChunk();
|
||||
super.afterChunk(context);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -576,12 +577,12 @@ public class MulticasterBatchListenerTests {
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public void beforeChunk() {
|
||||
public void beforeChunk(ChunkContext context) {
|
||||
count++;
|
||||
if (error) {
|
||||
throw new RuntimeException("listener error");
|
||||
}
|
||||
super.beforeChunk();
|
||||
super.beforeChunk(context);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -95,8 +95,8 @@ public class StepListenerFactoryBeanTests {
|
||||
StepListener listener = (StepListener) factoryBean.getObject();
|
||||
((StepExecutionListener) listener).beforeStep(stepExecution);
|
||||
((StepExecutionListener) listener).afterStep(stepExecution);
|
||||
((ChunkListener) listener).beforeChunk();
|
||||
((ChunkListener) listener).afterChunk();
|
||||
((ChunkListener) listener).beforeChunk(null);
|
||||
((ChunkListener) listener).afterChunk(null);
|
||||
((ChunkListener) listener).afterChunkError(new ChunkContext(null));
|
||||
((ItemReadListener<String>) listener).beforeRead();
|
||||
((ItemReadListener<String>) listener).afterRead(readItem);
|
||||
|
||||
@@ -598,14 +598,14 @@ public class FaultTolerantStepFactoryBeanRollbackTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeChunk() {
|
||||
public void beforeChunk(ChunkContext context) {
|
||||
if(phase == 1){
|
||||
throw new IllegalArgumentException("Planned exception");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterChunk() {
|
||||
public void afterChunk(ChunkContext context) {
|
||||
if(phase == 2) {
|
||||
throw new IllegalArgumentException("Planned exception");
|
||||
}
|
||||
|
||||
@@ -785,12 +785,12 @@ public class FaultTolerantStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterChunk() {
|
||||
public void afterChunk(ChunkContext context) {
|
||||
listenerCalls.add(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeChunk() {
|
||||
public void beforeChunk(ChunkContext context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -256,13 +256,13 @@ public class SimpleStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterChunk() {
|
||||
public void afterChunk(ChunkContext context) {
|
||||
writeListener.trail = writeListener.trail + "4";
|
||||
afterCount++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeChunk() {
|
||||
public void beforeChunk(ChunkContext context) {
|
||||
writeListener.trail = writeListener.trail + "1";
|
||||
beforeCount++;
|
||||
}
|
||||
@@ -399,12 +399,12 @@ public class SimpleStepFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterChunk() {
|
||||
public void afterChunk(ChunkContext context) {
|
||||
listenerCalls.add("chunk");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeChunk() {
|
||||
public void beforeChunk(ChunkContext context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user