Search in sources :

Example 21 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project spring-integration by spring-projects.

the class MongoDbMessageStoreClaimCheckIntegrationTests method objectPayload.

@Test
@MongoDbAvailable
public void objectPayload() throws Exception {
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
    MongoDbMessageStore messageStore = new MongoDbMessageStore(mongoDbFactory);
    messageStore.afterPropertiesSet();
    ClaimCheckInTransformer checkin = new ClaimCheckInTransformer(messageStore);
    ClaimCheckOutTransformer checkout = new ClaimCheckOutTransformer(messageStore);
    Beverage payload = new Beverage();
    payload.setName("latte");
    payload.setShots(3);
    payload.setIced(false);
    Message<?> originalMessage = MessageBuilder.withPayload(payload).build();
    Message<?> claimCheckMessage = checkin.transform(originalMessage);
    assertEquals(originalMessage.getHeaders().getId(), claimCheckMessage.getPayload());
    Message<?> checkedOutMessage = checkout.transform(claimCheckMessage);
    assertEquals(originalMessage.getPayload(), checkedOutMessage.getPayload());
    assertEquals(claimCheckMessage.getPayload(), checkedOutMessage.getHeaders().getId());
    assertEquals(originalMessage, checkedOutMessage);
}
Also used : MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) ClaimCheckInTransformer(org.springframework.integration.transformer.ClaimCheckInTransformer) ClaimCheckOutTransformer(org.springframework.integration.transformer.ClaimCheckOutTransformer) Test(org.junit.Test) MongoDbAvailable(org.springframework.integration.mongodb.rules.MongoDbAvailable)

Example 22 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project spring-integration by spring-projects.

the class ConfigurableMongoDbMessageStoreTests method getMessageStore.

@Override
protected MessageStore getMessageStore() throws Exception {
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
    ConfigurableMongoDbMessageStore mongoDbMessageStore = new ConfigurableMongoDbMessageStore(mongoDbFactory);
    GenericApplicationContext testApplicationContext = TestUtils.createTestApplicationContext();
    testApplicationContext.refresh();
    mongoDbMessageStore.setApplicationContext(testApplicationContext);
    mongoDbMessageStore.afterPropertiesSet();
    return mongoDbMessageStore;
}
Also used : MongoClient(com.mongodb.MongoClient) MongoDbFactory(org.springframework.data.mongodb.MongoDbFactory) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory)

Example 23 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project spring-integration by spring-projects.

the class MongoDbMessageGroupStoreTests method getMessageGroupStore.

@Override
protected MongoDbMessageStore getMessageGroupStore() throws Exception {
    MongoDbMessageStore mongoDbMessageStore = new MongoDbMessageStore(new SimpleMongoDbFactory(new MongoClient(), "test"));
    mongoDbMessageStore.afterPropertiesSet();
    return mongoDbMessageStore;
}
Also used : MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory)

Example 24 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory in project spring-integration by spring-projects.

the class MongoDbMessageStoreTests method getMessageStore.

@Override
protected MessageStore getMessageStore() throws Exception {
    MongoDbMessageStore mongoDbMessageStore = new MongoDbMessageStore(new SimpleMongoDbFactory(new MongoClient(), "test"));
    mongoDbMessageStore.afterPropertiesSet();
    return mongoDbMessageStore;
}
Also used : MongoClient(com.mongodb.MongoClient) SimpleMongoDbFactory(org.springframework.data.mongodb.core.SimpleMongoDbFactory)

Example 25 with SimpleMongoDbFactory

use of org.springframework.data.mongodb.core.SimpleMongoDbFactory 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)

Aggregations

SimpleMongoDbFactory (org.springframework.data.mongodb.core.SimpleMongoDbFactory)51 MongoClient (com.mongodb.MongoClient)38 Test (org.junit.Test)28 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)28 AbstractBatchingMessageGroupStore (org.springframework.integration.store.AbstractBatchingMessageGroupStore)16 MessageGroupStore (org.springframework.integration.store.MessageGroupStore)16 GenericMessage (org.springframework.messaging.support.GenericMessage)14 MessageGroup (org.springframework.integration.store.MessageGroup)12 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)10 Bean (org.springframework.context.annotation.Bean)9 MongoDbFactory (org.springframework.data.mongodb.MongoDbFactory)8 MappingMongoConverter (org.springframework.data.mongodb.core.convert.MappingMongoConverter)8 MessageStore (org.springframework.integration.store.MessageStore)8 MongoClientURI (com.mongodb.MongoClientURI)6 Net (de.flapdoodle.embed.mongo.config.Net)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)4 ClaimCheckInTransformer (org.springframework.integration.transformer.ClaimCheckInTransformer)4 ClaimCheckOutTransformer (org.springframework.integration.transformer.ClaimCheckOutTransformer)4 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3