INT-1029: Support for outbound-gateways in chain
XSD refactoring: remove use="required" from 'request-channel' attribute of all 'outbound-gateways' Tests for all 'outbound-gateways' inside the <chain>
This commit is contained in:
committed by
Oleg Zhurakousky
parent
c3860e14b7
commit
5bc41bc60b
@@ -3,29 +3,47 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:ip="http://www.springframework.org/schema/integration/ip"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration/ip
|
||||
http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
|
||||
<import resource="TcpConfigInboundGatewayTests-context.xml" />
|
||||
|
||||
<ip:tcp-outbound-gateway id="tcpOutGateway"
|
||||
|
||||
<ip:tcp-outbound-gateway id="tcpOutGateway"
|
||||
connection-factory="crLfClient"
|
||||
request-channel="requestChannel"
|
||||
reply-channel="replyChannel"
|
||||
/>
|
||||
|
||||
<ip:tcp-outbound-gateway id="tcpOutGatewayNio"
|
||||
<ip:tcp-outbound-gateway id="tcpOutGatewayNio"
|
||||
connection-factory="crLfClientNio"
|
||||
request-channel="requestChannelNio"
|
||||
reply-channel="replyChannel"
|
||||
/>
|
||||
|
||||
<ip:tcp-connection-factory id="crLfServer2"
|
||||
type="server"
|
||||
port="#{tcpIpUtils.findAvailableServerSocket(7400)}"
|
||||
serializer="crLfSerializer"
|
||||
deserializer="crLfSerializer"/>
|
||||
|
||||
<ip:tcp-connection-factory id="crLfClient2"
|
||||
type="client"
|
||||
host="localhost"
|
||||
port="#{crLfServer2.port}"
|
||||
serializer="crLfSerializer"
|
||||
deserializer="crLfSerializer"/>
|
||||
|
||||
|
||||
<int:chain input-channel="tcpOutboundGatewayInsideChain" output-channel="replyChannel">
|
||||
<ip:tcp-outbound-gateway connection-factory="crLfClient2"/>
|
||||
</int:chain>
|
||||
|
||||
<int:channel id="replyChannel" >
|
||||
<int:queue />
|
||||
</int:channel>
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -25,9 +25,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -35,6 +37,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -45,50 +48,50 @@ public class TcpConfigOutboundGatewayTests {
|
||||
|
||||
@Autowired
|
||||
AbstractApplicationContext ctx;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="crLfServer")
|
||||
AbstractServerConnectionFactory crLfServer;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="stxEtxServer")
|
||||
AbstractServerConnectionFactory stxEtxServer;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="lengthHeaderServer")
|
||||
AbstractServerConnectionFactory lengthHeaderServer;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="javaSerialServer")
|
||||
AbstractServerConnectionFactory javaSerialServer;
|
||||
|
||||
|
||||
@Autowired @Qualifier(value="crLfClient")
|
||||
AbstractClientConnectionFactory crLfClient;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="stxEtxClient")
|
||||
AbstractClientConnectionFactory stxEtxClient;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="lengthHeaderClient")
|
||||
AbstractClientConnectionFactory lengthHeaderClient;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="javaSerialClient")
|
||||
AbstractClientConnectionFactory javaSerialClient;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(value="gatewayCrLf")
|
||||
TcpInboundGateway gatewayCrLf;
|
||||
|
||||
|
||||
// @Autowired
|
||||
// @Qualifier("gatewayCrLf")
|
||||
// private TcpInboundGateway inboundGatewayCrLf;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("gatewayStxEtx")
|
||||
private TcpInboundGateway inboundGatewayStxEtx;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier("gatewayLength")
|
||||
private TcpInboundGateway inboundGatewayLength;
|
||||
@@ -109,6 +112,12 @@ public class TcpConfigOutboundGatewayTests {
|
||||
@Qualifier("requestChannelNio")
|
||||
SubscribableChannel requestChannelNio;
|
||||
|
||||
@Autowired
|
||||
AbstractClientConnectionFactory crLfClient2;
|
||||
|
||||
@Autowired
|
||||
MessageChannel tcpOutboundGatewayInsideChain;
|
||||
|
||||
@Test
|
||||
public void testOutboundCrLf() throws Exception {
|
||||
testOutboundUsingConfig();
|
||||
@@ -127,7 +136,7 @@ public class TcpConfigOutboundGatewayTests {
|
||||
throw new Exception("Gateway failed to listen");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,6 +175,17 @@ public class TcpConfigOutboundGatewayTests {
|
||||
assertEquals("echo:test", new String(bytes));
|
||||
}
|
||||
|
||||
@Test //INT-1029
|
||||
public void testOutboundInsideChain() throws Exception {
|
||||
// TODO Lifecycle#start() isn't invoked within chain...
|
||||
crLfClient2.start();
|
||||
|
||||
tcpOutboundGatewayInsideChain.send(MessageBuilder.withPayload("test").build());
|
||||
byte[] bytes = (byte[]) replyChannel.receive().getPayload();
|
||||
assertEquals("echo:test", new String(bytes).trim());
|
||||
}
|
||||
|
||||
|
||||
private void testOutboundUsingConfig() {
|
||||
Message<String> message = MessageBuilder.withPayload("test").build();
|
||||
requestChannel.send(message);
|
||||
@@ -186,7 +206,7 @@ public class TcpConfigOutboundGatewayTests {
|
||||
staticContext = ctx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void shutDown() {
|
||||
staticContext.close();
|
||||
|
||||
@@ -1064,7 +1064,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
@Test
|
||||
public void testOutboundChannelAdapterWithinChain() throws Exception {
|
||||
ApplicationContext ctx = new ClassPathXmlApplicationContext(
|
||||
"TcpOutboundChannelAdapterWithinTests-context.xml", this.getClass());
|
||||
"TcpOutboundChannelAdapterWithinChainTests-context.xml", this.getClass());
|
||||
AbstractConnectionFactory ccf = ctx.getBean("ccf", AbstractConnectionFactory.class);
|
||||
// TODO Lifecycle#start() isn't invoked within chain...
|
||||
ccf.start();
|
||||
|
||||
Reference in New Issue
Block a user