/** * Returns a test instance of {@link RequestNFrame}. * * @return a test instance of {@link RequestNFrame} */ public static RequestNFrame createTestRequestNFrame() { return createRequestNFrame(DEFAULT, 1); }
/** * Creates the {@code REQUEST_N} frame. * * @param byteBufAllocator the {@code ByteBufAllocator} to use * @param requestN the size of the request. Must be positive. * @return the {@code REQUEST_N} frame * @throws NullPointerException if {@code byteBufAllocator} is {@code null} */ public static RequestNFrame createRequestNFrame(ByteBufAllocator byteBufAllocator, int requestN) { NumberUtils.requirePositive(requestN, "requestN must be positive"); ByteBuf byteBuf = createFrameTypeAndFlags(byteBufAllocator, REQUEST_N).writeInt(requestN); return RECYCLER.get().setByteBuf(byteBuf); }
/** * Returns the size of the request. * * @return the size of the request */ int getRequestN() { return getByteBuf().getInt(OFFSET_REQUEST_N); } }
/** * Creates the {@code REQUEST_N} frame. * * @param byteBuf the {@link ByteBuf} representing the frame * @return the {@code REQUEST_N} frame. * @throws NullPointerException if {@code byteBuf} is {@code null} */ public static RequestNFrame createRequestNFrame(ByteBuf byteBuf) { Objects.requireNonNull(byteBuf, "byteBuf must not be null"); return RECYCLER.get().setByteBuf(byteBuf.retain()); }
@Override public String toString() { return "RequestNFrame{" + "requestN=" + getRequestN() + '}'; }
@DisplayName("creates REQUEST_N frame") @Test void createFrameRequestN() { createTestRequestNFrame() .consumeFrame( byteBuf -> assertThat(createFrame(byteBuf)).isInstanceOf(RequestNFrame.class)); }
/** * Creates the {@code REQUEST_N} frame. * * @param byteBuf the {@link ByteBuf} representing the frame * @return the {@code REQUEST_N} frame. * @throws NullPointerException if {@code byteBuf} is {@code null} */ public static RequestNFrame createRequestNFrame(ByteBuf byteBuf) { Objects.requireNonNull(byteBuf, "byteBuf must not be null"); return RECYCLER.get().setByteBuf(byteBuf.retain()); }
@Override public String toString() { return "RequestNFrame{" + "requestN=" + getRequestN() + '}'; }
public static RequestNFrame createTestRequestNFrame() { return createRequestNFrame(DEFAULT, 1); }
/** * Creates the {@code REQUEST_N} frame. * * @param byteBufAllocator the {@code ByteBufAllocator} to use * @param requestN the size of the request. Must be positive. * @return the {@code REQUEST_N} frame * @throws NullPointerException if {@code byteBufAllocator} is {@code null} */ public static RequestNFrame createRequestNFrame(ByteBufAllocator byteBufAllocator, int requestN) { NumberUtils.requirePositive(requestN, "requestN must be positive"); ByteBuf byteBuf = createFrameTypeAndFlags(byteBufAllocator, REQUEST_N).writeInt(requestN); return RECYCLER.get().setByteBuf(byteBuf); }
/** * Returns the size of the request. * * @return the size of the request */ int getRequestN() { return getByteBuf().getInt(OFFSET_REQUEST_N); } }
@DisplayName("createRequestNFrame throws NullPointerException with null byteBufAllocator") @Test void createRequestNFrameNullByteBufAllocator() { assertThatNullPointerException() .isThrownBy(() -> createRequestNFrame(null, 1)) .withMessage("byteBufAllocator must not be null"); }
@DisplayName("createRequestNFrame throws IllegalArgumentException with requestN less then 1") @Test void createRequestNFrameZeroRequestN() { assertThatIllegalArgumentException() .isThrownBy(() -> createRequestNFrame(DEFAULT, 0)) .withMessage("requestN must be positive"); }
return createRequestChannelFrame(byteBuf); case REQUEST_N: return createRequestNFrame(byteBuf); case CANCEL: return createCancelFrame(byteBuf);
return createRequestChannelFrame(byteBuf); case REQUEST_N: return createRequestNFrame(byteBuf); case CANCEL: return createCancelFrame(byteBuf);