use of org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory in project spring-integration by spring-projects.
the class TcpInboundGatewayTests method testNetNotSingle.
@Test
public void testNetNotSingle() throws Exception {
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(0);
scf.setSingleUse(false);
TcpInboundGateway gateway = new TcpInboundGateway();
gateway.setConnectionFactory(scf);
scf.start();
TestingUtilities.waitListening(scf, 20000L);
int port = scf.getPort();
final QueueChannel channel = new QueueChannel();
gateway.setRequestChannel(channel);
gateway.setBeanFactory(mock(BeanFactory.class));
ServiceActivatingHandler handler = new ServiceActivatingHandler(new Service());
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
socket.getOutputStream().write("Test1\r\n".getBytes());
socket.getOutputStream().write("Test2\r\n".getBytes());
handler.handleMessage(channel.receive(10000));
handler.handleMessage(channel.receive(10000));
byte[] bytes = new byte[12];
readFully(socket.getInputStream(), bytes);
assertEquals("Echo:Test1\r\n", new String(bytes));
readFully(socket.getInputStream(), bytes);
assertEquals("Echo:Test2\r\n", new String(bytes));
}
use of org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory in project spring-integration by spring-projects.
the class TcpReceivingChannelAdapterTests method testNetInterceptors.
@Test
public void testNetInterceptors() throws Exception {
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(0);
noopPublisher(scf);
interceptorsGuts(scf);
scf.stop();
}
use of org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory in project spring-integration by spring-projects.
the class TcpReceivingChannelAdapterTests method testNetSingleSharedInterceptors.
@Test
public void testNetSingleSharedInterceptors() throws Exception {
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(0);
noopPublisher(scf);
singleSharedInterceptorsGuts(scf);
scf.stop();
}
use of org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory in project spring-integration by spring-projects.
the class TcpReceivingChannelAdapterTests method testNetShared.
@Test
public void testNetShared() throws Exception {
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(0);
noopPublisher(scf);
ByteArrayCrLfSerializer serializer = new ByteArrayCrLfSerializer();
scf.setSerializer(serializer);
scf.setDeserializer(serializer);
TcpSendingMessageHandler handler = new TcpSendingMessageHandler();
handler.setConnectionFactory(scf);
TcpReceivingChannelAdapter adapter = new TcpReceivingChannelAdapter();
adapter.setConnectionFactory(scf);
scf.start();
QueueChannel channel = new QueueChannel();
adapter.setOutputChannel(channel);
TestingUtilities.waitListening(scf, null);
int port = scf.getPort();
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
socket.setSoTimeout(2000);
socket.getOutputStream().write("Test\r\n".getBytes());
socket.getOutputStream().write("Test\r\n".getBytes());
Message<?> message = channel.receive(10000);
assertNotNull(message);
handler.handleMessage(message);
message = channel.receive(10000);
assertNotNull(message);
handler.handleMessage(message);
byte[] b = new byte[6];
readFully(socket.getInputStream(), b);
assertEquals("Test\r\n", new String(b));
readFully(socket.getInputStream(), b);
assertEquals("Test\r\n", new String(b));
scf.stop();
}
use of org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory in project spring-integration by spring-projects.
the class TcpReceivingChannelAdapterTests method testNetSingleNoOutboundInterceptors.
@Test
public void testNetSingleNoOutboundInterceptors() throws Exception {
AbstractServerConnectionFactory scf = new TcpNetServerConnectionFactory(0);
noopPublisher(scf);
singleNoOutboundInterceptorsGuts(scf);
scf.stop();
}
Aggregations