TcpClientTransport implements ClientTransport { @Override public Mono<DuplexConnection> connect() { return client .doOnConnected(c -> c.addHandlerLast(new RSocketLengthCodec(maxFrameLength))) .connect() .map(TcpDuplexConnection::new); } private  TcpClientTransport(TcpClient client, int maxFrameLength); static TcpClientTransport create(int port); static TcpClientTransport create(String bindAddress, int port); static TcpClientTransport create(InetSocketAddress address); static TcpClientTransport create(TcpClient client); static TcpClientTransport create(TcpClient client, int maxFrameLength); @Override int maxFrameLength(); @Override Mono<DuplexConnection> connect();  }
@DisplayName("connects to server") @Test void connect() { InetSocketAddress address = InetSocketAddress.createUnresolved("localhost", 0); TcpServerTransport serverTransport = TcpServerTransport.create(address); serverTransport .start(duplexConnection -> Mono.empty()) .flatMap(context -> TcpClientTransport.create(context.address()).connect()) .as(StepVerifier::create) .expectNextCount(1) .verifyComplete(); }