use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class JmsOutboundChannelAdapterParserTests method adapterWithConnectionFactoryAndDestination.
@Test
public void adapterWithConnectionFactoryAndDestination() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundWithConnectionFactoryAndDestination.xml", this.getClass());
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("adapter");
DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
assertNotNull(accessor.getPropertyValue("jmsTemplate"));
assertTrue(TestUtils.getPropertyValue(endpoint, "handler.jmsTemplate.sessionTransacted", Boolean.class));
context.close();
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class JmsOutboundChannelAdapterParserTests method adapterWithConnectionFactoryAndDestinationName.
@Test
public void adapterWithConnectionFactoryAndDestinationName() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundWithConnectionFactoryAndDestinationName.xml", this.getClass());
EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("adapter");
DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
assertNotNull(accessor.getPropertyValue("jmsTemplate"));
assertFalse(TestUtils.getPropertyValue(endpoint, "handler.jmsTemplate.sessionTransacted", Boolean.class));
context.close();
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class TestSendingMessageHandlerParserTests method testSendingMessageHandlerSuccessfulBootstrap.
@Test
public void testSendingMessageHandlerSuccessfulBootstrap() {
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("TestSendingMessageHandlerParser-context.xml", this.getClass());
EventDrivenConsumer dmAdapter = ac.getBean("dmAdapter", EventDrivenConsumer.class);
MessageHandler handler = TestUtils.getPropertyValue(dmAdapter, "handler", MessageHandler.class);
assertEquals(DirectMessageSendingMessageHandler.class, handler.getClass());
assertEquals(23, TestUtils.getPropertyValue(handler, "order"));
dmAdapter = ac.getBean("dmAdvised", EventDrivenConsumer.class);
handler = TestUtils.getPropertyValue(dmAdapter, "handler", MessageHandler.class);
handler.handleMessage(new GenericMessage<String>("foo"));
assertEquals(1, adviceCalled);
MessageHandler handler2 = TestUtils.getPropertyValue(ac.getBean("advised"), "handler", MessageHandler.class);
assertNotSame(handler, handler2);
handler2.handleMessage(new GenericMessage<String>("foo"));
assertEquals(2, adviceCalled);
ac.close();
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class XPathMessageSplitterParserTests method testProvideDocumentBuilder.
@Test
public void testProvideDocumentBuilder() throws Exception {
TestXmlApplicationContext ctx = TestXmlApplicationContextHelper.getTestAppContext("<bean id='docBuilderFactory' class='org.springframework.integration.xml.config.StubDocumentBuilderFactory' />" + channelDefinitions + "<si-xml:xpath-splitter id='splitter' input-channel='test-input' output-channel='test-output' doc-builder-factory='docBuilderFactory'><si-xml:xpath-expression expression='//name'/></si-xml:xpath-splitter>");
EventDrivenConsumer consumer = (EventDrivenConsumer) ctx.getBean("splitter");
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(consumer);
Object handler = fieldAccessor.getPropertyValue("handler");
fieldAccessor = new DirectFieldAccessor(handler);
Object documnetBuilderFactory = fieldAccessor.getPropertyValue("documentBuilderFactory");
assertTrue("DocumnetBuilderFactory was not expected stub ", documnetBuilderFactory instanceof DocumentBuilderFactory);
}
use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.
the class XPathMessageSplitterParserTests method testSimpleStringExpression.
@Test
public void testSimpleStringExpression() 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' " + "order='2' send-timeout='123' auto-startup='false' phase='-1' " + "input-channel='test-input' output-channel='test-output'><si-xml:xpath-expression expression='//name'/></si-xml:xpath-splitter>");
EventDrivenConsumer consumer = (EventDrivenConsumer) ctx.getBean("splitter");
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));
consumer.start();
ctx.getAutowireCapableBeanFactory().autowireBeanProperties(this, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
inputChannel.send(docMessage);
assertEquals("Wrong number of split messages ", 2, outputChannel.getQueueSize());
}
Aggregations