use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbOutboundGatewayXmlTests method testSingleQueryExpression.
@Test
@MongoDbAvailable
public void testSingleQueryExpression() throws Exception {
EventDrivenConsumer consumer = context.getBean("gatewaySingleQueryExpression", EventDrivenConsumer.class);
PollableChannel outChannel = context.getBean("out", PollableChannel.class);
Message<String> message = MessageBuilder.withPayload("").setHeader("query", "{'name' : 'Gary'}").setHeader("collectionName", "data").build();
consumer.getHandler().handleMessage(message);
Message<?> result = outChannel.receive(10000);
Person person = getPerson(result);
assertEquals("Gary", person.getName());
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbOutboundGatewayXmlTests method testQueryExpression.
@Test
@MongoDbAvailable
public void testQueryExpression() throws Exception {
EventDrivenConsumer consumer = context.getBean("gatewayQueryExpression", EventDrivenConsumer.class);
PollableChannel outChannel = context.getBean("out", PollableChannel.class);
Message<String> message = MessageBuilder.withPayload("").setHeader("query", "{}").setHeader("collectionName", "data").build();
consumer.getHandler().handleMessage(message);
Message<?> result = outChannel.receive(10000);
List<Person> persons = getPersons(result);
assertEquals(4, persons.size());
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbOutboundGatewayXmlTests method testCollectionCallback.
@Test
@MongoDbAvailable
public void testCollectionCallback() throws Exception {
EventDrivenConsumer consumer = context.getBean("gatewayCollectionCallback", EventDrivenConsumer.class);
PollableChannel outChannel = context.getBean("out", PollableChannel.class);
Message<String> message = MessageBuilder.withPayload("").setHeader("collectionName", "data").build();
consumer.getHandler().handleMessage(message);
Message<?> result = outChannel.receive(10000);
long personsCount = (Long) result.getPayload();
assertEquals(4, personsCount);
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbOutboundGatewayXmlTests method testQueryExpressionWithLimit.
@Test
@MongoDbAvailable
public void testQueryExpressionWithLimit() throws Exception {
EventDrivenConsumer consumer = context.getBean("gatewayQueryExpressionLimit", EventDrivenConsumer.class);
PollableChannel outChannel = context.getBean("out", PollableChannel.class);
Message<String> message = MessageBuilder.withPayload("").setHeader("collectionName", "data").build();
consumer.getHandler().handleMessage(message);
Message<?> result = outChannel.receive(10000);
List<Person> persons = getPersons(result);
assertEquals(2, persons.size());
}
use of org.springframework.integration.mongodb.rules.MongoDbAvailable in project spring-integration by spring-projects.
the class MongoDbOutboundChannelAdapterIntegrationTests method testSavingDbObject.
@Test
@MongoDbAvailable
public void testSavingDbObject() throws Exception {
BasicDBObject dbObject = BasicDBObject.parse("{'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<BasicDBObject> message = MessageBuilder.withPayload(dbObject).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