Home / Function/ setup() — netty Function Reference

setup() — netty Function Reference

Architecture documentation for the setup() function in StreamBufferingEncoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  b8078d06_d505_ba88_4396_b7f705ff79d2["setup()"]
  b13b21e9_41cb_8feb_3534_f953823cad07["StreamBufferingEncoderTest"]
  b8078d06_d505_ba88_4396_b7f705ff79d2 -->|defined in| b13b21e9_41cb_8feb_3534_f953823cad07
  5429b381_1fa6_b38b_0c55_cfca3e18c639["successAnswer()"]
  b8078d06_d505_ba88_4396_b7f705ff79d2 -->|calls| 5429b381_1fa6_b38b_0c55_cfca3e18c639
  694e3b59_c990_d601_cc36_e260b7c719b8["noopAnswer()"]
  b8078d06_d505_ba88_4396_b7f705ff79d2 -->|calls| 694e3b59_c990_d601_cc36_e260b7c719b8
  style b8078d06_d505_ba88_4396_b7f705ff79d2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java lines 104–161

    @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);
        when(channel.metadata()).thenReturn(metadata);
        when(channel.unsafe()).thenReturn(unsafe);
        handler.handlerAdded(ctx);
    }

Domain

Subdomains

Frequently Asked Questions

What does setup() do?
setup() is a function in the netty codebase, defined in codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java.
Where is setup() defined?
setup() is defined in codec-http2/src/test/java/io/netty/handler/codec/http2/StreamBufferingEncoderTest.java at line 104.
What does setup() call?
setup() calls 2 function(s): noopAnswer, successAnswer.

Analyze Your Own Codebase

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

Try Supermodel Free