Search in sources :

Example 21 with AbstractClientConnectionFactory

use of org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory in project spring-integration by spring-projects.

the class TcpOutboundGatewayTests method testNioGWPropagatesSocketClose.

@Test
public void testNioGWPropagatesSocketClose() throws Exception {
    ServerSocket serverSocket = ServerSocketFactory.getDefault().createServerSocket(0);
    final int port = serverSocket.getLocalPort();
    AbstractClientConnectionFactory ccf = new TcpNioClientConnectionFactory("localhost", port);
    ccf.setSerializer(new DefaultSerializer());
    ccf.setDeserializer(new DefaultDeserializer());
    ccf.setSoTimeout(10000);
    ccf.setSingleUse(false);
    ccf.start();
    testGWPropagatesSocketCloseGuts(port, ccf, serverSocket);
    serverSocket.close();
}
Also used : AbstractClientConnectionFactory(org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory) DefaultSerializer(org.springframework.core.serializer.DefaultSerializer) DefaultDeserializer(org.springframework.core.serializer.DefaultDeserializer) ServerSocket(java.net.ServerSocket) TcpNioClientConnectionFactory(org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionFactory) LongRunningIntegrationTest(org.springframework.integration.test.support.LongRunningIntegrationTest) Test(org.junit.Test)

Example 22 with AbstractClientConnectionFactory

use of org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory in project spring-integration by spring-projects.

the class ConnectionFacforyTests method shouldReturnNioFlavor.

@Test
public void shouldReturnNioFlavor() throws Exception {
    AbstractServerConnectionFactory server = Tcp.nioServer(0).get();
    assertTrue(server instanceof TcpNioServerConnectionFactory);
    AbstractClientConnectionFactory client = Tcp.nioClient("localhost", server.getPort()).get();
    assertTrue(client instanceof TcpNioClientConnectionFactory);
}
Also used : AbstractClientConnectionFactory(org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory) TcpNioServerConnectionFactory(org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory) AbstractServerConnectionFactory(org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory) TcpNioClientConnectionFactory(org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionFactory) Test(org.junit.Test)

Aggregations

AbstractClientConnectionFactory (org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory)22 Test (org.junit.Test)21 ServerSocket (java.net.ServerSocket)17 TcpNetClientConnectionFactory (org.springframework.integration.ip.tcp.connection.TcpNetClientConnectionFactory)15 LongRunningIntegrationTest (org.springframework.integration.test.support.LongRunningIntegrationTest)15 DefaultDeserializer (org.springframework.core.serializer.DefaultDeserializer)14 DefaultSerializer (org.springframework.core.serializer.DefaultSerializer)14 CountDownLatch (java.util.concurrent.CountDownLatch)9 QueueChannel (org.springframework.integration.channel.QueueChannel)8 IOException (java.io.IOException)7 Socket (java.net.Socket)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 AtomicReference (java.util.concurrent.atomic.AtomicReference)7 EOFException (java.io.EOFException)5 ObjectInputStream (java.io.ObjectInputStream)5 ObjectOutputStream (java.io.ObjectOutputStream)5 SocketTimeoutException (java.net.SocketTimeoutException)5 ExecutionException (java.util.concurrent.ExecutionException)5 MessageTimeoutException (org.springframework.integration.MessageTimeoutException)5 TcpNioClientConnectionFactory (org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionFactory)5