DefaultFrameFactory extends FrameFactory { @Override public RawFrame createData(final int streamId, final ByteBuffer payload, final boolean endStream) { Args.positive(streamId, "Stream id"); final int flags = (endStream ? FrameFlag.END_STREAM.value : 0); return new RawFrame(FrameType.DATA.getValue(), flags, streamId, payload); }  @Override RawFrame createHeaders(final int streamId, final ByteBuffer payload, final boolean endHeaders, final boolean endStream); @Override RawFrame createContinuation(final int streamId, final ByteBuffer payload, final boolean endHeaders); @Override RawFrame createPushPromise(final int streamId, final ByteBuffer payload, final boolean endHeaders); @Override RawFrame createData(final int streamId, final ByteBuffer payload, final boolean endStream); static final FrameFactory INSTANCE; }
@Test public void testDataFrame() throws Exception { final FrameFactory frameFactory = new DefaultFrameFactory(); final byte[] data = new byte[]{'a', 'b', 'c', 'd', 'e', 'f'}; final Frame<ByteBuffer> dataFrame = frameFactory.createData(23, ByteBuffer.wrap(data), true); Assert.assertEquals(FrameType.DATA.value, dataFrame.getType()); Assert.assertEquals(23, dataFrame.getStreamId()); Assert.assertEquals(1L, dataFrame.getFlags()); }