Search in sources :

Example 16 with TestChannelResolver

use of org.springframework.integration.channel.TestChannelResolver in project spring-integration by spring-projects.

the class RouterTests method nullChannelIdentifierUsingChannelResolverRaisesMessageDeliveryExceptionByDefault.

@Test(expected = MessageDeliveryException.class)
public void nullChannelIdentifierUsingChannelResolverRaisesMessageDeliveryExceptionByDefault() {
    AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {

        @Override
        protected List<Object> getChannelKeys(Message<?> message) {
            return null;
        }
    };
    TestChannelResolver channelResolver = new TestChannelResolver();
    router.setChannelResolver(channelResolver);
    Message<String> message = new GenericMessage<String>("test");
    router.handleMessage(message);
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) Message(org.springframework.messaging.Message) GenericMessage(org.springframework.messaging.support.GenericMessage) TestChannelResolver(org.springframework.integration.channel.TestChannelResolver) Test(org.junit.Test)

Example 17 with TestChannelResolver

use of org.springframework.integration.channel.TestChannelResolver in project spring-integration by spring-projects.

the class RouterTests method nullChannelIdentifierInListRaisesMessageDeliveryExceptionByDefault.

@Test(expected = MessageDeliveryException.class)
public void nullChannelIdentifierInListRaisesMessageDeliveryExceptionByDefault() {
    AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {

        @Override
        protected List<Object> getChannelKeys(Message<?> message) {
            return Collections.singletonList(null);
        }
    };
    TestChannelResolver channelResolver = new TestChannelResolver();
    router.setChannelResolver(channelResolver);
    Message<String> message = new GenericMessage<String>("test");
    router.handleMessage(message);
}
Also used : GenericMessage(org.springframework.messaging.support.GenericMessage) Message(org.springframework.messaging.Message) GenericMessage(org.springframework.messaging.support.GenericMessage) TestChannelResolver(org.springframework.integration.channel.TestChannelResolver) Test(org.junit.Test)

Example 18 with TestChannelResolver

use of org.springframework.integration.channel.TestChannelResolver in project spring-integration by spring-projects.

the class MethodInvokingRouterTests method multiChannelListResolutionByPayloadConfiguredByMethodReference.

@Test
public void multiChannelListResolutionByPayloadConfiguredByMethodReference() throws Exception {
    TestChannelResolver channelResolver = new TestChannelResolver();
    MultiChannelInstanceRoutingTestBean testBean = new MultiChannelInstanceRoutingTestBean(channelResolver);
    Method routingMethod = testBean.getClass().getMethod("routePayload", String.class);
    MethodInvokingRouter router = new MethodInvokingRouter(testBean, routingMethod);
    this.doTestMultiChannelListResolutionByPayload(router, channelResolver);
}
Also used : TestChannelResolver(org.springframework.integration.channel.TestChannelResolver) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 19 with TestChannelResolver

use of org.springframework.integration.channel.TestChannelResolver in project spring-integration by spring-projects.

the class MethodInvokingRouterTests method channelInstanceResolutionByPayloadConfiguredByMethodName.

@Test
public void channelInstanceResolutionByPayloadConfiguredByMethodName() {
    TestChannelResolver channelResolver = new TestChannelResolver();
    SingleChannelInstanceRoutingTestBean testBean = new SingleChannelInstanceRoutingTestBean(channelResolver);
    MethodInvokingRouter router = new MethodInvokingRouter(testBean, "routePayload");
    this.doTestChannelInstanceResolutionByPayload(router, channelResolver);
}
Also used : TestChannelResolver(org.springframework.integration.channel.TestChannelResolver) Test(org.junit.Test)

Example 20 with TestChannelResolver

use of org.springframework.integration.channel.TestChannelResolver in project spring-integration by spring-projects.

the class MethodInvokingRouterTests method channelInstanceResolutionByMessageConfiguredByMethodReference.

@Test
public void channelInstanceResolutionByMessageConfiguredByMethodReference() throws Exception {
    TestChannelResolver channelResolver = new TestChannelResolver();
    SingleChannelInstanceRoutingTestBean testBean = new SingleChannelInstanceRoutingTestBean(channelResolver);
    Method routingMethod = testBean.getClass().getMethod("routeMessage", Message.class);
    MethodInvokingRouter router = new MethodInvokingRouter(testBean, routingMethod);
    this.doTestChannelInstanceResolutionByMessage(router, channelResolver);
}
Also used : TestChannelResolver(org.springframework.integration.channel.TestChannelResolver) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

TestChannelResolver (org.springframework.integration.channel.TestChannelResolver)28 Test (org.junit.Test)27 Method (java.lang.reflect.Method)10 GenericMessage (org.springframework.messaging.support.GenericMessage)10 QueueChannel (org.springframework.integration.channel.QueueChannel)8 Message (org.springframework.messaging.Message)6 ServiceActivatingHandler (org.springframework.integration.handler.ServiceActivatingHandler)2 TestUtils (org.springframework.integration.test.util.TestUtils)2 ArrayList (java.util.ArrayList)1 MessageDeliveryException (org.springframework.messaging.MessageDeliveryException)1