Search in sources :

Example 1 with FilterFactoryBean

use of org.springframework.integration.config.FilterFactoryBean in project spring-integration by spring-projects.

the class FilterAnnotationMethodResolutionTests method resolveAnnotatedMethod.

@Test
public void resolveAnnotatedMethod() throws Exception {
    TestUtils.TestApplicationContext testApplicationContext = TestUtils.createTestApplicationContext();
    testApplicationContext.refresh();
    FilterFactoryBean factoryBean = new FilterFactoryBean();
    factoryBean.setBeanFactory(testApplicationContext);
    AnnotatedTestFilter filter = new AnnotatedTestFilter();
    factoryBean.setTargetObject(filter);
    MessageHandler handler = factoryBean.getObject();
    QueueChannel replyChannel = new QueueChannel();
    handler.handleMessage(MessageBuilder.withPayload("test").setReplyChannel(replyChannel).build());
    Message<?> result = replyChannel.receive(0);
    assertNotNull(result);
    assertTrue(filter.invokedCorrectMethod);
    assertFalse(filter.invokedIncorrectMethod);
    testApplicationContext.close();
}
Also used : TestUtils(org.springframework.integration.test.util.TestUtils) MessageHandler(org.springframework.messaging.MessageHandler) QueueChannel(org.springframework.integration.channel.QueueChannel) FilterFactoryBean(org.springframework.integration.config.FilterFactoryBean) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 QueueChannel (org.springframework.integration.channel.QueueChannel)1 FilterFactoryBean (org.springframework.integration.config.FilterFactoryBean)1 TestUtils (org.springframework.integration.test.util.TestUtils)1 MessageHandler (org.springframework.messaging.MessageHandler)1