use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.
the class JdbcMessageStoreParserTests method testSimpleMessageStoreWithDataSource.
@Test
public void testSimpleMessageStoreWithDataSource() {
setUp("defaultJdbcMessageStore.xml", getClass());
MessageStore store = context.getBean("messageStore", MessageStore.class);
assertTrue(store instanceof JdbcMessageStore);
}
use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.
the class AbstractMongoDbMessageGroupStoreTests method testRemoveMessageGroup.
@Test
@MongoDbAvailable
public void testRemoveMessageGroup() throws Exception {
this.cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
MessageGroupStore store = this.getMessageGroupStore();
MessageStore messageStore = this.getMessageStore();
MessageGroup messageGroup = store.getMessageGroup(1);
Message<?> message = new GenericMessage<String>("Hello");
UUID id = message.getHeaders().getId();
messageGroup = store.addMessageToGroup(1, message);
assertNotNull(messageGroup);
assertEquals(1, messageGroup.size());
message = messageStore.getMessage(id);
assertNotNull(message);
store.removeMessageGroup(1);
MessageGroup messageGroupA = store.getMessageGroup(1);
assertEquals(0, messageGroupA.size());
assertFalse(messageGroupA.equals(messageGroup));
}
use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.
the class AbstractMongoDbMessageGroupStoreTests method testMessageGroupWithAddedMessagePrimitiveGroupId.
@Test
@MongoDbAvailable
public void testMessageGroupWithAddedMessagePrimitiveGroupId() throws Exception {
this.cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
MessageGroupStore store = this.getMessageGroupStore();
MessageStore messageStore = this.getMessageStore();
MessageGroup messageGroup = store.getMessageGroup(1);
Message<?> messageA = new GenericMessage<String>("A");
Message<?> messageB = new GenericMessage<String>("B");
store.addMessagesToGroup(1, messageA);
messageGroup = store.addMessageToGroup(1, messageB);
assertNotNull(messageGroup);
assertEquals(2, messageGroup.size());
Message<?> retrievedMessage = messageStore.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"));
}
use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.
the class AbstractMongoDbMessageStoreTests method testAddGetWithObjectDefaultConstructorPayload.
@Test
@MongoDbAvailable
public void testAddGetWithObjectDefaultConstructorPayload() throws Exception {
cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
MessageStore store = getMessageStore();
Person p = new Person();
p.setFname("John");
p.setLname("Doe");
Message<?> messageToStore = MessageBuilder.withPayload(p).build();
store.addMessage(messageToStore);
Message<?> retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
assertNotNull(retrievedMessage);
assertEquals(messageToStore.getPayload(), retrievedMessage.getPayload());
assertEquals(messageToStore.getHeaders(), retrievedMessage.getHeaders());
assertEquals(messageToStore, retrievedMessage);
}
use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.
the class AbstractMongoDbMessageStoreTests method testWithMessageHistory.
@Test
@MongoDbAvailable
public void testWithMessageHistory() throws Exception {
cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
MessageStore store = getMessageStore();
Foo foo = new Foo();
foo.setName("foo");
Message<?> message = MessageBuilder.withPayload(foo).setHeader("foo", foo).setHeader("bar", new Bar("bar")).setHeader("baz", new Baz()).setHeader("abc", new Abc()).setHeader("xyz", new Xyz()).build();
DirectChannel fooChannel = new DirectChannel();
fooChannel.setBeanName("fooChannel");
DirectChannel barChannel = new DirectChannel();
barChannel.setBeanName("barChannel");
message = MessageHistory.write(message, fooChannel);
message = MessageHistory.write(message, barChannel);
store.addMessage(message);
message = store.getMessage(message.getHeaders().getId());
assertNotNull(message);
assertTrue(message.getHeaders().get("foo") instanceof Foo);
assertTrue(message.getHeaders().get("bar") instanceof Bar);
assertTrue(message.getHeaders().get("baz") instanceof Baz);
assertTrue(message.getHeaders().get("abc") instanceof Abc);
assertTrue(message.getHeaders().get("xyz") instanceof Xyz);
MessageHistory messageHistory = MessageHistory.read(message);
assertNotNull(messageHistory);
assertEquals(2, messageHistory.size());
Properties fooChannelHistory = messageHistory.get(0);
assertEquals("fooChannel", fooChannelHistory.get("name"));
assertEquals("channel", fooChannelHistory.get("type"));
}
Aggregations