}
final int numChunks = 100;
final int chunkSize = 100;
final Buffer received = Buffer.buffer();
final Buffer sent = Buffer.buffer();
final NetSocket socket = ar2.result();
final AtomicBoolean upgradedClient = new AtomicBoolean();
socket.handler(buffer -> {
received.appendBuffer(buffer);
if (received.length() == sent.length()) {
assertEquals(sent, received);
testComplete();
}
if (startTLS && !upgradedClient.get()) {
assertFalse(socket.isSsl());
socket.upgradeToSsl(v -> {
assertTrue(socket.isSsl());
// Now send the rest
for (int i = 1; i < numChunks; i++) {
sendBuffer(socket, sent, chunkSize);
}
});
} else {
assertTrue(socket.isSsl());
}
});
//Now send some data
int numToSend = startTLS ? 1 : numChunks;