use of org.springframework.integration.mongodb.rules.MongoDbAvailable 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"));
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class AbstractMongoDbMessageStoreTests method testInt3076ErrorMessage.
@Test
@MongoDbAvailable
public void testInt3076ErrorMessage() throws Exception {
MessageStore store = this.getMessageStore();
Person p = new Person();
p.setFname("John");
p.setLname("Doe");
Message<Person> failedMessage = MessageBuilder.withPayload(p).build();
MessagingException messagingException;
try {
throw new RuntimeException("intentional");
} catch (Exception e) {
messagingException = new MessagingException(failedMessage, "intentional MessagingException", e);
}
Message<?> messageToStore = new ErrorMessage(messagingException);
store.addMessage(messageToStore);
Message<?> retrievedMessage = store.getMessage(messageToStore.getHeaders().getId());
assertNotNull(retrievedMessage);
assertTrue(retrievedMessage instanceof ErrorMessage);
assertThat(retrievedMessage.getPayload(), Matchers.instanceOf(MessagingException.class));
assertThat(((MessagingException) retrievedMessage.getPayload()).getMessage(), containsString("intentional MessagingException"));
assertEquals(failedMessage, ((MessagingException) retrievedMessage.getPayload()).getFailedMessage());
assertEquals(messageToStore.getHeaders(), retrievedMessage.getHeaders());
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class AbstractMongoDbMessageStoreTests method testAddAndUpdateAlreadySaved.
@Test
@MongoDbAvailable
public void testAddAndUpdateAlreadySaved() throws Exception {
MessageStore messageStore = getMessageStore();
Message<String> message = MessageBuilder.withPayload("foo").build();
message = messageStore.addMessage(message);
Message<String> result = messageStore.addMessage(message);
assertEquals(message, result);
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class AbstractMongoDbMessageStoreTests method testAddGetWithStringPayload.
@Test
@MongoDbAvailable
public void testAddGetWithStringPayload() 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);
assertEquals(messageToStore.getPayload(), retrievedMessage.getPayload());
assertEquals(messageToStore.getHeaders(), retrievedMessage.getHeaders());
assertEquals(messageToStore, retrievedMessage);
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbMetadataStoreTests method testConfigureFactorCustomCollection.
@MongoDbAvailable
@Test
public void testConfigureFactorCustomCollection() throws Exception {
final String collectionName = "testMetadataStore";
final MongoDbFactory mongoDbFactory = this.prepareMongoFactory(collectionName);
store = new MongoDbMetadataStore(mongoDbFactory, collectionName);
testBasics();
}
Aggregations