use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class ConfigurableMongoDbMessageGroupStoreTests method testPriorityChannel.
@Test
@MongoDbAvailable
public void testPriorityChannel() throws Exception {
this.cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ConfigurableMongoDbMessageStore-CustomConverter.xml", this.getClass());
context.refresh();
Object priorityChannel = context.getBean("priorityChannel");
assertThat(priorityChannel, Matchers.instanceOf(PriorityChannel.class));
QueueChannel channel = (QueueChannel) priorityChannel;
Message<String> message = MessageBuilder.withPayload("1").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 1).build();
channel.send(message);
message = MessageBuilder.withPayload("-1").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, -1).build();
channel.send(message);
message = MessageBuilder.withPayload("3").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 3).build();
channel.send(message);
message = MessageBuilder.withPayload("0").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 0).build();
channel.send(message);
message = MessageBuilder.withPayload("2").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 2).build();
channel.send(message);
message = MessageBuilder.withPayload("none").build();
channel.send(message);
message = MessageBuilder.withPayload("31").setHeader(IntegrationMessageHeaderAccessor.PRIORITY, 3).build();
channel.send(message);
Message<?> receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("3", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("31", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("2", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("1", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("0", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("-1", receive.getPayload());
receive = channel.receive(1000);
assertNotNull(receive);
assertEquals("none", receive.getPayload());
context.close();
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbMessageStoreClaimCheckIntegrationTests method stringPayloadConfigurable.
@Test
@MongoDbAvailable
public void stringPayloadConfigurable() throws Exception {
MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
ConfigurableMongoDbMessageStore messageStore = new ConfigurableMongoDbMessageStore(mongoDbFactory);
GenericApplicationContext testApplicationContext = TestUtils.createTestApplicationContext();
testApplicationContext.refresh();
messageStore.setApplicationContext(testApplicationContext);
messageStore.afterPropertiesSet();
ClaimCheckInTransformer checkin = new ClaimCheckInTransformer(messageStore);
ClaimCheckOutTransformer checkout = new ClaimCheckOutTransformer(messageStore);
Message<?> originalMessage = MessageBuilder.withPayload("test1").build();
Message<?> claimCheckMessage = checkin.transform(originalMessage);
assertEquals(originalMessage.getHeaders().getId(), claimCheckMessage.getPayload());
Message<?> checkedOutMessage = checkout.transform(claimCheckMessage);
assertEquals(claimCheckMessage.getPayload(), checkedOutMessage.getHeaders().getId());
assertEquals(originalMessage.getPayload(), checkedOutMessage.getPayload());
assertEquals(originalMessage, checkedOutMessage);
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbOutboundGatewayXmlTests method testSingleQuery.
@Test
@MongoDbAvailable
public void testSingleQuery() throws Exception {
EventDrivenConsumer consumer = context.getBean("gatewaySingleQuery", EventDrivenConsumer.class);
PollableChannel outChannel = context.getBean("out", PollableChannel.class);
Message<String> message = MessageBuilder.withPayload("").build();
consumer.getHandler().handleMessage(message);
Message<?> result = outChannel.receive(10000);
Person person = getPerson(result);
assertEquals("Xavi", person.getName());
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbOutboundGatewayXmlTests method testSingleQueryWithTemplate.
@Test
@MongoDbAvailable
public void testSingleQueryWithTemplate() throws Exception {
EventDrivenConsumer consumer = context.getBean("gatewayWithTemplate", EventDrivenConsumer.class);
PollableChannel outChannel = context.getBean("out", PollableChannel.class);
Message<String> message = MessageBuilder.withPayload("").build();
consumer.getHandler().handleMessage(message);
Message<?> result = outChannel.receive(10000);
Person person = getPerson(result);
assertEquals("Xavi", person.getName());
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbOutboundChannelAdapterIntegrationTests method testSavingJSONString.
@Test
@MongoDbAvailable
public void testSavingJSONString() throws Exception {
String object = "{'foo' : 'bar'}";
MongoDbFactory mongoDbFactory = this.prepareMongoFactory("foo");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("outbound-adapter-config.xml", this.getClass());
MessageChannel channel = context.getBean("simpleAdapterWithTemplate", MessageChannel.class);
Message<String> message = MessageBuilder.withPayload(object).setHeader("collectionName", "foo").build();
channel.send(message);
MongoTemplate template = new MongoTemplate(mongoDbFactory);
assertNotNull(template.find(new BasicQuery("{'foo' : 'bar'}"), BasicDBObject.class, "foo"));
context.close();
}
Aggregations