OPEN - issue INT-1063: MessageStore: correlation and grouping API
Here is something that works, but there is more work to do in simplifying the CorrelatingMessageHandler and friends
This commit is contained in:
@@ -108,8 +108,8 @@ public class CorrelatingMessageHandlerTests {
|
||||
handler.handleMessage(message2);
|
||||
storedMessages.add(message2);
|
||||
|
||||
verify(store).put(message1);
|
||||
verify(store).put(message2);
|
||||
verify(store).put(correlationKey, message1);
|
||||
verify(store).put(correlationKey, message2);
|
||||
verify(store, times(2)).list(correlationKey);
|
||||
verify(correlationStrategy).getCorrelationKey(message1);
|
||||
verify(correlationStrategy).getCorrelationKey(message2);
|
||||
@@ -164,10 +164,9 @@ public class CorrelatingMessageHandlerTests {
|
||||
assertFalse(handler.forceComplete("key"));
|
||||
|
||||
bothMessagesHandled.await();
|
||||
verify(store).put(message1);
|
||||
verify(store).put(message2);
|
||||
verify(store).delete(id1);
|
||||
verify(store).delete(id2);
|
||||
verify(store).put(correlationKey, message1);
|
||||
verify(store).put(correlationKey, message2);
|
||||
verify(store).deleteAll(correlationKey);
|
||||
}
|
||||
|
||||
private Message<?> testMessage(String correlationKey, int sequenceNumber) {
|
||||
|
||||
@@ -120,6 +120,7 @@ public class NewResequencerTests {
|
||||
assertEquals(new Integer(1), reply1.getHeaders().getSequenceNumber());
|
||||
assertNotNull(reply2);
|
||||
assertEquals(new Integer(2), reply2.getHeaders().getSequenceNumber());
|
||||
System.err.println(reply3);
|
||||
assertNull(reply3);
|
||||
// when sending the last message, the whole sequence must have been sent
|
||||
this.resequencer.handleMessage(message4);
|
||||
|
||||
@@ -16,20 +16,25 @@
|
||||
|
||||
package org.springframework.integration.store;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class SimpleMessageStoreTest {
|
||||
public class SimpleMessageStoreTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void shouldRetainMessage() {
|
||||
SimpleMessageStore store = new SimpleMessageStore();
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("foo").build();
|
||||
@@ -54,4 +59,22 @@ public class SimpleMessageStoreTest {
|
||||
store.put(testMessage1);
|
||||
store.put(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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldListByCorrelationAfterAddAll() throws Exception {
|
||||
SimpleMessageStore store = new SimpleMessageStore();
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("foo").build();
|
||||
Message<String> testMessage2 = MessageBuilder.withPayload("bar").build();
|
||||
store.put("bar", Arrays.<Message<?>>asList(testMessage1, testMessage2));
|
||||
assertEquals(2, store.list("bar").size());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user