use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testMessageGroupWithAddedMessage.
@Test
@RedisAvailable
public void testMessageGroupWithAddedMessage() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<?> message = new GenericMessage<>("Hello");
MessageGroup messageGroup = store.addMessageToGroup(this.groupId, message);
assertEquals(1, messageGroup.size());
// make sure the store is properly rebuild from Redis
store = new RedisMessageStore(jcf);
messageGroup = store.getMessageGroup(this.groupId);
assertEquals(1, messageGroup.size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testRemoveMessageFromTheGroup.
@Test
@RedisAvailable
public void testRemoveMessageFromTheGroup() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(this.groupId);
Message<?> message = new GenericMessage<>("2");
store.addMessagesToGroup(messageGroup.getGroupId(), new GenericMessage<>("1"), message);
messageGroup = store.addMessageToGroup(messageGroup.getGroupId(), new GenericMessage<>("3"));
assertEquals(3, messageGroup.size());
store.removeMessagesFromGroup(this.groupId, message);
messageGroup = store.getMessageGroup(this.groupId);
assertEquals(2, messageGroup.size());
// make sure the store is properly rebuild from Redis
store = new RedisMessageStore(jcf);
messageGroup = store.getMessageGroup(this.groupId);
assertEquals(2, messageGroup.size());
}
use of org.springframework.integration.store.MessageGroup in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testIteratorOfMessageGroups.
@Test
@RedisAvailable
public void testIteratorOfMessageGroups() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store1 = new RedisMessageStore(jcf);
RedisMessageStore store2 = new RedisMessageStore(jcf);
store1.removeMessageGroup(this.groupId);
UUID group2 = UUID.randomUUID();
store1.removeMessageGroup(group2);
UUID group3 = UUID.randomUUID();
store1.removeMessageGroup(group3);
store1.addMessagesToGroup(this.groupId, new GenericMessage<>("1"));
store2.addMessagesToGroup(group2, new GenericMessage<>("2"));
store1.addMessagesToGroup(group3, new GenericMessage<>("3"), new GenericMessage<>("3A"));
Iterator<MessageGroup> messageGroups = store1.iterator();
int counter = 0;
while (messageGroups.hasNext()) {
MessageGroup group = messageGroups.next();
String groupId = (String) group.getGroupId();
if (groupId.equals("1")) {
assertEquals(1, group.getMessages().size());
} else if (groupId.equals("2")) {
assertEquals(1, group.getMessages().size());
} else if (groupId.equals("3")) {
assertEquals(2, group.getMessages().size());
}
counter++;
}
assertEquals(3, counter);
store2.removeMessageGroup(group3);
messageGroups = store1.iterator();
counter = 0;
while (messageGroups.hasNext()) {
messageGroups.next();
counter++;
}
assertEquals(2, counter);
}
Aggregations