/** * Returns a test instance of {@link StreamIdFrame}. * * @return a test instance of {@link StreamIdFrame} */ public static StreamIdFrame createTestStreamIdFrame() { return createStreamIdFrame(DEFAULT, 1, createTestCancelFrame()); }
public static StreamIdFrame createTestStreamIdFrame() { return createStreamIdFrame(DEFAULT, 1, createTestCancelFrame()); }
/** * Returns an abstraction leaking frame with the stream id and frame. This adds the frame length * and stream id header to the frame. * * @param byteBufAllocator the {@link ByteBufAllocator} to use * @param streamId the stream id * @param frame the frame * @return an abstraction leaking frame with the stream id and frame * @throws NullPointerException if {@code byteBufAllocator} or {@code frame} is {@code null} */ public static Frame toAbstractionLeakingFrame( ByteBufAllocator byteBufAllocator, int streamId, io.rsocket.framing.Frame frame) { Objects.requireNonNull(byteBufAllocator, "byteBufAllocator must not be null"); Objects.requireNonNull(frame, "frame must not be null"); StreamIdFrame streamIdFrame = null; FrameLengthFrame frameLengthFrame = null; try { streamIdFrame = createStreamIdFrame(byteBufAllocator, streamId, frame); frameLengthFrame = createFrameLengthFrame(byteBufAllocator, streamIdFrame); return frameLengthFrame.mapFrame(byteBuf -> Frame.from(byteBuf.retain())); } finally { disposeQuietly(frame, streamIdFrame, frameLengthFrame); } } }
@DisplayName("createStreamIdFrame throws NullPointerException with null frame") @Test void createStreamIdFrameNullFrame() { assertThatNullPointerException() .isThrownBy(() -> createStreamIdFrame(DEFAULT, 0, null)) .withMessage("frame must not be null"); }
@DisplayName("createStreamIdFrame throws NullPointerException with null byteBufAllocator") @Test void createStreamIdFrameNullByteBufAllocator() { assertThatNullPointerException() .isThrownBy(() -> createStreamIdFrame(null, 0, createTestCancelFrame())) .withMessage("byteBufAllocator must not be null"); }
/** * Returns an abstraction leaking frame with the stream id and frame. This adds the frame length * and stream id header to the frame. * * @param byteBufAllocator the {@link ByteBufAllocator} to use * @param streamId the stream id * @param frame the frame * @return an abstraction leaking frame with the stream id and frame * @throws NullPointerException if {@code byteBufAllocator} or {@code frame} is {@code null} */ public static Frame toAbstractionLeakingFrame( ByteBufAllocator byteBufAllocator, int streamId, io.rsocket.framing.Frame frame) { Objects.requireNonNull(byteBufAllocator, "byteBufAllocator must not be null"); Objects.requireNonNull(frame, "frame must not be null"); StreamIdFrame streamIdFrame = null; FrameLengthFrame frameLengthFrame = null; try { streamIdFrame = createStreamIdFrame(byteBufAllocator, streamId, frame); frameLengthFrame = createFrameLengthFrame(byteBufAllocator, streamIdFrame); return frameLengthFrame.mapFrame(byteBuf -> Frame.from(byteBuf.retain())); } finally { disposeQuietly(frame, streamIdFrame, frameLengthFrame); } } }