INT-330: BufferingMessageHandler -> CorrelatingMessageHandler and MessagesProcessor -> MessageGroupProcessor
This commit is contained in:
@@ -15,11 +15,11 @@ public class BufferingMessageHandlerIntegrationTest {
|
||||
private CorrelationStrategy correlationStrategy;
|
||||
private MessageStore store = new SimpleMessageStore(100);
|
||||
private MessageChannel outputChannel = mock(MessageChannel.class);
|
||||
private MessagesProcessor processor = new PassThroughMessagesProcessor();
|
||||
// private BufferingMessageHandler customizedHandler = new BufferingMessageHandler(
|
||||
private MessageGroupProcessor processor = new PassThroughMessageGroupProcessor();
|
||||
// private CorrelatingMessageHandler customizedHandler = new CorrelatingMessageHandler(
|
||||
// store, correlationStrategy, completionStrategy, processor,
|
||||
// outputChannel);
|
||||
private BufferingMessageHandler defaultHandler = new BufferingMessageHandler(
|
||||
private CorrelatingMessageHandler defaultHandler = new CorrelatingMessageHandler(
|
||||
store, processor);
|
||||
|
||||
@Before public void setupHandler(){
|
||||
|
||||
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.*;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class BufferingMessageHandlerTest {
|
||||
|
||||
private BufferingMessageHandler buffer;
|
||||
private CorrelatingMessageHandler buffer;
|
||||
@Mock
|
||||
private MessageStore store;
|
||||
@Mock
|
||||
@@ -45,13 +45,13 @@ public class BufferingMessageHandlerTest {
|
||||
@Mock
|
||||
private CompletionStrategy completionStrategy;
|
||||
@Mock
|
||||
private MessagesProcessor processor;
|
||||
private MessageGroupProcessor processor;
|
||||
@Mock
|
||||
private MessageChannel outputChannel;
|
||||
|
||||
@Before
|
||||
public void initializeSubject() {
|
||||
buffer = new BufferingMessageHandler(store, correlationStrategy,
|
||||
buffer = new CorrelatingMessageHandler(store, correlationStrategy,
|
||||
completionStrategy, processor);
|
||||
buffer.setOutputChannel(outputChannel);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MethodInvokingMessagesProcessorTests {
|
||||
public class MethodInvokingMessageGroupProcessorTests {
|
||||
|
||||
@Mock
|
||||
private BufferedMessagesCallback processedCallback;
|
||||
@@ -61,7 +61,7 @@ public class MethodInvokingMessagesProcessorTests {
|
||||
|
||||
@Test
|
||||
public void shouldFindAnnotatedAggregatorMethod() throws Exception {
|
||||
MessagesProcessor processor = new MethodInvokingMessagesProcessor(
|
||||
MessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(
|
||||
new AnnotatedAggregatorMethod());
|
||||
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor
|
||||
.forClass(Message.class);
|
||||
@@ -86,7 +86,7 @@ public class MethodInvokingMessagesProcessorTests {
|
||||
|
||||
@Test
|
||||
public void shouldFindSimpleAggregatorMethod() throws Exception {
|
||||
MessagesProcessor processor = new MethodInvokingMessagesProcessor(
|
||||
MessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(
|
||||
new SimpleAggregator());
|
||||
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor
|
||||
.forClass(Message.class);
|
||||
@@ -119,7 +119,7 @@ public class MethodInvokingMessagesProcessorTests {
|
||||
|
||||
@Test
|
||||
public void shouldFindFittingMethodAmongMultipleUnanotated() {
|
||||
MessagesProcessor processor = new MethodInvokingMessagesProcessor(
|
||||
MessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(
|
||||
new UnnanotatedAggregator()
|
||||
);
|
||||
|
||||
@@ -150,7 +150,7 @@ public class MethodInvokingMessagesProcessorTests {
|
||||
|
||||
@Test
|
||||
public void shouldFindFittingMethodAmongMultipleWithAnnotatedParameters() {
|
||||
MessagesProcessor processor = new MethodInvokingMessagesProcessor(
|
||||
MessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(
|
||||
new AnnotatedParametersAggregator()
|
||||
);
|
||||
|
||||
@@ -16,36 +16,25 @@
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
import org.springframework.integration.aggregator.BufferingMessageHandler;
|
||||
import org.springframework.integration.aggregator.MessagesProcessor;
|
||||
import org.springframework.integration.aggregator.CorrelatingMessageHandler;
|
||||
import org.springframework.integration.aggregator.MessageGroupProcessor;
|
||||
import org.springframework.integration.aggregator.BufferedMessagesCallback;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.integration.config.StubTaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.test.annotation.Repeat;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -54,11 +43,11 @@ import java.util.concurrent.ScheduledFuture;
|
||||
*/
|
||||
public class NewAggregatorEndpointTests {
|
||||
|
||||
private BufferingMessageHandler aggregator;
|
||||
private CorrelatingMessageHandler aggregator;
|
||||
|
||||
@Before
|
||||
public void configureAggregator() {
|
||||
this.aggregator = new BufferingMessageHandler(new SimpleMessageStore(50), new MultiplyingProcessor());
|
||||
this.aggregator = new CorrelatingMessageHandler(new SimpleMessageStore(50), new MultiplyingProcessor());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -236,7 +225,7 @@ public class NewAggregatorEndpointTests {
|
||||
|
||||
@Test
|
||||
public void testNullReturningAggregator() throws InterruptedException {
|
||||
this.aggregator = new BufferingMessageHandler(new SimpleMessageStore(50), new NullReturningMessageProcessor());
|
||||
this.aggregator = new CorrelatingMessageHandler(new SimpleMessageStore(50), new NullReturningMessageProcessor());
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
Message<?> message1 = createMessage(3, "ABC", 3, 1, replyChannel, null);
|
||||
Message<?> message2 = createMessage(5, "ABC", 3, 2, replyChannel, null);
|
||||
@@ -262,7 +251,7 @@ public class NewAggregatorEndpointTests {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private class MultiplyingProcessor implements MessagesProcessor {
|
||||
private class MultiplyingProcessor implements MessageGroupProcessor {
|
||||
public void processAndSend(Object correlationKey, Collection<Message<?>> messagesUpForProcessing,
|
||||
MessageChannel outputChannel, BufferedMessagesCallback processedCallback
|
||||
) {
|
||||
@@ -279,7 +268,7 @@ public class NewAggregatorEndpointTests {
|
||||
}
|
||||
}
|
||||
|
||||
private class NullReturningMessageProcessor implements MessagesProcessor {
|
||||
private class NullReturningMessageProcessor implements MessageGroupProcessor {
|
||||
public void processAndSend(Object correlationKey, Collection<Message<?>> messagesUpForProcessing, MessageChannel outputChannel, BufferedMessagesCallback processedCallback) {
|
||||
//noop
|
||||
}
|
||||
|
||||
@@ -31,12 +31,11 @@ import org.springframework.integration.core.MessageHeaders;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
import org.springframework.integration.aggregator.BufferingMessageHandler;
|
||||
import org.springframework.integration.aggregator.MessagesProcessor;
|
||||
import org.springframework.integration.aggregator.CorrelatingMessageHandler;
|
||||
import org.springframework.integration.aggregator.MessageGroupProcessor;
|
||||
import org.springframework.integration.aggregator.BufferedMessagesCallback;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.test.annotation.Repeat;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -53,7 +52,7 @@ public class NewConcurrentAggregatorEndpointTests {
|
||||
|
||||
private ThreadPoolTaskScheduler taskScheduler;
|
||||
|
||||
private BufferingMessageHandler aggregator;
|
||||
private CorrelatingMessageHandler aggregator;
|
||||
|
||||
@Before
|
||||
public void configureAggregator() {
|
||||
@@ -61,7 +60,7 @@ public class NewConcurrentAggregatorEndpointTests {
|
||||
this.taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.afterPropertiesSet();
|
||||
this.taskScheduler.afterPropertiesSet();
|
||||
this.aggregator = new BufferingMessageHandler(new SimpleMessageStore(50), new MultiplyingProcessor());
|
||||
this.aggregator = new CorrelatingMessageHandler(new SimpleMessageStore(50), new MultiplyingProcessor());
|
||||
this.aggregator.setTaskScheduler(this.taskScheduler);
|
||||
}
|
||||
|
||||
@@ -243,7 +242,7 @@ public class NewConcurrentAggregatorEndpointTests {
|
||||
@Test
|
||||
public void testNullReturningAggregator() throws InterruptedException {
|
||||
this.aggregator.start();
|
||||
this.aggregator = new BufferingMessageHandler(new SimpleMessageStore(50), new NullReturningMessageProcessor());
|
||||
this.aggregator = new CorrelatingMessageHandler(new SimpleMessageStore(50), new NullReturningMessageProcessor());
|
||||
this.aggregator.setTaskScheduler(this.taskScheduler);
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
Message<?> message1 = createMessage(3, "ABC", 3, 1, replyChannel, null);
|
||||
@@ -320,7 +319,7 @@ public class NewConcurrentAggregatorEndpointTests {
|
||||
if (this.aggregator != null) this.aggregator.stop();
|
||||
}
|
||||
|
||||
private class MultiplyingProcessor implements MessagesProcessor {
|
||||
private class MultiplyingProcessor implements MessageGroupProcessor {
|
||||
public void processAndSend(Object correlationKey, Collection<Message<?>> messagesUpForProcessing,
|
||||
MessageChannel outputChannel, BufferedMessagesCallback processedCallback
|
||||
) {
|
||||
@@ -337,7 +336,7 @@ public class NewConcurrentAggregatorEndpointTests {
|
||||
}
|
||||
}
|
||||
|
||||
private class NullReturningMessageProcessor implements MessagesProcessor {
|
||||
private class NullReturningMessageProcessor implements MessageGroupProcessor {
|
||||
public void processAndSend(Object correlationKey, Collection<Message<?>> messagesUpForProcessing, MessageChannel outputChannel, BufferedMessagesCallback processedCallback) {
|
||||
//noop
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import static org.hamcrest.CoreMatchers.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.matchers.JUnitMatchers;
|
||||
|
||||
import static org.junit.matchers.JUnitMatchers.*;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
@@ -33,7 +33,6 @@ import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
import java.util.Arrays;
|
||||
import static java.util.Arrays.*;
|
||||
|
||||
/**
|
||||
@@ -43,7 +42,7 @@ import static java.util.Arrays.*;
|
||||
*/
|
||||
public class NewResequencerTests {
|
||||
|
||||
private BufferingMessageHandler resequencer;
|
||||
private CorrelatingMessageHandler resequencer;
|
||||
|
||||
private ThreadPoolTaskScheduler taskScheduler;
|
||||
|
||||
@@ -53,7 +52,7 @@ public class NewResequencerTests {
|
||||
public void configureResequencer() {
|
||||
this.resequencerStrategies = new DefaultResequencerStrategies();
|
||||
MessageStore store = new SimpleMessageStore(30);
|
||||
this.resequencer = new BufferingMessageHandler(store, resequencerStrategies, resequencerStrategies, resequencerStrategies);
|
||||
this.resequencer = new CorrelatingMessageHandler(store, resequencerStrategies, resequencerStrategies, resequencerStrategies);
|
||||
this.taskScheduler = TestUtils.createTaskScheduler(10);
|
||||
this.resequencer.setTaskScheduler(taskScheduler);
|
||||
this.taskScheduler.afterPropertiesSet();
|
||||
|
||||
Reference in New Issue
Block a user