// Build up raw (network bytes) buffer
ByteBuffer networkBytes = UnitGenerator.generate(frames);
// Parse, in 4096 sized windows
WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER);
Parser parser = new UnitParser(policy);
IncomingFramesCapture capture = new IncomingFramesCapture();
parser.setIncomingFramesHandler(capture);
while (networkBytes.remaining() > 0)
{
ByteBuffer window = networkBytes.slice();
int windowSize = Math.min(window.remaining(),4096);
window.limit(windowSize);
parser.parse(window);
networkBytes.position(networkBytes.position() + windowSize);
}
capture.assertNoErrors();
Assert.assertThat("Frame Count",capture.getFrames().size(),is(2));