Search in sources :

Example 6 with MessageStore

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

the class AbstractMongoDbMessageStoreTests method testInt3153SequenceDetails.

@Test
@MongoDbAvailable
public void testInt3153SequenceDetails() throws Exception {
    cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
    MessageStore store = getMessageStore();
    Message<?> messageToStore = MessageBuilder.withPayload("test").pushSequenceDetails(UUID.randomUUID(), 1, 1).pushSequenceDetails(UUID.randomUUID(), 1, 1).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);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 7 with MessageStore

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

the class AbstractMongoDbMessageStoreTests method testAddThenRemoveWithStringPayload.

@Test
@MongoDbAvailable
public void testAddThenRemoveWithStringPayload() throws Exception {
    cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
    MessageStore store = getMessageStore();
    Message<?> messageToStore = MessageBuilder.withPayload("Hello").build();
    store.addMessage(messageToStore);
    Message<?> retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
    assertNotNull(retrievedMessage);
    store.removeMessage(retrievedMessage.getHeaders().getId());
    retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
    assertNull(retrievedMessage);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 8 with MessageStore

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

the class AbstractMongoDbMessageStoreTests method testAdviceMessageAsPayload.

@Test
@MongoDbAvailable
public void testAdviceMessageAsPayload() throws Exception {
    MessageStore store = this.getMessageStore();
    Person p = new Person();
    p.setFname("John");
    p.setLname("Doe");
    Message<Person> inputMessage = MessageBuilder.withPayload(p).build();
    Message<?> messageToStore = new GenericMessage<Message<?>>(new AdviceMessage<String>("foo", inputMessage));
    store.addMessage(messageToStore);
    Message<?> retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
    assertNotNull(retrievedMessage);
    assertTrue(retrievedMessage.getPayload() instanceof AdviceMessage);
    AdviceMessage<?> adviceMessage = (AdviceMessage<?>) retrievedMessage.getPayload();
    assertEquals("foo", adviceMessage.getPayload());
    assertEquals(messageToStore.getHeaders(), retrievedMessage.getHeaders());
    assertEquals(inputMessage, adviceMessage.getInputMessage());
    assertEquals(messageToStore, retrievedMessage);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) GenericMessage(org.springframework.messaging.support.GenericMessage) Matchers.containsString(org.hamcrest.Matchers.containsString) AdviceMessage(org.springframework.integration.message.AdviceMessage) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 9 with MessageStore

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

the class AbstractMongoDbMessageStoreTests method testInt3076MessageAsPayload.

@Test
@MongoDbAvailable
public void testInt3076MessageAsPayload() throws Exception {
    MessageStore store = this.getMessageStore();
    Person p = new Person();
    p.setFname("John");
    p.setLname("Doe");
    Message<?> messageToStore = new GenericMessage<Message<?>>(MessageBuilder.withPayload(p).build());
    store.addMessage(messageToStore);
    Message<?> retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
    assertNotNull(retrievedMessage);
    assertTrue(retrievedMessage.getPayload() instanceof GenericMessage);
    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) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 10 with MessageStore

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

the class AbstractMongoDbMessageStoreTests method testInt3076AdviceMessage.

@Test
@MongoDbAvailable
public void testInt3076AdviceMessage() throws Exception {
    MessageStore store = this.getMessageStore();
    Person p = new Person();
    p.setFname("John");
    p.setLname("Doe");
    Message<Person> inputMessage = MessageBuilder.withPayload(p).build();
    Message<?> messageToStore = new AdviceMessage<String>("foo", inputMessage);
    store.addMessage(messageToStore);
    Message<?> retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
    assertNotNull(retrievedMessage);
    assertTrue(retrievedMessage instanceof AdviceMessage);
    assertEquals(messageToStore.getPayload(), retrievedMessage.getPayload());
    assertEquals(messageToStore.getHeaders(), retrievedMessage.getHeaders());
    assertEquals(inputMessage, ((AdviceMessage<?>) retrievedMessage).getInputMessage());
    assertEquals(messageToStore, retrievedMessage);
}
Also used : MessageStore(org.springframework.integration.store.MessageStore) AdviceMessage(org.springframework.integration.message.AdviceMessage) 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