send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.BAD_PAYLOAD).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this))
{
fuzzer.connect();
ByteBuffer net = fuzzer.asNetworkBuffer(send);
int splits[] = { 17, 21, net.limit() };
ByteBuffer part1 = net.slice(); // Header + good UTF
part1.limit(splits[0]);
ByteBuffer part2 = net.slice(); // invalid UTF
part2.position(splits[0]);
part2.limit(splits[1]);
ByteBuffer part3 = net.slice(); // good UTF
part3.position(splits[1]);
part3.limit(splits[2]);
fuzzer.send(part1); // the header + good utf
TimeUnit.MILLISECONDS.sleep(500);
fuzzer.send(part2); // the bad UTF
TimeUnit.MILLISECONDS.sleep(500);
fuzzer.send(part3); // the rest (shouldn't work)
fuzzer.expect(expect);
}
}
}