@Test
public void testReadStreamPauseResume() {
server.close();
server = vertx.createNetServer(new NetServerOptions().setAcceptBacklog(1).setPort(1234).setHost("localhost"));
NetSocketStream socketStream = server.connectStream();
AtomicBoolean paused = new AtomicBoolean();
socketStream.handler(so -> {
assertTrue(!paused.get());
so.write("hello");
so.close();
});
server.listen(ar -> {
assertTrue(ar.succeeded());
paused.set(true);
socketStream.pause();
client.connect(1234, "localhost", ar2 -> {
assertTrue(ar2.succeeded());
NetSocket so2 = ar2.result();
so2.handler(buffer -> {
fail();
});
so2.closeHandler(v -> {
paused.set(false);
socketStream.resume();
client.connect(1234, "localhost", ar3 -> {
assertTrue(ar3.succeeded());
NetSocket so3 = ar3.result();
Buffer buffer = Buffer.buffer();
so3.handler(buffer::appendBuffer);