Use MessagingGateway for chunk writer
This commit is contained in:
@@ -34,6 +34,7 @@ import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.gateway.SimpleMessagingGateway;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -72,9 +73,13 @@ public class ChunkMessageItemWriterIntegrationTests {
|
||||
factory.setBeanName("step");
|
||||
factory.setItemWriter(writer);
|
||||
factory.setCommitInterval(4);
|
||||
|
||||
SimpleMessagingGateway gateway = new SimpleMessagingGateway();
|
||||
writer.setMessagingGateway(gateway);
|
||||
|
||||
writer.setInputChannel(replies);
|
||||
writer.setOutputChannel(requests);
|
||||
gateway.setRequestChannel(requests);
|
||||
gateway.setReplyChannel(replies);
|
||||
gateway.setReplyTimeout(100);
|
||||
|
||||
TestItemWriter.count = 0;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.springframework.batch.integration.chunk;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
public class ChunkProcessorChunkHandlerTests {
|
||||
@@ -14,7 +14,6 @@ public class ChunkProcessorChunkHandlerTests {
|
||||
|
||||
protected int count = 0;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testVanillaHandleChunk() {
|
||||
handler.setChunkProcessor(new ChunkProcessor<Object>() {
|
||||
@@ -23,11 +22,11 @@ public class ChunkProcessorChunkHandlerTests {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
ChunkResponse response = handler.handleChunk(new ChunkRequest(StringUtils.commaDelimitedListToSet("foo,bar"),
|
||||
ChunkResponse response = handler.handleChunk(new ChunkRequest<Object>(StringUtils.commaDelimitedListToSet("foo,bar"),
|
||||
12L, 10));
|
||||
assertEquals(0, response.getSkipCount());
|
||||
assertEquals(new Long(12L), response.getJobId());
|
||||
assertEquals(BatchStatus.COMPLETED, response.getStatus());
|
||||
assertTrue(response.isSuccessful());
|
||||
assertEquals(2, count);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user