INT-1745 added support for error-channel to in-the-chain gateways
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<int:channel id="errorChannelA"/>
|
||||
|
||||
<int:service-activator input-channel="errorChannelA" expression="'ERROR from errorChannelA'"/>
|
||||
|
||||
<int:channel id="errorChannelB"/>
|
||||
|
||||
<int:service-activator input-channel="errorChannelB" expression="'ERROR from errorChannelB'"/>
|
||||
|
||||
|
||||
<int:gateway id="testGateway"
|
||||
service-interface="org.springframework.integration.gateway.InnerGatewayWithChainTests.TestGateway"
|
||||
default-request-channel="requestChannelA"
|
||||
error-channel="errorChannelA"/>
|
||||
|
||||
<int:chain input-channel="requestChannelA">
|
||||
<int:service-activator expression="1/(payload-5)"/>
|
||||
<int:gateway request-channel="requestChannelB" error-channel="errorChannelB"/>
|
||||
</int:chain>
|
||||
|
||||
<int:service-activator input-channel="requestChannelB" expression="10/payload"/>
|
||||
</beans>
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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 static junit.framework.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class InnerGatewayWithChainTests {
|
||||
|
||||
@Autowired
|
||||
private TestGateway testGateway;
|
||||
|
||||
@Test
|
||||
public void testExceptionHandledByMainGateway(){
|
||||
String reply = testGateway.echo(5);
|
||||
assertEquals("ERROR from errorChannelA", reply);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExceptionHandledByInnerGateway(){
|
||||
String reply = testGateway.echo(0);
|
||||
assertEquals("ERROR from errorChannelB", reply);
|
||||
}
|
||||
|
||||
public static interface TestGateway{
|
||||
public String echo(int value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user