INT-2275: any outbound-channel-adapter in <chain>

Add re-init logic for nested chains
Add logic about nested element for AbstractChannelAdapterParser
Refactor of DefaultOutboundChannelAdapterParser
Test for non-last nested chain with some outbound-channel-adapter
Improve XSD for chain-type
Manual outbound-channel-adapter ability for chain
Integration tests for all outbound-channel-adapter within <chain>
Remove redundant 'return-value-required' attribute from <stored-proc-outbound-channel-adapter>
Add support 'expectReply' for FileWritingMessageHandler

INT-2275 polishing & refactor FileOutbound*Parser

HttpRequestExecutingMessageHandlerTests polishing

INT-2275: polishing JavaDoc
This commit is contained in:
Artem Bilan
2012-01-03 23:26:16 +02:00
committed by Oleg Zhurakousky
parent 4d5b8d5be1
commit 45c429ee2b
58 changed files with 1302 additions and 318 deletions

View File

@@ -0,0 +1,40 @@
<?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-ip="http://www.springframework.org/schema/integration/ip"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="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/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="tcpIpUtils" class="org.springframework.integration.ip.util.SocketTestUtils" />
<int-ip:tcp-connection-factory
id="scf"
type="server"
so-timeout="60000"
deserializer=""
port="#{tcpIpUtils.findAvailableServerSocket(7000)}"/>
<int-ip:tcp-inbound-channel-adapter
connection-factory="scf"
channel="inbound"/>
<int:channel id="inbound">
<int:queue/>
</int:channel>
<int-ip:tcp-connection-factory
id="ccf"
type="client"
host="localhost"
port="#{scf.port}"
single-use="true"
so-timeout="60000"/>
<int:chain input-channel="tcpOutboundChannelAdapterWithinChain">
<int-ip:tcp-outbound-channel-adapter connection-factory="ccf"/>
</int:chain>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 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.
@@ -43,10 +43,15 @@ import javax.net.ServerSocketFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.serializer.DefaultDeserializer;
import org.springframework.core.serializer.DefaultSerializer;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.ip.IpHeaders;
import org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory;
import org.springframework.integration.ip.tcp.connection.HelloWorldInterceptorFactory;
import org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorFactory;
@@ -57,10 +62,12 @@ import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer
import org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSerializer;
import org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer;
import org.springframework.integration.ip.util.SocketTestUtils;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
/**
* @author Gary Russell
* @author Artem Bilan
* @since 2.0
*/
public class TcpSendingMessageHandlerTests {
@@ -1055,4 +1062,20 @@ public class TcpSendingMessageHandlerTests {
done.set(true);
}
@Test
public void testOutboundChannelAdapterWithinChain() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"TcpOutboundChannelAdapterWithinTests-context.xml", this.getClass());
AbstractConnectionFactory ccf = ctx.getBean("ccf", AbstractConnectionFactory.class);
// TODO Lifecycle#start() isn't invoked within chain...
ccf.start();
MessageChannel channelAdapterWithinChain = ctx.getBean("tcpOutboundChannelAdapterWithinChain", MessageChannel.class);
PollableChannel inbound = ctx.getBean("inbound", PollableChannel.class);
String testPayload = "Hello, world!";
channelAdapterWithinChain.send(new GenericMessage<String>(testPayload));
Message<?> m = inbound.receive(1000);
assertNotNull(m);
assertEquals(testPayload, new String((byte[]) m.getPayload()));
}
}

View File

@@ -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.
@@ -26,6 +26,7 @@ import java.util.Properties;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
@@ -49,6 +50,7 @@ import org.springframework.integration.test.util.TestUtils;
* received in the other context (and written back to the console).
*
* @author Gary Russell
* @author Artem Bilan
* @since 2.0
*/
public class UdpUnicastEndToEndTests implements Runnable {
@@ -67,7 +69,18 @@ public class UdpUnicastEndToEndTests implements Runnable {
private CountDownLatch readyToReceive = new CountDownLatch(1);
private static long hangAroundFor = 0;
private static long hangAroundFor = 10;
@Before
public void setup() {
this.testingIpText = null;
this.finalMessage = null;
this.sentFirst = new CountDownLatch(1);
this.firstReceived = new CountDownLatch(1);
this.doneProcessing = new CountDownLatch(1);
this.okToRun = true;
this.readyToReceive = new CountDownLatch(1);
}
@Test
public void runIt() throws Exception {
@@ -80,6 +93,17 @@ public class UdpUnicastEndToEndTests implements Runnable {
applicationContext.stop();
}
@Test
public void tesUudpOutboundChannelAdapterWithinChain() throws Exception {
UdpUnicastEndToEndTests launcher = new UdpUnicastEndToEndTests();
Thread t = new Thread(launcher);
t.start(); // launch the receiver
AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext(
"testIp-out-within-chain-context.xml", UdpUnicastEndToEndTests.class);
launcher.launchSender(applicationContext);
applicationContext.stop();
}
public void launchSender(ApplicationContext applicationContext) throws Exception {
ChannelResolver channelResolver = new BeanFactoryChannelResolver(applicationContext);
@@ -159,6 +183,7 @@ public class UdpUnicastEndToEndTests implements Runnable {
public static void main(String[] args) throws Exception {
hangAroundFor = 120000;
new UdpUnicastEndToEndTests().runIt();
new UdpUnicastEndToEndTests().tesUudpOutboundChannelAdapterWithinChain();
}
}

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xmlns:ip="http://www.springframework.org/schema/integration/ip"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
http://www.springframework.org/schema/integration/ip
http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
<stream:stdin-channel-adapter id="stdin" channel="outputChannel" >
<poller fixed-delay="100"/>
</stream:stdin-channel-adapter>
<channel id="inputChannel"/>
<channel id="outputChannel" />
<service-activator input-channel="inputChannel"
output-channel="outputChannel"
ref="testIp"
method="testIp"/>
<chain input-channel="outputChannel">
<ip:udp-outbound-channel-adapter host="localhost"
port="11111"
check-length="true"
acknowledge="true"
ack-host="localhost"
ack-port="22223"
ack-timeout="10000"/>
</chain>
<beans:import resource="testIp-common-context.xml" />
</beans:beans>