ByteBuffer buffer = generator.data(streamId, 2 * length, data);
Assert.assertNotNull(buffer);
TestSPDYParserListener listener = new TestSPDYParserListener();
Parser parser = new Parser(new StandardCompressionFactory().newDecompressor());
parser.addListener(listener);
// Split the buffer to simulate a split boundary in receiving the bytes
int split = 3;
ByteBuffer buffer1 = ByteBuffer.allocate(buffer.remaining() - split);
buffer.limit(buffer.limit() - split);
buffer1.put(buffer);
buffer1.flip();
ByteBuffer buffer2 = ByteBuffer.allocate(split);
buffer.limit(buffer.limit() + split);
buffer2.put(buffer);
buffer2.flip();
parser.parse(buffer1);
DataFrame frame2 = listener.getDataFrame();
Assert.assertNotNull(frame2);
Assert.assertEquals(streamId, frame2.getStreamId());
Assert.assertEquals(0, frame2.getFlags());
Assert.assertEquals(length - split, frame2.getLength());
Assert.assertEquals(length - split, listener.getData().remaining());
parser.parse(buffer2);
DataFrame frame3 = listener.getDataFrame();
Assert.assertNotNull(frame3);
Assert.assertEquals(streamId, frame3.getStreamId());
Assert.assertEquals(DataInfo.FLAG_CLOSE, frame3.getFlags());