XD-1389: Added null check when receiving partitioned messages back to handle timeouts

This commit is contained in:
Michael Minella
2014-05-01 09:48:02 -05:00
parent 5600061b92
commit f6b83167ac
2 changed files with 38 additions and 13 deletions

View File

@@ -1,24 +1,26 @@
package org.springframework.batch.integration.partition;
import org.junit.Test;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.partition.StepExecutionSplitter;
import org.springframework.integration.MessageTimeoutException;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
import java.util.Collection;
import java.util.Collections;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.Collection;
import java.util.Collections;
import org.junit.Test;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.partition.StepExecutionSplitter;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
/**
*
* @author Will Schipp
* @author Michael Minella
*
*/
public class MessageChannelPartitionHandlerTest {
@@ -72,4 +74,21 @@ public class MessageChannelPartitionHandlerTest {
}
@Test(expected = MessageTimeoutException.class)
public void messageReceiveTimeout() throws Exception {
//execute with no default set
messageChannelPartitionHandler = new MessageChannelPartitionHandler();
//mock
StepExecution masterStepExecution = mock(StepExecution.class);
StepExecutionSplitter stepExecutionSplitter = mock(StepExecutionSplitter.class);
MessagingTemplate operations = mock(MessagingTemplate.class);
Message message = mock(Message.class);
//when
when(message.getPayload()).thenReturn(Collections.emptyList());
//set
messageChannelPartitionHandler.setMessagingOperations(operations);
//execute
Collection<StepExecution> executions = messageChannelPartitionHandler.handle(stepExecutionSplitter, masterStepExecution);
}
}