use of io.vertx.test.core.CheckingSender in project vert.x by eclipse.
the class NetTest method testServerNetSocketShouldBeClosedWhenTheClosedHandlerIsCalled.
// We only do it for server, as client uses the same NetSocket implementation
@Test
public void testServerNetSocketShouldBeClosedWhenTheClosedHandlerIsCalled() throws Exception {
waitFor(2);
server.connectHandler(so -> {
CheckingSender sender = new CheckingSender(vertx.getOrCreateContext(), 2, so);
sender.send();
so.closeHandler(v -> {
Throwable failure = sender.close();
if (failure != null) {
fail(failure);
} else {
complete();
}
});
so.endHandler(v -> {
Throwable failure = sender.close();
if (failure != null) {
fail(failure);
} else {
complete();
}
});
});
startServer();
client.connect(testAddress, onSuccess(so -> {
vertx.setTimer(1000, id -> {
so.close();
});
}));
await();
}
Aggregations