Merge branch 'work'
This commit is contained in:
@@ -31,6 +31,8 @@ import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageGroup;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -104,7 +106,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
headers.put("k2", new Integer(2));
|
||||
Message<?> message = correlatedMessage(1, 1, 1, headers);
|
||||
List<Message<?>> messages = Collections.<Message<?>>singletonList(message);
|
||||
MessageGroup group = new MessageGroup(messages, 1);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
@@ -119,7 +121,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
Message<?> message1 = correlatedMessage(1, 2, 1, headers);
|
||||
Message<?> message2 = correlatedMessage(1, 2, 2, headers);
|
||||
List<Message<?>> messages = Arrays.<Message<?>>asList(message1, message2);
|
||||
MessageGroup group = new MessageGroup(messages, 1);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
@@ -137,7 +139,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
headers2.put("k2", new Integer(123));
|
||||
Message<?> message2 = correlatedMessage(1, 2, 2, headers2);
|
||||
List<Message<?>> messages = Arrays.<Message<?>>asList(message1, message2);
|
||||
MessageGroup group = new MessageGroup(messages, 1);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
@@ -167,7 +169,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
headers3.put("conflictBetween2And3", "valueFor3");
|
||||
Message<?> message3 = correlatedMessage(1, 3, 3, headers3);
|
||||
List<Message<?>> messages = Arrays.<Message<?>>asList(message1, message2, message3);
|
||||
MessageGroup group = new MessageGroup(messages, 1);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
@@ -195,7 +197,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
headers3.put("common", "valueForAll");
|
||||
Message<?> message3 = correlatedMessage(1, 3, 3, headers3);
|
||||
List<Message<?>> messages = Arrays.<Message<?>>asList(message1, message2, message3);
|
||||
MessageGroup group = new MessageGroup(messages, 1);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ 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.store.MessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,12 +25,12 @@ import org.junit.Test;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.store.MessageStore;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
|
||||
public class CorrelatingMessageHandlerIntegrationTest {
|
||||
|
||||
private MessageStore store = new SimpleMessageStore(100);
|
||||
private MessageGroupStore store = new SimpleMessageStore(100);
|
||||
|
||||
private MessageChannel outputChannel = mock(MessageChannel.class);
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.store.SimpleMessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@@ -68,7 +69,7 @@ public class CorrelatingMessageHandlerTests {
|
||||
handler = new CorrelatingMessageHandler(processor, new SimpleMessageStore(), correlationStrategy,
|
||||
ReleaseStrategy);
|
||||
handler.setOutputChannel(outputChannel);
|
||||
doAnswer(new DoesNothing()).when(processor).processAndSend(isA(MessageGroup.class),
|
||||
doAnswer(new DoesNothing()).when(processor).processAndSend(isA(SimpleMessageGroup.class),
|
||||
isA(MessageChannelTemplate.class), eq(outputChannel));
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ public class CorrelatingMessageHandlerTests {
|
||||
|
||||
verify(correlationStrategy).getCorrelationKey(message1);
|
||||
verify(correlationStrategy).getCorrelationKey(message2);
|
||||
verify(processor).processAndSend(isA(MessageGroup.class), isA(MessageChannelTemplate.class), eq(outputChannel));
|
||||
verify(processor).processAndSend(isA(SimpleMessageGroup.class), isA(MessageChannelTemplate.class), eq(outputChannel));
|
||||
}
|
||||
|
||||
private void verifyLocks(CorrelatingMessageHandler handler, int lockCount) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MethodInvokingMessageGroupProcessorTests {
|
||||
|
||||
@@ -25,6 +25,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageGroup;
|
||||
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
@@ -155,7 +157,7 @@ public class ReleaseStrategyAdapterTests {
|
||||
if (size > 2) {
|
||||
messages.add(new GenericMessage<String>("789"));
|
||||
}
|
||||
return new MessageGroup(messages, "ABC");
|
||||
return new SimpleMessageGroup(messages, "ABC");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.integration.aggregator;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -31,12 +30,13 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.store.MessageStore;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
* @author Alex Peters
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class ResequencerTests {
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ResequencerTests {
|
||||
|
||||
private Resequencer processor = new Resequencer();
|
||||
|
||||
private MessageStore store = new SimpleMessageStore();
|
||||
private MessageGroupStore store = new SimpleMessageStore();
|
||||
|
||||
@Before
|
||||
public void configureResequencer() {
|
||||
@@ -230,7 +230,7 @@ public class ResequencerTests {
|
||||
String correlationId = "ABC";
|
||||
Message<?> message1 = createMessage("123", correlationId, 1, 1, replyChannel);
|
||||
resequencer.handleMessage(message1);
|
||||
assertTrue(store.list(correlationId).isEmpty());
|
||||
assertEquals(0, store.getMessageGroup(correlationId).size());
|
||||
}
|
||||
|
||||
private static Message<?> createMessage(String payload, Object correlationId, int sequenceSize, int sequenceNumber,
|
||||
|
||||
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageGroup;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -32,7 +34,7 @@ public class SequenceSizeReleaseStrategyTests {
|
||||
public void testIncompleteList() {
|
||||
Message<String> message = MessageBuilder.withPayload("test1")
|
||||
.setSequenceSize(2).build();
|
||||
MessageGroup messages = new MessageGroup("FOO");
|
||||
MessageGroup messages = new SimpleMessageGroup("FOO");
|
||||
messages.add(message);
|
||||
SequenceSizeReleaseStrategy ReleaseStrategy = new SequenceSizeReleaseStrategy();
|
||||
assertFalse(ReleaseStrategy.canRelease(messages));
|
||||
@@ -44,7 +46,7 @@ public class SequenceSizeReleaseStrategyTests {
|
||||
.setSequenceSize(2).build();
|
||||
Message<String> message2 = MessageBuilder.withPayload("test2")
|
||||
.setSequenceSize(2).build();
|
||||
MessageGroup messages = new MessageGroup("FOO");
|
||||
MessageGroup messages = new SimpleMessageGroup("FOO");
|
||||
messages.add(message1);
|
||||
messages.add(message2);
|
||||
SequenceSizeReleaseStrategy ReleaseStrategy = new SequenceSizeReleaseStrategy();
|
||||
@@ -54,7 +56,7 @@ public class SequenceSizeReleaseStrategyTests {
|
||||
@Test
|
||||
public void testEmptyList() {
|
||||
SequenceSizeReleaseStrategy ReleaseStrategy = new SequenceSizeReleaseStrategy();
|
||||
assertTrue(ReleaseStrategy.canRelease(new MessageGroup("FOO")));
|
||||
assertTrue(ReleaseStrategy.canRelease(new SimpleMessageGroup("FOO")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.aggregator.MessageGroup;
|
||||
import org.springframework.integration.aggregator.ReleaseStrategy;
|
||||
import org.springframework.integration.aggregator.CorrelationStrategy;
|
||||
import org.springframework.integration.annotation.Aggregator;
|
||||
@@ -29,6 +28,7 @@ import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.integration.config;
|
||||
|
||||
|
||||
import org.springframework.integration.aggregator.MessageGroup;
|
||||
import org.springframework.integration.aggregator.ReleaseStrategy;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.springframework.integration.aggregator;
|
||||
package org.springframework.integration.store;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
@@ -9,13 +9,14 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.store.SimpleMessageGroup;
|
||||
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class MessageGroupTests {
|
||||
public class SimpleMessageGroupTests {
|
||||
|
||||
private Object key = new Object();
|
||||
|
||||
@@ -23,7 +24,7 @@ public class MessageGroupTests {
|
||||
|
||||
@Before
|
||||
public void buildMessageGroup() {
|
||||
group = new MessageGroup(Collections.<Message<?>> emptyList(), key);
|
||||
group = new SimpleMessageGroup(Collections.<Message<?>> emptyList(), key);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -18,6 +18,7 @@ package org.springframework.integration.store;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -36,8 +37,8 @@ public class SimpleMessageStoreTests {
|
||||
public void shouldRetainMessage() {
|
||||
SimpleMessageStore store = new SimpleMessageStore();
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("foo").build();
|
||||
store.put(testMessage1);
|
||||
assertThat((Message<String>) store.get(testMessage1.getHeaders().getId()), is(testMessage1));
|
||||
store.addMessage(testMessage1);
|
||||
assertThat((Message<String>) store.getMessage(testMessage1.getHeaders().getId()), is(testMessage1));
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
@@ -45,8 +46,8 @@ public class SimpleMessageStoreTests {
|
||||
SimpleMessageStore store = new SimpleMessageStore(1);
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("foo").build();
|
||||
Message<String> testMessage2 = MessageBuilder.withPayload("bar").build();
|
||||
store.put(testMessage1);
|
||||
store.put(testMessage2);
|
||||
store.addMessage(testMessage1);
|
||||
store.addMessage(testMessage2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,16 +55,24 @@ public class SimpleMessageStoreTests {
|
||||
SimpleMessageStore store = new SimpleMessageStore(2);
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("foo").build();
|
||||
Message<String> testMessage2 = MessageBuilder.withPayload("bar").build();
|
||||
store.put(testMessage1);
|
||||
store.put(testMessage2);
|
||||
store.addMessage(testMessage1);
|
||||
store.addMessage(testMessage2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldListByCorrelation() throws Exception {
|
||||
SimpleMessageStore store = new SimpleMessageStore();
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("foo").build();
|
||||
store.put("bar", testMessage1);
|
||||
assertEquals(1, store.list("bar").size());
|
||||
store.addMessageToGroup("bar", testMessage1);
|
||||
assertEquals(1, store.getMessageGroup("bar").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCopyMessageGroup() throws Exception {
|
||||
SimpleMessageStore store = new SimpleMessageStore();
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("foo").build();
|
||||
store.addMessageToGroup("bar", testMessage1);
|
||||
assertNotSame(store.getMessageGroup("bar"), store.getMessageGroup("bar"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ClaimCheckTransformerTests {
|
||||
MessageStore store = new SimpleMessageStore(10);
|
||||
Message<?> message = MessageBuilder.withPayload("test").build();
|
||||
UUID storedId = message.getHeaders().getId();
|
||||
store.put(message);
|
||||
store.addMessage(message);
|
||||
ClaimCheckTransformer transformer = new ClaimCheckTransformer(store);
|
||||
Message<?> input = MessageBuilder.withPayload(storedId).build();
|
||||
Message<?> output = transformer.transform(input);
|
||||
|
||||
Reference in New Issue
Block a user