use of org.springframework.integration.transformer.ObjectToStringTransformer in project spring-integration by spring-projects.
the class ConnectionFacforyTests method test.
@Test
public void test() throws Exception {
ApplicationEventPublisher publisher = e -> {
};
AbstractServerConnectionFactory server = Tcp.netServer(0).backlog(2).soTimeout(5000).get();
final AtomicReference<Message<?>> received = new AtomicReference<>();
final CountDownLatch latch = new CountDownLatch(1);
server.registerListener(m -> {
received.set(new ObjectToStringTransformer().transform(m));
latch.countDown();
return false;
});
server.setApplicationEventPublisher(publisher);
server.afterPropertiesSet();
server.start();
TestingUtilities.waitListening(server, null);
AbstractClientConnectionFactory client = Tcp.netClient("localhost", server.getPort()).get();
client.setApplicationEventPublisher(publisher);
client.afterPropertiesSet();
client.start();
client.getConnection().send(new GenericMessage<>("foo"));
assertTrue(latch.await(10, TimeUnit.SECONDS));
assertEquals("foo", received.get().getPayload());
client.stop();
server.stop();
}
Aggregations