Http2PingFrame extends Http2Frame { public byte[] getData() { return data; } protected  Http2PingFrame(Http2PingFrameBuilder builder); byte[] getData(); @Override void writePayload(ByteBuffer buffer);  }
@Test public void decode() { Http2Connection connection = new Http2Connection(); ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_STANDARD_BUFFER); Http2PingFrame frame = (Http2PingFrame) connection.decode(buffer); assertNotNull(frame); assertEquals(8, frame.getLength()); assertEquals(6, frame.getType()); assertEquals(0x00, frame.getFlags()); assertEquals(32, frame.getStreamID()); assertArrayEquals(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}, frame.getData()); }
@Test public void decodeExtraData() { Http2Connection connection = new Http2Connection(); ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_EXTRA_DATA_BUFFER); Http2PingFrame frame = (Http2PingFrame) connection.decode(buffer); assertNotNull(frame); assertEquals(9, frame.getLength()); assertEquals(6, frame.getType()); assertEquals(0x00, frame.getFlags()); assertEquals(32, frame.getStreamID()); assertArrayEquals(new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}, frame.getData()); }
@Test public void decodeNotEnoughData() { Http2Connection connection = new Http2Connection(); ByteBuffer buffer = ByteBuffer.wrap(TestMessages.PING_NO_ENOUGH_DATA_BUFFER); Http2PingFrame frame = (Http2PingFrame) connection.decode(buffer); assertNotNull(frame); assertEquals(1, frame.getLength()); assertEquals(6, frame.getType()); assertEquals(0x00, frame.getFlags()); assertEquals(32, frame.getStreamID()); assertArrayEquals(new byte[] {0x00}, frame.getData()); }