@Test @MongoDbAvailable public void testMessageGroupWithAddedMessage() throws Exception { MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); MongoDbMessageStore store = new MongoDbMessageStore(mongoDbFactory); MessageGroup messageGroup = store.getMessageGroup(1); Message<?> messageA = new GenericMessage<String>("A"); Message<?> messageB = new GenericMessage<String>("B"); store.addMessageToGroup(1, messageA); messageGroup = store.addMessageToGroup(1, messageB); assertEquals(2, messageGroup.size()); Message<?> retrievedMessage = store.getMessage(messageA.getHeaders().getId()); assertNotNull(retrievedMessage); assertEquals(retrievedMessage.getHeaders().getId(), messageA.getHeaders().getId()); // ensure that 'message_group' header that is only used internally is not propagated assertNull(retrievedMessage.getHeaders().get("message_group")); }
@Test @MongoDbAvailable public void testRemoveMessageGroup() throws Exception { MongoDbFactory mongoDbFactory = this.prepareMongoFactory(); MongoDbMessageStore store = new MongoDbMessageStore(mongoDbFactory); MessageGroup messageGroup = store.getMessageGroup(1); Message<?> message = new GenericMessage<String>("Hello"); UUID id = message.getHeaders().getId(); messageGroup = store.addMessageToGroup(1, message); assertEquals(1, messageGroup.size()); message = store.getMessage(id); assertNotNull(message); store.removeMessageGroup(1); MessageGroup messageGroupA = store.getMessageGroup(1); assertEquals(0, messageGroupA.size()); assertFalse(messageGroupA.equals(messageGroup)); }