Search in sources :

Example 46 with EventDrivenConsumer

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

the class InnerDefinitionHandlerAwareEndpointParserTests method testSADefinitionSuccess.

private void testSADefinitionSuccess(String configProperty) {
    ApplicationContext ac = this.bootStrap(configProperty);
    EventDrivenConsumer splitter = (EventDrivenConsumer) ac.getBean("testServiceActivator");
    Assert.assertNotNull(splitter);
    MessageBuilder<String> inChannelMessageBuilder = MessageBuilder.withPayload("1");
    Message<String> inMessage = inChannelMessageBuilder.build();
    DirectChannel inChannel = (DirectChannel) ac.getBean("inChannel");
    inChannel.send(inMessage);
    PollableChannel channel1 = (PollableChannel) ac.getBean("outChannel");
    Assert.assertTrue(channel1.receive().getPayload().equals("1"));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) DirectChannel(org.springframework.integration.channel.DirectChannel) PollableChannel(org.springframework.messaging.PollableChannel)

Example 47 with EventDrivenConsumer

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

the class InnerDefinitionHandlerAwareEndpointParserTests method testTransformerDefinitionSuccess.

private void testTransformerDefinitionSuccess(String configProperty) {
    ApplicationContext ac = this.bootStrap(configProperty);
    EventDrivenConsumer transformer = (EventDrivenConsumer) ac.getBean("testTransformer");
    Assert.assertNotNull(transformer);
    MessageBuilder<String[]> inChannelMessageBuilder = MessageBuilder.withPayload(new String[] { "One", "Two" });
    Message<String[]> inMessage = inChannelMessageBuilder.build();
    DirectChannel inChannel = (DirectChannel) ac.getBean("inChannel");
    inChannel.send(inMessage);
    PollableChannel outChannel = (PollableChannel) ac.getBean("outChannel");
    String payload = (String) outChannel.receive().getPayload();
    Assert.assertTrue(payload.equals("One,Two"));
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) DirectChannel(org.springframework.integration.channel.DirectChannel) PollableChannel(org.springframework.messaging.PollableChannel)

Example 48 with EventDrivenConsumer

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

the class FilterAnnotationPostProcessorTests method filterAnnotationWithAdviceArray.

@Test
public void filterAnnotationWithAdviceArray() {
    TestAdvice advice = new TestAdvice();
    context.registerBean("adviceChain", new TestAdvice[] { advice });
    testValidFilter(new TestFilterWithAdviceDiscardWithin());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("testFilter.filter.filter");
    assertSame(advice, TestUtils.getPropertyValue(endpoint, "handler.adviceChain", List.class).get(0));
    assertTrue(TestUtils.getPropertyValue(endpoint, "handler.postProcessWithinAdvice", Boolean.class));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) Test(org.junit.Test)

Example 49 with EventDrivenConsumer

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

the class FilterAnnotationPostProcessorTests method filterAnnotationWithAdviceArrayTwice.

@Test
public void filterAnnotationWithAdviceArrayTwice() {
    TestAdvice advice1 = new TestAdvice();
    TestAdvice advice2 = new TestAdvice();
    context.registerBean("adviceChain1", new TestAdvice[] { advice1, advice2 });
    TestAdvice advice3 = new TestAdvice();
    TestAdvice advice4 = new TestAdvice();
    context.registerBean("adviceChain2", new TestAdvice[] { advice3, advice4 });
    testValidFilter(new TestFilterWithAdviceDiscardWithinTwice());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("testFilter.filter.filter");
    List<?> adviceList = TestUtils.getPropertyValue(endpoint, "handler.adviceChain", List.class);
    assertEquals(4, adviceList.size());
    assertSame(advice1, adviceList.get(0));
    assertSame(advice2, adviceList.get(1));
    assertSame(advice3, adviceList.get(2));
    assertSame(advice4, adviceList.get(3));
    assertTrue(TestUtils.getPropertyValue(endpoint, "handler.postProcessWithinAdvice", Boolean.class));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) Test(org.junit.Test)

Example 50 with EventDrivenConsumer

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

the class FilterAnnotationPostProcessorTests method filterAnnotationWithAdviceDiscardWithinTwice.

@Test
public void filterAnnotationWithAdviceDiscardWithinTwice() {
    TestAdvice advice1 = new TestAdvice();
    TestAdvice advice2 = new TestAdvice();
    context.registerBean("adviceChain1", advice1);
    context.registerBean("adviceChain2", advice2);
    testValidFilter(new TestFilterWithAdviceDiscardWithinTwice());
    EventDrivenConsumer endpoint = (EventDrivenConsumer) context.getBean("testFilter.filter.filter");
    List<?> adviceList = TestUtils.getPropertyValue(endpoint, "handler.adviceChain", List.class);
    assertEquals(2, adviceList.size());
    assertSame(advice1, adviceList.get(0));
    assertSame(advice2, adviceList.get(1));
    assertTrue(TestUtils.getPropertyValue(endpoint, "handler.postProcessWithinAdvice", Boolean.class));
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) 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