Home / Class/ StreamBufferingEncoderTest Class — netty Architecture

StreamBufferingEncoderTest Class — netty Architecture

Architecture documentation for the StreamBufferingEncoderTest class in StreamBufferingEncoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  b13b21e9_41cb_8feb_3534_f953823cad07["StreamBufferingEncoderTest"]
  aebb84f3_a3c7_3d78_a140_6364aaf00264["StreamBufferingEncoderTest.java"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|defined in| aebb84f3_a3c7_3d78_a140_6364aaf00264
  b8078d06_d505_ba88_4396_b7f705ff79d2["setup()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| b8078d06_d505_ba88_4396_b7f705ff79d2
  dd885e31_d119_a7b1_1b06_21e4ace29f21["teardown()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| dd885e31_d119_a7b1_1b06_21e4ace29f21
  884c387e_e967_3596_fff0_8b70e4c80b9a["multipleWritesToActiveStream()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| 884c387e_e967_3596_fff0_8b70e4c80b9a
  9f8162e5_2b2a_2415_bd00_d03ac0023abc["ensureCanCreateNextStreamWhenStreamCloses()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| 9f8162e5_2b2a_2415_bd00_d03ac0023abc
  c794a500_3f66_190a_7d42_f15255392e9f["alternatingWritesToActiveAndBufferedStreams()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| c794a500_3f66_190a_7d42_f15255392e9f
  f4d05f2d_c6c5_35d4_b589_f342d5aab5de["bufferingNewStreamFailsAfterGoAwayReceived()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| f4d05f2d_c6c5_35d4_b589_f342d5aab5de
  5915426b_4b99_aac6_0cb7_db9629a54540["receivingGoAwayFailsBufferedStreams()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| 5915426b_4b99_aac6_0cb7_db9629a54540
  b50540da_87f1_0953_7998_c4a801d47e45["receivingGoAwayFailsNewStreamIfMaxConcurrentStreamsReached()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| b50540da_87f1_0953_7998_c4a801d47e45
  569bbfdb_1483_c5d9_1ce7_fcd616d9c72d["sendingGoAwayShouldNotFailStreams()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| 569bbfdb_1483_c5d9_1ce7_fcd616d9c72d
  5ce03f8b_849d_0303_8613_5ed842fcacab["endStreamDoesNotFailBufferedStream()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| 5ce03f8b_849d_0303_8613_5ed842fcacab
  a4834aab_bdfa_a201_170b_50ec29002cd8["rstStreamClosesBufferedStream()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| a4834aab_bdfa_a201_170b_50ec29002cd8
  ed24aad8_a143_6f58_e566_7e8acdbc51a5["bufferUntilActiveStreamsAreReset()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| ed24aad8_a143_6f58_e566_7e8acdbc51a5
  dfd26aec_d7ff_cb7f_2e5a_3d11e7382ac9["bufferUntilMaxStreamsIncreased()"]
  b13b21e9_41cb_8feb_3534_f953823cad07 -->|method| dfd26aec_d7ff_cb7f_2e5a_3d11e7382ac9

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java lines 77–619

public class StreamBufferingEncoderTest {

    private StreamBufferingEncoder encoder;

    private Http2Connection connection;

    @Mock
    private Http2FrameWriter writer;

    @Mock
    private ChannelHandlerContext ctx;

    @Mock
    private Channel channel;

    @Mock
    private Channel.Unsafe unsafe;

    @Mock
    private ChannelConfig config;

    @Mock
    private EventExecutor executor;

    /**
     * Init fields and do mocking.
     */
    @BeforeEach
    public void setup() throws Exception {
        MockitoAnnotations.initMocks(this);

        Http2FrameWriter.Configuration configuration = mock(Http2FrameWriter.Configuration.class);
        Http2FrameSizePolicy frameSizePolicy = mock(Http2FrameSizePolicy.class);
        when(writer.configuration()).thenReturn(configuration);
        when(configuration.frameSizePolicy()).thenReturn(frameSizePolicy);
        when(frameSizePolicy.maxFrameSize()).thenReturn(DEFAULT_MAX_FRAME_SIZE);
        when(writer.writeData(any(ChannelHandlerContext.class), anyInt(), any(ByteBuf.class), anyInt(), anyBoolean(),
                any(ChannelPromise.class))).thenAnswer(successAnswer());
        when(writer.writeRstStream(eq(ctx), anyInt(), anyLong(), any(ChannelPromise.class))).thenAnswer(
                successAnswer());
        when(writer.writeGoAway(any(ChannelHandlerContext.class), anyInt(), anyLong(), any(ByteBuf.class),
                any(ChannelPromise.class)))
                .thenAnswer(successAnswer());
        when(writer.writeHeaders(any(ChannelHandlerContext.class), anyInt(), any(Http2Headers.class),
            anyInt(), anyBoolean(), any(ChannelPromise.class))).thenAnswer(noopAnswer());
        when(writer.writeHeaders(any(ChannelHandlerContext.class), anyInt(), any(Http2Headers.class),
            anyInt(), anyShort(), anyBoolean(), anyInt(), anyBoolean(), any(ChannelPromise.class)))
            .thenAnswer(noopAnswer());

        connection = new DefaultHttp2Connection(false);
        connection.remote().flowController(new DefaultHttp2RemoteFlowController(connection));
        connection.local().flowController(new DefaultHttp2LocalFlowController(connection).frameWriter(writer));

        DefaultHttp2ConnectionEncoder defaultEncoder =
                new DefaultHttp2ConnectionEncoder(connection, writer);
        encoder = new StreamBufferingEncoder(defaultEncoder);
        DefaultHttp2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(
                connection, encoder, mock(Http2FrameReader.class), ALWAYS_VERIFY, false);
        Http2ConnectionHandler handler = new Http2ConnectionHandlerBuilder()
                .frameListener(mock(Http2FrameListener.class))
                .codec(decoder, encoder).build();

        // Set LifeCycleManager on encoder and decoder
        when(ctx.channel()).thenReturn(channel);
        when(ctx.alloc()).thenReturn(UnpooledByteBufAllocator.DEFAULT);
        when(channel.alloc()).thenReturn(UnpooledByteBufAllocator.DEFAULT);
        when(executor.inEventLoop()).thenReturn(true);
        doAnswer(new Answer<ChannelPromise>() {
            @Override
            public ChannelPromise answer(InvocationOnMock invocation) throws Throwable {
                return newPromise();
            }
        }).when(ctx).newPromise();
        when(ctx.executor()).thenReturn(executor);
        when(channel.isActive()).thenReturn(false);
        when(channel.config()).thenReturn(config);
        when(channel.isWritable()).thenReturn(true);
        when(channel.bytesBeforeUnwritable()).thenReturn(Long.MAX_VALUE);
        when(config.getWriteBufferHighWaterMark()).thenReturn(Integer.MAX_VALUE);
        when(config.getMessageSizeEstimator()).thenReturn(DefaultMessageSizeEstimator.DEFAULT);
        ChannelMetadata metadata = new ChannelMetadata(false, 16);

Frequently Asked Questions

What is the StreamBufferingEncoderTest class?
StreamBufferingEncoderTest is a class in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java.
Where is StreamBufferingEncoderTest defined?
StreamBufferingEncoderTest is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java at line 77.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free