use of org.springframework.integration.endpoint.EventDrivenConsumer 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.endpoint.EventDrivenConsumer 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.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class JmsOutboundGatewayParserTests method gatewayWithDefaultPubSubDomain.
@Test
public void gatewayWithDefaultPubSubDomain() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayWithPubSubSettings.xml", this.getClass());
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("defaultGateway");
DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
assertFalse((Boolean) accessor.getPropertyValue("requestPubSubDomain"));
assertFalse((Boolean) accessor.getPropertyValue("replyPubSubDomain"));
context.close();
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class JmsOutboundGatewayParserTests method testAdvised.
@Test
public void testAdvised() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayWithDeliveryPersistent.xml", this.getClass());
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("advised");
JmsOutboundGateway gateway = TestUtils.getPropertyValue(endpoint, "handler", JmsOutboundGateway.class);
assertFalse(TestUtils.getPropertyValue(gateway, "async", Boolean.class));
gateway.handleMessage(new GenericMessage<String>("foo"));
assertEquals(1, adviceCalled);
assertEquals(3, TestUtils.getPropertyValue(gateway, "replyContainer.sessionAcknowledgeMode"));
context.close();
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class JmsOutboundGatewayParserTests method gatewayWithDestExpression.
@Test
public void gatewayWithDestExpression() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundGatewayReplyDestOptions.xml", this.getClass());
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("jmsGatewayDestExpression");
DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
ExpressionEvaluatingMessageProcessor<?> processor = TestUtils.getPropertyValue(gateway, "replyDestinationExpressionProcessor", ExpressionEvaluatingMessageProcessor.class);
Expression expression = TestUtils.getPropertyValue(gateway, "replyDestinationExpressionProcessor.expression", Expression.class);
assertEquals("payload", expression.getExpressionString());
Message<?> message = MessageBuilder.withPayload("foo").build();
assertEquals("foo", processor.processMessage(message));
Method method = JmsOutboundGateway.class.getDeclaredMethod("determineReplyDestination", Message.class, Session.class);
method.setAccessible(true);
Session session = mock(Session.class);
Queue queue = mock(Queue.class);
when(session.createQueue("foo")).thenReturn(queue);
Destination replyQ = (Destination) method.invoke(gateway, message, session);
assertSame(queue, replyQ);
context.close();
}
Aggregations