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);
}

View File

@@ -35,7 +35,7 @@ public class SftpInboundOutboundSanitySample {
@Test
@Ignore
//@Ignore
public void testInbound() throws Exception{
File fileA = new File("local-test-dir/a.test");
if (fileA.exists()){
@@ -55,11 +55,12 @@ public class SftpInboundOutboundSanitySample {
}
new ClassPathXmlApplicationContext("SftpInboundReceiveSample-ignored.xml", this.getClass());
Thread.sleep(3000);
fileA = new File("local-test-dir/a.test");
fileB = new File("local-test-dir/b.test");
assertTrue(fileA.exists());
assertTrue(fileB.exists());
System.in.read();
//Thread.sleep(30000);
// fileA = new File("local-test-dir/a.test");
// fileB = new File("local-test-dir/b.test");
// assertTrue(fileA.exists());
// assertTrue(fileB.exists());
}
@Test

View File

@@ -11,7 +11,7 @@
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
<property name="host" value="192.168.1.155"/>
<property name="host" value="192.168.28.146"/>
<property name="privateKey" value="classpath:org/springframework/integration/sftp/config/sftp_rsa"/>
<property name="privateKeyPassphrase" value="springintegration"/>
<property name="port" value="22"/>
@@ -22,10 +22,10 @@
channel="receiveChannel"
session-factory="sftpSessionFactory"
local-directory="file:local-test-dir"
remote-directory="/home/ozhurakousky/Downloads"
remote-directory="/home/ozhurakousky/foo/bar"
auto-startup="true"
delete-remote-files="false"
filename-regex=".*\.gz$">
filename-regex=".*\.txt$">
<int:poller fixed-rate="3000" max-messages-per-poll="1" />
</int-sftp:inbound-channel-adapter>