Search in sources :

Example 1 with MessageStore

use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.

the class ClaimCheckParserTests method checkMessageStoreReferenceOnCheckOut.

@Test
public void checkMessageStoreReferenceOnCheckOut() {
    ClaimCheckOutTransformer transformer = (ClaimCheckOutTransformer) new DirectFieldAccessor(new DirectFieldAccessor(checkout).getPropertyValue("handler")).getPropertyValue("transformer");
    MessageStore messageStore = (MessageStore) new DirectFieldAccessor(transformer).getPropertyValue("messageStore");
    assertEquals(context.getBean("testMessageStore"), messageStore);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) ClaimCheckOutTransformer(org.springframework.integration.transformer.ClaimCheckOutTransformer) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 2 with MessageStore

use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.

the class ClaimCheckTransformerTests method unknown.

@Test(expected = MessageTransformationException.class)
public void unknown() {
    MessageStore store = new SimpleMessageStore(10);
    ClaimCheckOutTransformer transformer = new ClaimCheckOutTransformer(store);
    transformer.transform(MessageBuilder.withPayload(UUID.randomUUID()).build());
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) SimpleMessageStore(org.springframework.integration.store.SimpleMessageStore) SimpleMessageStore(org.springframework.integration.store.SimpleMessageStore) Test(org.junit.Test)

Example 3 with MessageStore

use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.

the class AbstractMongoDbMessageGroupStoreTests method testMessageGroupWithAddedMessageUUIDGroupIdAndUUIDHeader.

@Test
@MongoDbAvailable
public void testMessageGroupWithAddedMessageUUIDGroupIdAndUUIDHeader() throws Exception {
    this.cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
    MessageGroupStore store = this.getMessageGroupStore();
    MessageStore messageStore = this.getMessageStore();
    Object id = UUID.randomUUID();
    MessageGroup messageGroup = store.getMessageGroup(id);
    UUID uuidA = UUID.randomUUID();
    Message<?> messageA = MessageBuilder.withPayload("A").setHeader("foo", uuidA).build();
    UUID uuidB = UUID.randomUUID();
    Message<?> messageB = MessageBuilder.withPayload("B").setHeader("foo", uuidB).build();
    store.addMessagesToGroup(id, messageA);
    messageGroup = store.addMessageToGroup(id, 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"));
    Object fooHeader = retrievedMessage.getHeaders().get("foo");
    assertTrue(fooHeader instanceof UUID);
    assertEquals(uuidA, fooHeader);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) MongoClient(com.mongodb.MongoClient) AbstractBatchingMessageGroupStore(org.springframework.integration.store.AbstractBatchingMessageGroupStore) MessageGroupStore(org.springframework.integration.store.MessageGroupStore) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MessageGroup(org.springframework.integration.store.MessageGroup) UUID(java.util.UUID) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 4 with MessageStore

use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.

the class JdbcMessageStoreParserTests method testSimpleMessageStoreWithSerializer.

@Test
public void testSimpleMessageStoreWithSerializer() {
    setUp("serializerJdbcMessageStore.xml", getClass());
    MessageStore store = context.getBean("messageStore", MessageStore.class);
    Object serializer = TestUtils.getPropertyValue(store, "serializer.serializer");
    assertTrue(serializer instanceof EnhancedSerializer);
    Object deserializer = TestUtils.getPropertyValue(store, "deserializer.deserializer");
    assertTrue(deserializer instanceof EnhancedSerializer);
}
Also used : JdbcMessageStore(org.springframework.integration.jdbc.store.JdbcMessageStore) MessageStore(org.springframework.integration.store.MessageStore) Test(org.junit.Test)

Example 5 with MessageStore

use of org.springframework.integration.store.MessageStore in project spring-integration by spring-projects.

the class AbstractMongoDbMessageStoreTests method testMutableMessageAsPayload.

@Test
@MongoDbAvailable
public void testMutableMessageAsPayload() throws Exception {
    MessageStore store = this.getMessageStore();
    Person p = new Person();
    p.setFname("John");
    p.setLname("Doe");
    Message<?> messageToStore = new GenericMessage<Message<?>>(MutableMessageBuilder.withPayload(p).build());
    store.addMessage(messageToStore);
    Message<?> retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
    assertNotNull(retrievedMessage);
    assertThat(retrievedMessage.getPayload(), instanceOf(MutableMessage.class));
    assertEquals(messageToStore.getPayload(), retrievedMessage.getPayload());
    assertEquals(messageToStore.getHeaders(), retrievedMessage.getHeaders());
    assertEquals(((Message<?>) messageToStore.getPayload()).getPayload(), p);
    assertEquals(messageToStore, retrievedMessage);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) GenericMessage(org.springframework.messaging.support.GenericMessage) MutableMessage(org.springframework.integration.support.MutableMessage) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Aggregations

Test (org.junit.Test)23 MessageStore (org.springframework.integration.store.MessageStore)23 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)14 MongoClient (com.mongodb.MongoClient)8 SimpleMongoDbFactory (org.springframework.data.mongodb.core.SimpleMongoDbFactory)8 GenericMessage (org.springframework.messaging.support.GenericMessage)5 JdbcMessageStore (org.springframework.integration.jdbc.store.JdbcMessageStore)4 UUID (java.util.UUID)3 AbstractBatchingMessageGroupStore (org.springframework.integration.store.AbstractBatchingMessageGroupStore)3 MessageGroup (org.springframework.integration.store.MessageGroup)3 MessageGroupStore (org.springframework.integration.store.MessageGroupStore)3 SimpleMessageStore (org.springframework.integration.store.SimpleMessageStore)3 Matchers.containsString (org.hamcrest.Matchers.containsString)2 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)2 AdviceMessage (org.springframework.integration.message.AdviceMessage)2 Properties (java.util.Properties)1 DirectChannel (org.springframework.integration.channel.DirectChannel)1 MessageHistory (org.springframework.integration.history.MessageHistory)1 MutableMessage (org.springframework.integration.support.MutableMessage)1 ClaimCheckInTransformer (org.springframework.integration.transformer.ClaimCheckInTransformer)1