use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class XPathMessageSplitterParserTests method testSimpleStringExpressionWithCreateDocuments.
@Test
public void testSimpleStringExpressionWithCreateDocuments() throws Exception {
Document doc = XmlTestUtil.getDocumentForString("<names><name>Bob</name><name>John</name></names>");
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
TestXmlApplicationContext ctx = TestXmlApplicationContextHelper.getTestAppContext(channelDefinitions + "<si-xml:xpath-splitter id='splitter' input-channel='test-input' output-channel='test-output' create-documents='true'><si-xml:xpath-expression expression='//name'/></si-xml:xpath-splitter>");
EventDrivenConsumer consumer = (EventDrivenConsumer) ctx.getBean("splitter");
consumer.start();
ctx.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
inputChannel.send(docMessage);
assertEquals("Wrong number of split messages ", 2, outputChannel.getQueueSize());
assertTrue("Splitter failed to create documents ", ((Message<?>) outputChannel.receive(1000)).getPayload() instanceof Document);
assertTrue("Splitter failed to create documents ", ((Message<?>) outputChannel.receive(1000)).getPayload() instanceof Document);
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class XPathFilterParserTests method testParse.
@Test
public void testParse() throws Exception {
EventDrivenConsumer consumer = (EventDrivenConsumer) context.getBean("parseOnly");
assertEquals(2, TestUtils.getPropertyValue(consumer, "handler.order"));
assertEquals(123L, TestUtils.getPropertyValue(consumer, "handler.messagingTemplate.sendTimeout"));
assertEquals(-1, TestUtils.getPropertyValue(consumer, "phase"));
assertFalse(TestUtils.getPropertyValue(consumer, "autoStartup", Boolean.class));
SmartLifecycleRoleController roleController = context.getBean(SmartLifecycleRoleController.class);
@SuppressWarnings("unchecked") List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class).get("foo");
assertThat(list, contains((SmartLifecycle) consumer));
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class EventOutboundChannelAdapterParserTests method validateEventParser.
@Test
public void validateEventParser() {
EventDrivenConsumer adapter = this.context.getBean("eventAdapter", EventDrivenConsumer.class);
Assert.assertNotNull(adapter);
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapter);
MessageHandler handler = (MessageHandler) adapterAccessor.getPropertyValue("handler");
Assert.assertTrue(handler instanceof ApplicationEventPublishingMessageHandler);
Assert.assertEquals(this.context.getBean("input"), adapterAccessor.getPropertyValue("inputChannel"));
Assert.assertTrue(TestUtils.getPropertyValue(handler, "publishPayload", Boolean.class));
}
use of org.springframework.integration.endpoint.EventDrivenConsumer 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.endpoint.EventDrivenConsumer 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());
}
Aggregations