### Question:
PaddingFrame extends Frame { public static PaddingFrame parse(final ByteBuf bb) { int length = 0; while (bb.isReadable()) { final int pos = bb.readerIndex(); final byte b = bb.readByte(); if (b == 0) { length += 1; } else { bb.readerIndex(pos); break; } } if (length == 0) { throw new IllegalArgumentException("Illegal frame type"); } return new PaddingFrame(length); } PaddingFrame(final int length); static PaddingFrame parse(final ByteBuf bb); @Override int calculateLength(); @Override void write(final ByteBuf bb); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void parseOne() { final PaddingFrame frame = PaddingFrame.parse(Unpooled.copiedBuffer(Hex.dehex("00"))); assertEquals(new PaddingFrame(1), frame); }
@Test public void parseMulti() { final PaddingFrame frame = PaddingFrame.parse(Unpooled.copiedBuffer(Hex.dehex("000000000000"))); assertEquals(new PaddingFrame(6), frame); }
@Test public void parseTrailing() { final ByteBuf bb = Unpooled.copiedBuffer(Hex.dehex("000000000000FF")); final PaddingFrame frame = PaddingFrame.parse(bb); assertEquals(new PaddingFrame(6), frame); assertEquals(1, bb.readableBytes()); }
@Test(expected = IllegalArgumentException.class) public void parseIllegal() { PaddingFrame.parse(Unpooled.copiedBuffer(Hex.dehex("FF"))); }