Search in sources :

Example 1 with TestSupportBinder

use of org.springframework.cloud.stream.test.binder.TestSupportBinder in project spring-cloud-stream by spring-cloud.

the class AggregateApplicationTests method testAggregateApplication.

@Test
@SuppressWarnings("unchecked")
public void testAggregateApplication() throws Exception {
    ConfigurableApplicationContext context = new AggregateApplicationBuilder(TestSupportBinderAutoConfiguration.class).web(false).from(TestSource.class).to(TestProcessor.class).run();
    TestSupportBinder testSupportBinder = (TestSupportBinder) context.getBean(BinderFactory.class).getBinder(null, MessageChannel.class);
    MessageChannel processorOutput = testSupportBinder.getChannelForName("output");
    Message<String> received = (Message<String>) (testSupportBinder.messageCollector().forChannel(processorOutput).poll(5, TimeUnit.SECONDS));
    Assert.assertThat(received, notNullValue());
    Assert.assertTrue(received.getPayload().endsWith("processed"));
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) TestSupportBinder(org.springframework.cloud.stream.test.binder.TestSupportBinder) MessageChannel(org.springframework.messaging.MessageChannel) Message(org.springframework.messaging.Message) AggregateApplicationBuilder(org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder) TestProcessor(org.springframework.cloud.stream.config.aggregate.processor.TestProcessor) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 AggregateApplicationBuilder (org.springframework.cloud.stream.aggregate.AggregateApplicationBuilder)1 TestProcessor (org.springframework.cloud.stream.config.aggregate.processor.TestProcessor)1 TestSupportBinder (org.springframework.cloud.stream.test.binder.TestSupportBinder)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 Message (org.springframework.messaging.Message)1 MessageChannel (org.springframework.messaging.MessageChannel)1