renamed SocketUtils in src/test to SocketTestUtils
This commit is contained in:
@@ -36,14 +36,14 @@ import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.support.channel.ChannelResolver;
|
||||
|
||||
public class TcpInboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testNetSingle() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
scf.setSingleUse(true);
|
||||
TcpInboundGateway gateway = new TcpInboundGateway();
|
||||
@@ -78,7 +78,7 @@ public class TcpInboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testNetNotSingle() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
scf.setSingleUse(false);
|
||||
TcpInboundGateway gateway = new TcpInboundGateway();
|
||||
@@ -108,7 +108,7 @@ public class TcpInboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testNioSingle() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
scf.setSingleUse(true);
|
||||
TcpInboundGateway gateway = new TcpInboundGateway();
|
||||
@@ -146,7 +146,7 @@ public class TcpInboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testNioNotSingle() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
scf.setSingleUse(false);
|
||||
TcpInboundGateway gateway = new TcpInboundGateway();
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.springframework.integration.MessageTimeoutException;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.connection.TcpNetClientConnectionFactory;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ public class TcpOutboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testGoodNetSingle() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractConnectionFactory ccf = new TcpNetClientConnectionFactory("localhost", port);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
@@ -110,7 +110,7 @@ public class TcpOutboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testGoodNetMultiplex() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -161,7 +161,7 @@ public class TcpOutboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void testGoodNetTimeout() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.springframework.integration.ip.tcp.connection.TcpConnectionIntercepto
|
||||
import org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
@@ -57,7 +57,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNet() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -87,7 +87,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNio() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
TcpNioServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -122,7 +122,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetShared() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -160,7 +160,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioShared() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
TcpNioServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -198,7 +198,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetSingleNoOutbound() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -234,7 +234,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioSingleNoOutbound() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
TcpNioServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -280,7 +280,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetSingleShared() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -321,7 +321,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioSingleShared() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
TcpNioServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -362,7 +362,7 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioSingleSharedMany() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
TcpNioServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
scf.setSerializer(serializer);
|
||||
@@ -406,42 +406,42 @@ public class TcpReceivingChannelAdapterTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetInterceptors() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
interceptorsGuts(port, scf);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newTestNetSingleNoOutboundInterceptors() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
singleNoOutboundInterceptorsGuts(port, scf);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newTestNetSingleSharedInterceptors() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(port);
|
||||
singleSharedInterceptorsGuts(port, scf);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newTestNioInterceptors() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
interceptorsGuts(port, scf);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newTestNioSingleNoOutboundInterceptors() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
singleNoOutboundInterceptorsGuts(port, scf);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newTestNioSingleSharedInterceptors() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
AbstractServerConnectionFactory scf = new TcpNioServerConnectionFactory(port);
|
||||
singleSharedInterceptorsGuts(port, scf);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionF
|
||||
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.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetCrLf() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -126,7 +126,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioCrLf() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -178,7 +178,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetStxEtx() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -227,7 +227,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioStxEtx() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -279,7 +279,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetLength() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -331,7 +331,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioLength() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -386,7 +386,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetSerial() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -434,7 +434,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioSerial() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -485,7 +485,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetSingleUseNoInbound() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
@@ -526,7 +526,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioSingleUseNoInbound() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
@@ -567,7 +567,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetSingleUseWithInbound() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
@@ -622,7 +622,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioSingleUseWithInbound() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
@@ -677,7 +677,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioSingleUseWithInboundMany() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
@@ -743,7 +743,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetNegotiate() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -810,7 +810,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioNegotiate() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -875,7 +875,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNetNegotiateSingleNoListen() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
@@ -932,7 +932,7 @@ public class TcpSendingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void newTestNioNegotiateSingleNoListen() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicBoolean done = new AtomicBoolean();
|
||||
Executors.newSingleThreadExecutor().execute(new Runnable() {
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerial
|
||||
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.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
@@ -79,7 +79,7 @@ public class TcpNioConnectionReadTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testReadLength() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ByteArrayLengthHeaderSerializer serializer = new ByteArrayLengthHeaderSerializer();
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
@@ -93,14 +93,14 @@ public class TcpNioConnectionReadTests {
|
||||
|
||||
// Fire up the sender.
|
||||
|
||||
SocketUtils.testSendLength(port, latch);
|
||||
SocketTestUtils.testSendLength(port, latch);
|
||||
latch.countDown();
|
||||
assertTrue(semaphore.tryAcquire(1, 10000, TimeUnit.MILLISECONDS));
|
||||
assertTrue(semaphore.tryAcquire(1, 10000, TimeUnit.MILLISECONDS));
|
||||
assertEquals("Did not receive data", 2, responses.size());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(((Message<byte[]>) responses.get(0)).getPayload()));
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(((Message<byte[]>) responses.get(1)).getPayload()));
|
||||
scf.close();
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class TcpNioConnectionReadTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testFragmented() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ByteArrayLengthHeaderSerializer serializer = new ByteArrayLengthHeaderSerializer();
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
@@ -128,7 +128,7 @@ public class TcpNioConnectionReadTests {
|
||||
int howMany = 2;
|
||||
scf.setPoolSize(howMany + 5);
|
||||
// Fire up the sender.
|
||||
SocketUtils.testSendFragmented(port, howMany, false);
|
||||
SocketTestUtils.testSendFragmented(port, howMany, false);
|
||||
assertTrue(semaphore.tryAcquire(howMany, 20000, TimeUnit.MILLISECONDS));
|
||||
assertEquals("Expected", howMany, responses.size());
|
||||
for (int i = 0; i < howMany; i++) {
|
||||
@@ -144,7 +144,7 @@ public class TcpNioConnectionReadTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testReadStxEtx() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ByteArrayStxEtxSerializer serializer = new ByteArrayStxEtxSerializer();
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
@@ -158,14 +158,14 @@ public class TcpNioConnectionReadTests {
|
||||
|
||||
// Fire up the sender.
|
||||
|
||||
SocketUtils.testSendStxEtx(port, latch);
|
||||
SocketTestUtils.testSendStxEtx(port, latch);
|
||||
latch.countDown();
|
||||
assertTrue(semaphore.tryAcquire(1, 10000, TimeUnit.MILLISECONDS));
|
||||
assertTrue(semaphore.tryAcquire(1, 10000, TimeUnit.MILLISECONDS));
|
||||
assertEquals("Did not receive data", 2, responses.size());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(((Message<byte[]>) responses.get(0)).getPayload()));
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(((Message<byte[]>) responses.get(1)).getPayload()));
|
||||
scf.close();
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class TcpNioConnectionReadTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testReadCrLf() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
@@ -190,14 +190,14 @@ public class TcpNioConnectionReadTests {
|
||||
|
||||
// Fire up the sender.
|
||||
|
||||
SocketUtils.testSendCrLf(port, latch);
|
||||
SocketTestUtils.testSendCrLf(port, latch);
|
||||
latch.countDown();
|
||||
assertTrue(semaphore.tryAcquire(1, 10000, TimeUnit.MILLISECONDS));
|
||||
assertTrue(semaphore.tryAcquire(1, 10000, TimeUnit.MILLISECONDS));
|
||||
assertEquals("Did not receive data", 2, responses.size());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(((Message<byte[]>) responses.get(0)).getPayload()));
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(((Message<byte[]>) responses.get(1)).getPayload()));
|
||||
scf.close();
|
||||
}
|
||||
@@ -207,7 +207,7 @@ public class TcpNioConnectionReadTests {
|
||||
*/
|
||||
@Test
|
||||
public void testReadLengthOverflow() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ByteArrayLengthHeaderSerializer serializer = new ByteArrayLengthHeaderSerializer();
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
@@ -232,7 +232,7 @@ public class TcpNioConnectionReadTests {
|
||||
|
||||
// Fire up the sender.
|
||||
|
||||
SocketUtils.testSendLengthOverflow(port);
|
||||
SocketTestUtils.testSendLengthOverflow(port);
|
||||
whileOpen(semaphore, added);
|
||||
assertEquals(1, added.size());
|
||||
assertTrue(removed.size() > 0);
|
||||
@@ -244,7 +244,7 @@ public class TcpNioConnectionReadTests {
|
||||
*/
|
||||
@Test
|
||||
public void testReadStxEtxOverflow() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ByteArrayStxEtxSerializer serializer = new ByteArrayStxEtxSerializer();
|
||||
serializer.setMaxMessageSize(1024);
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
@@ -270,7 +270,7 @@ public class TcpNioConnectionReadTests {
|
||||
|
||||
// Fire up the sender.
|
||||
|
||||
SocketUtils.testSendStxEtxOverflow(port);
|
||||
SocketTestUtils.testSendStxEtxOverflow(port);
|
||||
whileOpen(semaphore, added);
|
||||
assertEquals(1, added.size());
|
||||
assertTrue(removed.size() > 0);
|
||||
@@ -282,7 +282,7 @@ public class TcpNioConnectionReadTests {
|
||||
*/
|
||||
@Test
|
||||
public void testReadCrLfOverflow() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
serializer.setMaxMessageSize(1024);
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
@@ -308,7 +308,7 @@ public class TcpNioConnectionReadTests {
|
||||
|
||||
// Fire up the sender.
|
||||
|
||||
SocketUtils.testSendCrLfOverflow(port);
|
||||
SocketTestUtils.testSendCrLfOverflow(port);
|
||||
whileOpen(semaphore, added);
|
||||
assertEquals(1, added.size());
|
||||
assertTrue(removed.size() > 0);
|
||||
@@ -322,7 +322,7 @@ public class TcpNioConnectionReadTests {
|
||||
*/
|
||||
@Test
|
||||
public void testCloseCleanupNoData() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
serializer.setMaxMessageSize(1024);
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
@@ -391,7 +391,7 @@ public class TcpNioConnectionReadTests {
|
||||
private void testClosureMidMessageGuts(AbstractByteArraySerializer serializer, String shortMessage)
|
||||
throws Exception, IOException, UnknownHostException,
|
||||
InterruptedException {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final List<Message<?>> responses = new ArrayList<Message<?>>();
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final List<TcpConnection> added = new ArrayList<TcpConnection>();
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import javax.net.ServerSocketFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class TcpNioConnectionTests {
|
||||
|
||||
@Test
|
||||
public void testWriteTimeout() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
TcpNioClientConnectionFactory factory = new TcpNioClientConnectionFactory("localhost", port);
|
||||
factory.setSoTimeout(1000);
|
||||
factory.start();
|
||||
@@ -74,7 +74,7 @@ public class TcpNioConnectionTests {
|
||||
|
||||
@Test
|
||||
public void testReadTimeout() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
TcpNioClientConnectionFactory factory = new TcpNioClientConnectionFactory("localhost", port);
|
||||
factory.setSoTimeout(1000);
|
||||
factory.start();
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerial
|
||||
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.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ public class TcpNioConnectionWriteTests {
|
||||
|
||||
@Test
|
||||
public void testWriteLengthHeader() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port);
|
||||
@@ -87,7 +87,7 @@ public class TcpNioConnectionWriteTests {
|
||||
|
||||
@Test
|
||||
public void testWriteStxEtx() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port);
|
||||
@@ -120,7 +120,7 @@ public class TcpNioConnectionWriteTests {
|
||||
|
||||
@Test
|
||||
public void testWriteCrLf() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port);
|
||||
@@ -153,7 +153,7 @@ public class TcpNioConnectionWriteTests {
|
||||
|
||||
@Test
|
||||
public void testWriteLengthHeaderDirect() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port);
|
||||
@@ -186,7 +186,7 @@ public class TcpNioConnectionWriteTests {
|
||||
|
||||
@Test
|
||||
public void testWriteStxEtxDirect() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port);
|
||||
@@ -220,7 +220,7 @@ public class TcpNioConnectionWriteTests {
|
||||
|
||||
@Test
|
||||
public void testWriteCrLfDirect() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port);
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.net.ServerSocketFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.serializer.DefaultDeserializer;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
@@ -38,80 +38,80 @@ public class DeserializationTests {
|
||||
|
||||
@Test
|
||||
public void testReadLength() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendLength(port, null);
|
||||
SocketTestUtils.testSendLength(port, null);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(5000);
|
||||
ByteArrayLengthHeaderSerializer serializer = new ByteArrayLengthHeaderSerializer();
|
||||
byte[] out = serializer.deserialize(socket.getInputStream());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(out));
|
||||
out = serializer.deserialize(socket.getInputStream());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(out));
|
||||
server.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadStxEtx() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendStxEtx(port, null);
|
||||
SocketTestUtils.testSendStxEtx(port, null);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(5000);
|
||||
ByteArrayStxEtxSerializer serializer = new ByteArrayStxEtxSerializer();
|
||||
byte[] out = serializer.deserialize(socket.getInputStream());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(out));
|
||||
out = serializer.deserialize(socket.getInputStream());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(out));
|
||||
server.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadCrLf() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendCrLf(port, null);
|
||||
SocketTestUtils.testSendCrLf(port, null);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(5000);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
byte[] out = serializer.deserialize(socket.getInputStream());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(out));
|
||||
out = serializer.deserialize(socket.getInputStream());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING + SocketUtils.TEST_STRING,
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING + SocketTestUtils.TEST_STRING,
|
||||
new String(out));
|
||||
server.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadSerialized() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendSerialized(port);
|
||||
SocketTestUtils.testSendSerialized(port);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(5000);
|
||||
DefaultDeserializer deserializer = new DefaultDeserializer();
|
||||
Object out = deserializer.deserialize(socket.getInputStream());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING, out);
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING, out);
|
||||
out = deserializer.deserialize(socket.getInputStream());
|
||||
assertEquals("Data", SocketUtils.TEST_STRING, out);
|
||||
assertEquals("Data", SocketTestUtils.TEST_STRING, out);
|
||||
server.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadLengthOverflow() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendLengthOverflow(port);
|
||||
SocketTestUtils.testSendLengthOverflow(port);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(5000);
|
||||
ByteArrayLengthHeaderSerializer serializer = new ByteArrayLengthHeaderSerializer();
|
||||
@@ -129,10 +129,10 @@ public class DeserializationTests {
|
||||
|
||||
@Test
|
||||
public void testReadStxEtxTimeout() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendStxEtxOverflow(port);
|
||||
SocketTestUtils.testSendStxEtxOverflow(port);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(500);
|
||||
ByteArrayStxEtxSerializer serializer = new ByteArrayStxEtxSerializer();
|
||||
@@ -150,10 +150,10 @@ public class DeserializationTests {
|
||||
|
||||
@Test
|
||||
public void testReadStxEtxOverflow() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendStxEtxOverflow(port);
|
||||
SocketTestUtils.testSendStxEtxOverflow(port);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(5000);
|
||||
ByteArrayStxEtxSerializer serializer = new ByteArrayStxEtxSerializer();
|
||||
@@ -172,10 +172,10 @@ public class DeserializationTests {
|
||||
|
||||
@Test
|
||||
public void testReadCrLfTimeout() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendCrLfOverflow(port);
|
||||
SocketTestUtils.testSendCrLfOverflow(port);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(500);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
@@ -193,10 +193,10 @@ public class DeserializationTests {
|
||||
|
||||
@Test
|
||||
public void testReadCrLfOverflow() throws Exception {
|
||||
int port = SocketUtils.findAvailableServerSocket();
|
||||
int port = SocketTestUtils.findAvailableServerSocket();
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
SocketUtils.testSendCrLfOverflow(port);
|
||||
SocketTestUtils.testSendCrLfOverflow(port);
|
||||
Socket socket = server.accept();
|
||||
socket.setSoTimeout(5000);
|
||||
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
|
||||
|
||||
@@ -31,7 +31,7 @@ import javax.net.SocketFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.serializer.DefaultSerializer;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
@@ -41,7 +41,7 @@ public class SerializationTests {
|
||||
|
||||
@Test
|
||||
public void testWriteLengthHeader() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
@@ -74,7 +74,7 @@ public class SerializationTests {
|
||||
|
||||
@Test
|
||||
public void testWriteStxEtx() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
@@ -107,7 +107,7 @@ public class SerializationTests {
|
||||
|
||||
@Test
|
||||
public void testWriteCrLf() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
@@ -140,7 +140,7 @@ public class SerializationTests {
|
||||
|
||||
@Test
|
||||
public void testWriteSerialized() throws Exception {
|
||||
final int port = SocketUtils.findAvailableServerSocket();
|
||||
final int port = SocketTestUtils.findAvailableServerSocket();
|
||||
final String testString = "abcdef";
|
||||
ServerSocket server = ServerSocketFactory.getDefault().createServerSocket(port);
|
||||
server.setSoTimeout(10000);
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.ip.IpHeaders;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ public class DatagramPacketSendingHandlerTests {
|
||||
|
||||
@Test
|
||||
public void verifySend() throws Exception {
|
||||
final int testPort = SocketUtils.findAvailableUdpSocket();
|
||||
final int testPort = SocketTestUtils.findAvailableUdpSocket();
|
||||
byte[] buffer = new byte[8];
|
||||
final DatagramPacket receivedPacket = new DatagramPacket(buffer, buffer.length);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
@@ -82,8 +82,8 @@ public class DatagramPacketSendingHandlerTests {
|
||||
|
||||
@Test
|
||||
public void verifySendWithAck() throws Exception {
|
||||
final int testPort = SocketUtils.findAvailableUdpSocket();
|
||||
final int ackPort = SocketUtils.findAvailableUdpSocket(testPort + 1);
|
||||
final int testPort = SocketTestUtils.findAvailableUdpSocket();
|
||||
final int ackPort = SocketTestUtils.findAvailableUdpSocket(testPort + 1);
|
||||
byte[] buffer = new byte[1000];
|
||||
final DatagramPacket receivedPacket = new DatagramPacket(buffer, buffer.length);
|
||||
final CountDownLatch latch1 = new CountDownLatch(1);
|
||||
@@ -133,7 +133,7 @@ public class DatagramPacketSendingHandlerTests {
|
||||
@Test
|
||||
@Ignore
|
||||
public void verifySendMulticast() throws Exception {
|
||||
final int testPort = SocketUtils.findAvailableUdpSocket();
|
||||
final int testPort = SocketTestUtils.findAvailableUdpSocket();
|
||||
final String multicastAddress = "225.6.7.8";
|
||||
final String payload = "foo";
|
||||
final CountDownLatch latch1 = new CountDownLatch(2);
|
||||
@@ -184,8 +184,8 @@ public class DatagramPacketSendingHandlerTests {
|
||||
@Test
|
||||
@Ignore
|
||||
public void verifySendMulticastWithAcks() throws Exception {
|
||||
final int testPort = SocketUtils.findAvailableUdpSocket();
|
||||
final int ackPort = SocketUtils.findAvailableUdpSocket(testPort + 1);
|
||||
final int testPort = SocketTestUtils.findAvailableUdpSocket();
|
||||
final int ackPort = SocketTestUtils.findAvailableUdpSocket(testPort + 1);
|
||||
final String multicastAddress = "225.6.7.8";
|
||||
final String payload = "foobar";
|
||||
final CountDownLatch latch1 = new CountDownLatch(2);
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class MultiClientTests {
|
||||
public void testNoAck() throws Exception {
|
||||
final String payload = largePayload(1000);
|
||||
final UnicastReceivingChannelAdapter adapter =
|
||||
new UnicastReceivingChannelAdapter(SocketUtils.findAvailableUdpSocket());
|
||||
new UnicastReceivingChannelAdapter(SocketTestUtils.findAvailableUdpSocket());
|
||||
int drivers = 10;
|
||||
adapter.setPoolSize(drivers);
|
||||
QueueChannel queue = new QueueChannel(drivers * 3);
|
||||
@@ -58,7 +58,7 @@ public class MultiClientTests {
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
adapter.start();
|
||||
final QueueChannel queueIn = new QueueChannel(1000);
|
||||
SocketUtils.waitListening(adapter);
|
||||
SocketTestUtils.waitListening(adapter);
|
||||
for (int i = 0; i < drivers; i++) {
|
||||
Thread t = new Thread( new Runnable() {
|
||||
public void run() {
|
||||
@@ -89,7 +89,7 @@ public class MultiClientTests {
|
||||
Thread.sleep(1000);
|
||||
final String payload = largePayload(1000);
|
||||
final UnicastReceivingChannelAdapter adapter =
|
||||
new UnicastReceivingChannelAdapter(SocketUtils.findAvailableUdpSocket(), false);
|
||||
new UnicastReceivingChannelAdapter(SocketTestUtils.findAvailableUdpSocket(), false);
|
||||
int drivers = 5;
|
||||
adapter.setPoolSize(drivers);
|
||||
QueueChannel queue = new QueueChannel(drivers * 3);
|
||||
@@ -99,7 +99,7 @@ public class MultiClientTests {
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
adapter.start();
|
||||
final QueueChannel queueIn = new QueueChannel(1000);
|
||||
SocketUtils.waitListening(adapter);
|
||||
SocketTestUtils.waitListening(adapter);
|
||||
for (int i = 0; i < drivers; i++) {
|
||||
final int j = i;
|
||||
Thread t = new Thread( new Runnable() {
|
||||
@@ -107,7 +107,7 @@ public class MultiClientTests {
|
||||
UnicastSendingMessageHandler sender = new UnicastSendingMessageHandler(
|
||||
"localhost", adapter.getPort(),
|
||||
false, true, "localhost",
|
||||
SocketUtils.findAvailableUdpSocket(adapter.getPort() + j + 1000),
|
||||
SocketTestUtils.findAvailableUdpSocket(adapter.getPort() + j + 1000),
|
||||
10000);
|
||||
while (true) {
|
||||
Message<?> message = queueIn.receive();
|
||||
@@ -134,7 +134,7 @@ public class MultiClientTests {
|
||||
Thread.sleep(1000);
|
||||
final String payload = largePayload(1000);
|
||||
final UnicastReceivingChannelAdapter adapter =
|
||||
new UnicastReceivingChannelAdapter(SocketUtils.findAvailableUdpSocket(), true);
|
||||
new UnicastReceivingChannelAdapter(SocketTestUtils.findAvailableUdpSocket(), true);
|
||||
int drivers = 10;
|
||||
adapter.setPoolSize(drivers);
|
||||
QueueChannel queue = new QueueChannel(drivers * 3);
|
||||
@@ -144,7 +144,7 @@ public class MultiClientTests {
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
adapter.start();
|
||||
final QueueChannel queueIn = new QueueChannel(1000);
|
||||
SocketUtils.waitListening(adapter);
|
||||
SocketTestUtils.waitListening(adapter);
|
||||
for (int i = 0; i < drivers; i++) {
|
||||
final int j = i;
|
||||
Thread t = new Thread( new Runnable() {
|
||||
@@ -152,7 +152,7 @@ public class MultiClientTests {
|
||||
UnicastSendingMessageHandler sender = new UnicastSendingMessageHandler(
|
||||
"localhost", adapter.getPort(),
|
||||
true, true, "localhost",
|
||||
SocketUtils.findAvailableUdpSocket(adapter.getPort() + j + 1100),
|
||||
SocketTestUtils.findAvailableUdpSocket(adapter.getPort() + j + 1100),
|
||||
10000);
|
||||
while (true) {
|
||||
Message<?> message = queueIn.receive();
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.ip.util.SocketUtils;
|
||||
import org.springframework.integration.ip.util.SocketTestUtils;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class UdpChannelAdapterTests {
|
||||
@Test
|
||||
public void testUnicastReceiver() throws Exception {
|
||||
QueueChannel channel = new QueueChannel(2);
|
||||
int port = SocketUtils.findAvailableUdpSocket();
|
||||
int port = SocketTestUtils.findAvailableUdpSocket();
|
||||
UnicastReceivingChannelAdapter adapter = new UnicastReceivingChannelAdapter(port);
|
||||
adapter.setOutputChannel(channel);
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
@@ -32,13 +32,13 @@ public class UdpChannelAdapterTests {
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
// SocketUtils.setLocalNicIfPossible(adapter);
|
||||
adapter.start();
|
||||
SocketUtils.waitListening(adapter);
|
||||
SocketTestUtils.waitListening(adapter);
|
||||
|
||||
Message<byte[]> message = MessageBuilder.withPayload("ABCD".getBytes()).build();
|
||||
DatagramPacketMessageMapper mapper = new DatagramPacketMessageMapper();
|
||||
DatagramPacket packet = mapper.fromMessage(message);
|
||||
packet.setSocketAddress(new InetSocketAddress("localhost", port));
|
||||
new DatagramSocket(SocketUtils.findAvailableUdpSocket()).send(packet);
|
||||
new DatagramSocket(SocketTestUtils.findAvailableUdpSocket()).send(packet);
|
||||
Message<byte[]> receivedMessage = (Message<byte[]>) channel.receive(2000);
|
||||
assertEquals(new String(message.getPayload()), new String(receivedMessage.getPayload()));
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class UdpChannelAdapterTests {
|
||||
@Test
|
||||
public void testUnicastSender() throws Exception {
|
||||
QueueChannel channel = new QueueChannel(2);
|
||||
int port = SocketUtils.findAvailableUdpSocket();
|
||||
int port = SocketTestUtils.findAvailableUdpSocket();
|
||||
UnicastReceivingChannelAdapter adapter = new UnicastReceivingChannelAdapter(port);
|
||||
adapter.setOutputChannel(channel);
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
@@ -55,14 +55,14 @@ public class UdpChannelAdapterTests {
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
// SocketUtils.setLocalNicIfPossible(adapter);
|
||||
adapter.start();
|
||||
SocketUtils.waitListening(adapter);
|
||||
SocketTestUtils.waitListening(adapter);
|
||||
|
||||
// String whichNic = SocketUtils.chooseANic(false);
|
||||
UnicastSendingMessageHandler handler = new UnicastSendingMessageHandler(
|
||||
"localhost", port, false, true,
|
||||
"localhost",
|
||||
// whichNic,
|
||||
SocketUtils.findAvailableUdpSocket(), 5000);
|
||||
SocketTestUtils.findAvailableUdpSocket(), 5000);
|
||||
// handler.setLocalAddress(whichNic);
|
||||
handler.afterPropertiesSet();
|
||||
Message<byte[]> message = MessageBuilder.withPayload("ABCD".getBytes()).build();
|
||||
@@ -75,20 +75,20 @@ public class UdpChannelAdapterTests {
|
||||
@Test @Ignore
|
||||
public void testMulticastReceiver() throws Exception {
|
||||
QueueChannel channel = new QueueChannel(2);
|
||||
int port = SocketUtils.findAvailableUdpSocket();
|
||||
int port = SocketTestUtils.findAvailableUdpSocket();
|
||||
MulticastReceivingChannelAdapter adapter = new MulticastReceivingChannelAdapter("225.6.7.8", port);
|
||||
adapter.setOutputChannel(channel);
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.initialize();
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
String nic = SocketUtils.chooseANic(true);
|
||||
String nic = SocketTestUtils.chooseANic(true);
|
||||
if (nic == null) { // no multicast support
|
||||
LogFactory.getLog(this.getClass()).error("No Multicast support");
|
||||
return;
|
||||
}
|
||||
adapter.setLocalAddress(nic);
|
||||
adapter.start();
|
||||
SocketUtils.waitListening(adapter);
|
||||
SocketTestUtils.waitListening(adapter);
|
||||
|
||||
Message<byte[]> message = MessageBuilder.withPayload("ABCD".getBytes()).build();
|
||||
DatagramPacketMessageMapper mapper = new DatagramPacketMessageMapper();
|
||||
@@ -105,20 +105,20 @@ public class UdpChannelAdapterTests {
|
||||
@Test @Ignore
|
||||
public void testMulticastSender() throws Exception {
|
||||
QueueChannel channel = new QueueChannel(2);
|
||||
int port = SocketUtils.findAvailableUdpSocket();
|
||||
int port = SocketTestUtils.findAvailableUdpSocket();
|
||||
UnicastReceivingChannelAdapter adapter = new MulticastReceivingChannelAdapter("225.6.7.9", port);
|
||||
adapter.setOutputChannel(channel);
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.initialize();
|
||||
adapter.setTaskScheduler(taskScheduler);
|
||||
String nic = SocketUtils.chooseANic(true);
|
||||
String nic = SocketTestUtils.chooseANic(true);
|
||||
if (nic == null) { // no multicast support
|
||||
LogFactory.getLog(this.getClass()).error("No Multicast support");
|
||||
return;
|
||||
}
|
||||
adapter.setLocalAddress(nic);
|
||||
adapter.start();
|
||||
SocketUtils.waitListening(adapter);
|
||||
SocketTestUtils.waitListening(adapter);
|
||||
|
||||
MulticastSendingMessageHandler handler = new MulticastSendingMessageHandler("225.6.7.9", port);
|
||||
handler.setLocalAddress(nic);
|
||||
|
||||
@@ -39,11 +39,11 @@ import org.springframework.integration.ip.AbstractInternetProtocolReceivingChann
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public class SocketUtils {
|
||||
public class SocketTestUtils {
|
||||
|
||||
public static final String TEST_STRING = "TestMessage";
|
||||
|
||||
private static final Log logger = LogFactory.getLog(SocketUtils.class);
|
||||
private static final Log logger = LogFactory.getLog(SocketTestUtils.class);
|
||||
|
||||
/**
|
||||
* Sends a message in two chunks with a preceding length. Two such messages are sent.
|
||||
Reference in New Issue
Block a user