GenericFrameCodec { static ByteBuf encode( final ByteBufAllocator allocator, final FrameType frameType, final int streamId, boolean fragmentFollows, @Nullable ByteBuf metadata, ByteBuf data) { return encode(allocator, frameType, streamId, fragmentFollows, false, false, 0, metadata, data); }    }
@Test void testEncoding() { ByteBuf frame = RequestStreamFrameCodec.encode( ByteBufAllocator.DEFAULT, 1, false, 1, Unpooled.copiedBuffer("md", StandardCharsets.UTF_8), Unpooled.copiedBuffer("d", StandardCharsets.UTF_8)); frame = FrameLengthCodec.encode(ByteBufAllocator.DEFAULT, frame.readableBytes(), frame); String expected = "000010000000011900000000010000026d6464"; assertEquals(expected, ByteBufUtil.hexDump(frame)); frame.release(); }
@Test void testEncodingWithEmptyMetadata() { ByteBuf frame = RequestStreamFrameCodec.encode( ByteBufAllocator.DEFAULT, 1, false, 1, Unpooled.EMPTY_BUFFER, Unpooled.copiedBuffer("d", StandardCharsets.UTF_8)); frame = FrameLengthCodec.encode(ByteBufAllocator.DEFAULT, frame.readableBytes(), frame); String expected = "00000e0000000119000000000100000064"; assertEquals(expected, ByteBufUtil.hexDump(frame)); frame.release(); }
@Test void testEncodingWithNullMetadata() { ByteBuf frame = RequestStreamFrameCodec.encode( ByteBufAllocator.DEFAULT, 1, false, 1, null, Unpooled.copiedBuffer("d", StandardCharsets.UTF_8)); frame = FrameLengthCodec.encode(ByteBufAllocator.DEFAULT, frame.readableBytes(), frame); String expected = "00000b0000000118000000000164"; assertEquals(expected, ByteBufUtil.hexDump(frame)); frame.release(); }