added more test to InnerGatewayWithChainTests

This commit is contained in:
Oleg Zhurakousky
2011-02-02 19:55:46 -05:00
parent 0cb10b5942
commit f6061346d3
4 changed files with 52 additions and 13 deletions

View File

@@ -14,7 +14,7 @@
<int:service-activator input-channel="errorChannelB" expression="'ERROR from errorChannelB'"/>
<int:gateway id="testGateway"
<int:gateway id="testGatewayWithErrorChannelA"
service-interface="org.springframework.integration.gateway.InnerGatewayWithChainTests.TestGateway"
default-request-channel="requestChannelA"
error-channel="errorChannelA"/>
@@ -24,5 +24,24 @@
<int:gateway request-channel="requestChannelB" error-channel="errorChannelB"/>
</int:chain>
<int:gateway id="testGatewayWithErrorChannelAA"
service-interface="org.springframework.integration.gateway.InnerGatewayWithChainTests.TestGateway"
default-request-channel="requestChannelAA"
error-channel="errorChannelA"/>
<int:chain input-channel="requestChannelAA">
<int:service-activator expression="1/(payload-5)"/>
<int:gateway request-channel="requestChannelB"/>
</int:chain>
<int:gateway id="testGatewayWithNoErrorChannelAAA"
service-interface="org.springframework.integration.gateway.InnerGatewayWithChainTests.TestGateway"
default-request-channel="requestChannelAAA"/>
<int:chain input-channel="requestChannelAAA">
<int:service-activator expression="1/(payload-5)"/>
<int:gateway request-channel="requestChannelB"/>
</int:chain>
<int:service-activator input-channel="requestChannelB" expression="10/payload"/>
</beans>

View File

@@ -21,6 +21,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.MessageHandlingException;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -33,20 +34,38 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class InnerGatewayWithChainTests {
@Autowired
private TestGateway testGateway;
private TestGateway testGatewayWithErrorChannelA;
@Autowired
private TestGateway testGatewayWithErrorChannelAA;
@Autowired
private TestGateway testGatewayWithNoErrorChannelAAA;
@Test
public void testExceptionHandledByMainGateway(){
String reply = testGateway.echo(5);
String reply = testGatewayWithErrorChannelA.echo(5);
assertEquals("ERROR from errorChannelA", reply);
}
@Test
public void testExceptionHandledByMainGatewayNoErrorChannelInChain(){
String reply = testGatewayWithErrorChannelAA.echo(0);
assertEquals("ERROR from errorChannelA", reply);
}
@Test
public void testExceptionHandledByInnerGateway(){
String reply = testGateway.echo(0);
String reply = testGatewayWithErrorChannelA.echo(0);
assertEquals("ERROR from errorChannelB", reply);
}
// if no error channels explicitly defined exception is rethrown
@Test(expected=MessageHandlingException.class)
public void testGatewaysNoErrorChannel(){
testGatewayWithNoErrorChannelAAA.echo(0);
}
public static interface TestGateway{
public String echo(int value);
}