INT-1223, INT-1226. The fix is temporary as we are considering refactoring of ARPMH and supporting classes (see INT-1227), however test cases are now in place to aid in refactoring efforts
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd"
|
||||
xmlns:int="http://www.springframework.org/schema/integration">
|
||||
|
||||
|
||||
<int:gateway id="gatewayA"
|
||||
service-interface="org.springframework.integration.gateway.MultipleEndpointGatewayTests$SampleGateway"
|
||||
default-request-channel="routingChannel"/>
|
||||
|
||||
<int:gateway id="gatewayB"
|
||||
service-interface="org.springframework.integration.gateway.MultipleEndpointGatewayTests$SampleGateway"
|
||||
default-request-channel="routingChannel"
|
||||
default-reply-channel="outputChannel"/>
|
||||
|
||||
<int:publish-subscribe-channel id="outputChannel"/>
|
||||
|
||||
<int:router input-channel="routingChannel" expression="payload"/>
|
||||
|
||||
<!-- gatewayNoDefaultReplyChannel -->
|
||||
<int:service-activator input-channel="echoAsMessageChannel" output-channel="echoAsMessageChannelA" ref="service" method="echoAsMessage"/>
|
||||
<int:service-activator input-channel="echoAsMessageChannelA" ref="service" method="echoAsMessage"/>
|
||||
<!-- gatewayWithDefaultReplyChannel -->
|
||||
<int:service-activator input-channel="echoAsMessageChannelIgnoreDefOutChannel" output-channel="echoAsMessageChannelIgnoreDefOutChannelB" ref="service" method="echoAsMessage"/>
|
||||
<int:service-activator input-channel="echoAsMessageChannelIgnoreDefOutChannelB" ref="service" method="echoAsMessage"/>
|
||||
<!-- gatewayWithReplySentBackToDefaultReplyChannel -->
|
||||
<int:service-activator input-channel="echoAsMessageChannelDefaultOutputChannel" output-channel="echoAsMessageChannelDefaultOutputChannelB" ref="service" method="echoAsMessage"/>
|
||||
<int:service-activator input-channel="echoAsMessageChannelDefaultOutputChannelB" output-channel="outputChannel" ref="service" method="echoAsMessage"/>
|
||||
|
||||
|
||||
<bean id="service" class="org.springframework.integration.gateway.MultipleEndpointGatewayTests$SampleEchoService"/>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.integration.gateway;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class MultipleEndpointGatewayTests {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("gatewayA")
|
||||
private SampleGateway gatewayA;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("gatewayB")
|
||||
private SampleGateway gatewayB;
|
||||
|
||||
@Test
|
||||
public void gatewayNoDefaultReplyChannel(){
|
||||
gatewayA.echo("echoAsMessageChannel");
|
||||
// there is nothing to assert. Successful execution of the above is all we care in this test
|
||||
}
|
||||
@Test
|
||||
public void gatewayWithDefaultReplyChannel(){
|
||||
gatewayB.echo("echoAsMessageChannelIgnoreDefOutChannel");
|
||||
// there is nothing to assert. Successful execution of the above is all we care in this test
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gatewayWithReplySentBackToDefaultReplyChannel(){
|
||||
gatewayB.echo("echoAsMessageChannelDefaultOutputChannel");
|
||||
// there is nothing to assert. Successful execution of the above is all we care in this test
|
||||
}
|
||||
|
||||
public static interface SampleGateway{
|
||||
public Object echo(Object value);
|
||||
}
|
||||
|
||||
public static class SampleEchoService {
|
||||
public Object echo(Object value){
|
||||
return "R:" + value;
|
||||
}
|
||||
public Message echoAsMessage(Object value){
|
||||
return MessageBuilder.withPayload("R:" + value).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user