Home / Class/ Http2MaxRstFrameLimitEncoderTest Class — netty Architecture

Http2MaxRstFrameLimitEncoderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  eeac0acc_8c8f_03de_0277_9e95e05f7fa8["Http2MaxRstFrameLimitEncoderTest"]
  13a681d9_0fe4_1b2a_a0c8_cb95bbb86c68["Http2MaxRstFrameLimitEncoderTest.java"]
  eeac0acc_8c8f_03de_0277_9e95e05f7fa8 -->|defined in| 13a681d9_0fe4_1b2a_a0c8_cb95bbb86c68
  8f9b0a5f_24da_97ad_a912_a05ecf227bcf["setup()"]
  eeac0acc_8c8f_03de_0277_9e95e05f7fa8 -->|method| 8f9b0a5f_24da_97ad_a912_a05ecf227bcf
  3645720d_7f6b_6bf9_d46d_168df19f06b2["ChannelPromise()"]
  eeac0acc_8c8f_03de_0277_9e95e05f7fa8 -->|method| 3645720d_7f6b_6bf9_d46d_168df19f06b2
  0c45519c_d07f_b80f_ad14_90790a35c45d["teardown()"]
  eeac0acc_8c8f_03de_0277_9e95e05f7fa8 -->|method| 0c45519c_d07f_b80f_ad14_90790a35c45d
  24075965_efc6_4526_e262_a76239b838fc["testLimitRst()"]
  eeac0acc_8c8f_03de_0277_9e95e05f7fa8 -->|method| 24075965_efc6_4526_e262_a76239b838fc
  d0b8f83e_3058_5872_0f12_e8495e796a13["testLimitRstReset()"]
  eeac0acc_8c8f_03de_0277_9e95e05f7fa8 -->|method| d0b8f83e_3058_5872_0f12_e8495e796a13
  00a5eab7_8aa2_fcd5_ae09_235b89915618["verifyFlushAndClose()"]
  eeac0acc_8c8f_03de_0277_9e95e05f7fa8 -->|method| 00a5eab7_8aa2_fcd5_ae09_235b89915618

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/Http2MaxRstFrameLimitEncoderTest.java lines 65–216

public class Http2MaxRstFrameLimitEncoderTest {

    private Http2MaxRstFrameLimitEncoder encoder;

    @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;

    private final MockTicker ticker = Ticker.newMockTicker();

    private final Queue<ChannelPromise> goAwayPromises = new ArrayDeque<ChannelPromise>();

    /**
     * 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.writeRstStream(eq(ctx), anyInt(), anyLong(), any(ChannelPromise.class)))
                .thenAnswer(new Answer<ChannelFuture>() {
                    @Override
                    public ChannelFuture answer(InvocationOnMock invocationOnMock) {
                        return handlePromise(invocationOnMock, 3);
                    }
                });
        when(writer.writeGoAway(any(ChannelHandlerContext.class), anyInt(), anyLong(), any(ByteBuf.class),
                any(ChannelPromise.class))).thenAnswer(new Answer<ChannelFuture>() {
            @Override
            public ChannelFuture answer(InvocationOnMock invocationOnMock) {
                ReferenceCountUtil.release(invocationOnMock.getArgument(3));
                ChannelPromise promise = invocationOnMock.getArgument(4);
                goAwayPromises.offer(promise);
                return promise;
            }
        });
        Http2Connection 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 Http2MaxRstFrameLimitEncoder(defaultEncoder, 2, 1, ticker);
        DefaultHttp2ConnectionDecoder decoder =
                new DefaultHttp2ConnectionDecoder(connection, encoder, mock(Http2FrameReader.class));
        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);

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free