INT-2599 TCP Client Mode Corrections

1. Schema docs indicated client-mode is true by default, when
it is false.

2. Use IntegrationObjectSupport taskScheduler instead of
a field in the subclass.

INT-2599 polishing
This commit is contained in:
Gary Russell
2012-06-01 09:34:01 -04:00
committed by Oleg Zhurakousky
parent 6be155fbc5
commit 4be2e53d8f
11 changed files with 69 additions and 79 deletions

View File

@@ -430,7 +430,7 @@ public class ParserUnitTests {
assertEquals("ip:tcp-inbound-gateway", tcpInboundGateway2.getComponentType());
assertNull(dfa.getPropertyValue("errorChannel"));
assertEquals(Boolean.FALSE, dfa.getPropertyValue("isClientMode"));
assertNull(dfa.getPropertyValue("scheduler"));
assertNull(dfa.getPropertyValue("taskScheduler"));
assertEquals(60000L, dfa.getPropertyValue("retryInterval"));
}
@@ -542,7 +542,7 @@ public class ParserUnitTests {
assertSame(client1, dfa.getPropertyValue("clientConnectionFactory"));
assertEquals(25, dfa.getPropertyValue("order"));
assertEquals(Boolean.FALSE, dfa.getPropertyValue("isClientMode"));
assertNull(dfa.getPropertyValue("scheduler"));
assertNull(dfa.getPropertyValue("taskScheduler"));
assertEquals(60000L, dfa.getPropertyValue("retryInterval"));
}
@@ -559,7 +559,7 @@ public class ParserUnitTests {
assertSame(client1, dfa.getPropertyValue("clientConnectionFactory"));
assertNull(dfa.getPropertyValue("errorChannel"));
assertEquals(Boolean.FALSE, dfa.getPropertyValue("isClientMode"));
assertNull(dfa.getPropertyValue("scheduler"));
assertNull(dfa.getPropertyValue("taskScheduler"));
assertEquals(60000L, dfa.getPropertyValue("retryInterval"));
}
@@ -591,7 +591,7 @@ public class ParserUnitTests {
assertSame(cfC3, dfa.getPropertyValue("clientConnectionFactory"));
assertNull(dfa.getPropertyValue("serverConnectionFactory"));
assertEquals(Boolean.TRUE, dfa.getPropertyValue("isClientMode"));
assertSame(sched, dfa.getPropertyValue("scheduler"));
assertSame(sched, dfa.getPropertyValue("taskScheduler"));
assertEquals(123000L, dfa.getPropertyValue("retryInterval"));
}
@@ -601,7 +601,7 @@ public class ParserUnitTests {
assertSame(cfC4, dfa.getPropertyValue("clientConnectionFactory"));
assertNull(dfa.getPropertyValue("serverConnectionFactory"));
assertEquals(Boolean.TRUE, dfa.getPropertyValue("isClientMode"));
assertSame(sched, dfa.getPropertyValue("scheduler"));
assertSame(sched, dfa.getPropertyValue("taskScheduler"));
assertEquals(124000L, dfa.getPropertyValue("retryInterval"));
}
@@ -611,7 +611,7 @@ public class ParserUnitTests {
assertSame(cfC5, dfa.getPropertyValue("clientConnectionFactory"));
assertNull(dfa.getPropertyValue("serverConnectionFactory"));
assertEquals(Boolean.TRUE, dfa.getPropertyValue("isClientMode"));
assertSame(sched, dfa.getPropertyValue("scheduler"));
assertSame(sched, dfa.getPropertyValue("taskScheduler"));
assertEquals(125000L, dfa.getPropertyValue("retryInterval"));
}

View File

@@ -15,11 +15,15 @@
*/
package org.springframework.integration.ip.tcp;
import static org.junit.Assert.*;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -38,6 +42,9 @@ public class ClientModeControlBusTests {
@Autowired
TcpReceivingChannelAdapter tcpIn;
@Autowired
TaskScheduler taskScheduler; // default
@Test
public void test() throws Exception {
assertTrue(controlBus.boolResult("@tcpIn.isClientMode()"));
@@ -50,6 +57,7 @@ public class ClientModeControlBusTests {
}
}
assertTrue(controlBus.boolResult("@tcpIn.isRunning()"));
assertSame(taskScheduler, TestUtils.getPropertyValue(tcpIn, "taskScheduler"));
controlBus.voidResult("@tcpIn.retryConnection()");
}

View File

@@ -52,6 +52,7 @@ import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.channel.ChannelResolver;
import org.springframework.integration.test.util.SocketUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
public class TcpInboundGatewayTests {
@@ -152,6 +153,10 @@ public class TcpInboundGatewayTests {
}
});
assertTrue(latch1.await(10, TimeUnit.SECONDS));
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setPoolSize(1);
taskScheduler.initialize();
gateway.setTaskScheduler(taskScheduler);
gateway.start();
Message<?> message = channel.receive(10000);
assertNotNull(message);

View File

@@ -58,6 +58,7 @@ import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionF
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.test.util.SocketUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/**
* @author Gary Russell
@@ -126,6 +127,10 @@ public class TcpReceivingChannelAdapterTests {
adapter.afterPropertiesSet();
assertTrue(latch1.await(10, TimeUnit.SECONDS));
adapter.setRetryInterval(10000);
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setPoolSize(1);
taskScheduler.initialize();
adapter.setTaskScheduler(taskScheduler);
adapter.start();
Message<?> message = channel.receive(10000);
assertNotNull(message);

View File

@@ -65,6 +65,7 @@ import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.SocketUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
/**
* @author Gary Russell
@@ -173,6 +174,10 @@ public class TcpSendingMessageHandlerTests {
handler.setClientMode(true);
handler.setRetryInterval(10000);
handler.afterPropertiesSet();
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setPoolSize(1);
taskScheduler.initialize();
handler.setTaskScheduler(taskScheduler);
handler.start();
adapter.start();
handler.handleMessage(MessageBuilder.withPayload("Test").build());