Search in sources :

Example 76 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JpaMessageHandlerParserTests method advised.

@Test
public void advised() throws Exception {
    setUp("JpaMessageHandlerParserTests.xml", getClass());
    EventDrivenConsumer consumer = this.context.getBean("advised", EventDrivenConsumer.class);
    final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(consumer, "inputChannel", AbstractMessageChannel.class);
    assertEquals("target", inputChannel.getComponentName());
    final MessageHandler handler = TestUtils.getPropertyValue(consumer, "handler", MessageHandler.class);
    adviceCalled = 0;
    handler.handleMessage(new GenericMessage<String>("foo"));
    assertEquals(1, adviceCalled);
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) AbstractMessageChannel(org.springframework.integration.channel.AbstractMessageChannel) AbstractReplyProducingMessageHandler(org.springframework.integration.handler.AbstractReplyProducingMessageHandler) MessageHandler(org.springframework.messaging.MessageHandler) Test(org.junit.Test)

Example 77 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class MarshallingTransformerParserTests method testParse.

@Test
public void testParse() throws Exception {
    EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.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 = appContext.getBean(SmartLifecycleRoleController.class);
    @SuppressWarnings("unchecked") List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class).get("foo");
    assertThat(list, contains((SmartLifecycle) consumer));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) SmartLifecycleRoleController(org.springframework.integration.support.SmartLifecycleRoleController) List(java.util.List) SmartLifecycle(org.springframework.context.SmartLifecycle) Test(org.junit.Test)

Example 78 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class UnmarshallingTransformerParserTests method testParse.

@Test
public void testParse() throws Exception {
    EventDrivenConsumer consumer = (EventDrivenConsumer) appContext.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 = appContext.getBean(SmartLifecycleRoleController.class);
    @SuppressWarnings("unchecked") List<SmartLifecycle> list = (List<SmartLifecycle>) TestUtils.getPropertyValue(roleController, "lifecycles", MultiValueMap.class).get("foo");
    assertThat(list, contains((SmartLifecycle) consumer));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) SmartLifecycleRoleController(org.springframework.integration.support.SmartLifecycleRoleController) List(java.util.List) SmartLifecycle(org.springframework.context.SmartLifecycle) Test(org.junit.Test)

Example 79 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class XPathMessageSplitterParserTests method testXPathExpressionRef.

@Test
public void testXPathExpressionRef() throws Exception {
    TestXmlApplicationContext ctx = TestXmlApplicationContextHelper.getTestAppContext(channelDefinitions + "<si-xml:xpath-expression id='xpathOne' expression='//name'/>" + "<si-xml:xpath-splitter id='splitter' xpath-expression-ref='xpathOne' input-channel='test-input' output-channel='test-output' />");
    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);
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 80 with EventDrivenConsumer

use of org.springframework.integration.endpoint.EventDrivenConsumer in project spring-integration by spring-projects.

the class JmsOutboundChannelAdapterParserTests method adapterWithDefaultConnectionFactory.

@Test
public void adapterWithDefaultConnectionFactory() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jmsOutboundWithDefaultConnectionFactory.xml", this.getClass());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("adapter");
    DirectFieldAccessor accessor = new DirectFieldAccessor(new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
    assertNotNull(accessor.getPropertyValue("jmsTemplate"));
    context.close();
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Aggregations

EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)106 Test (org.junit.Test)96 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)29 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)27 DirectChannel (org.springframework.integration.channel.DirectChannel)19 PollableChannel (org.springframework.messaging.PollableChannel)19 GenericMessage (org.springframework.messaging.support.GenericMessage)18 MessageChannel (org.springframework.messaging.MessageChannel)16 QueueChannel (org.springframework.integration.channel.QueueChannel)14 MessageHandler (org.springframework.messaging.MessageHandler)12 List (java.util.List)9 ResequencingMessageHandler (org.springframework.integration.aggregator.ResequencingMessageHandler)9 Message (org.springframework.messaging.Message)8 SmartLifecycle (org.springframework.context.SmartLifecycle)6 JmsOutboundGateway (org.springframework.integration.jms.JmsOutboundGateway)6 MongoDbAvailable (org.springframework.integration.mongodb.rules.MongoDbAvailable)6 SmartLifecycleRoleController (org.springframework.integration.support.SmartLifecycleRoleController)6 MethodInvokingReleaseStrategy (org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)5 ReleaseStrategy (org.springframework.integration.aggregator.ReleaseStrategy)5 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)5