Home / Class/ Http2FrameCodecTest Class — netty Architecture

Http2FrameCodecTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c["Http2FrameCodecTest"]
  ac4b0b25_b2f4_7618_4ecb_5c49943a5756["Http2FrameCodecTest.java"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|defined in| ac4b0b25_b2f4_7618_4ecb_5c49943a5756
  868f866c_1fcb_c067_1110_d326c0e4d94b["setUp()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| 868f866c_1fcb_c067_1110_d326c0e4d94b
  ee3ac301_c62a_f284_aea1_90c154a34caa["tearDown()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| ee3ac301_c62a_f284_aea1_90c154a34caa
  220ce60e_282e_a12d_b6ae_a5f8c2f25fc5["stateChanges()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| 220ce60e_282e_a12d_b6ae_a5f8c2f25fc5
  3b97ac86_f171_4b1b_4f93_24233ae39a78["headerRequestHeaderResponse()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| 3b97ac86_f171_4b1b_4f93_24233ae39a78
  a193ee97_5cac_69e5_57e5_f0a41a196061["flowControlShouldBeResilientToMissingStreams()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| a193ee97_5cac_69e5_57e5_f0a41a196061
  2c5a26b8_d76c_6240_131a_6816aa46c449["canCreateCustomUnknownFrame()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| 2c5a26b8_d76c_6240_131a_6816aa46c449
  dd8cad60_7ec8_75c0_7085_0a2323c15234["entityRequestEntityResponse()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| dd8cad60_7ec8_75c0_7085_0a2323c15234
  2c7872fb_3e9f_346a_d6ab_f5f7843dd8f9["sendRstStream()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| 2c7872fb_3e9f_346a_d6ab_f5f7843dd8f9
  03b9de62_bc6d_e46e_0624_0e7ac0091714["receiveRstStream()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| 03b9de62_bc6d_e46e_0624_0e7ac0091714
  33bebf89_dcc2_a260_076b_e15cedd343e8["sendGoAway()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| 33bebf89_dcc2_a260_076b_e15cedd343e8
  b0cb90a4_d2d8_144d_ddc9_65aad57cbbe9["receiveGoaway()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| b0cb90a4_d2d8_144d_ddc9_65aad57cbbe9
  85136a15_32e2_f20a_fcea_44cccb0909a9["unknownFrameTypeShouldThrowAndBeReleased()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| 85136a15_32e2_f20a_fcea_44cccb0909a9
  fa3cb425_2047_eb20_476b_98cd06b6a498["unknownFrameTypeOnConnectionStream()"]
  71f17950_8fc4_c3e9_2e13_384d1ac7ea2c -->|method| fa3cb425_2047_eb20_476b_98cd06b6a498

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/Http2FrameCodecTest.java lines 85–1027

public class Http2FrameCodecTest {

    // For verifying outbound frames
    private Http2FrameWriter frameWriter;
    private Http2FrameCodec frameCodec;
    private EmbeddedChannel channel;

    // For injecting inbound frames
    private Http2FrameInboundWriter frameInboundWriter;

    private LastInboundHandler inboundHandler;

    private final Http2Headers request = new DefaultHttp2Headers()
            .method(HttpMethod.GET.asciiName()).scheme(HttpScheme.HTTPS.name())
            .authority(new AsciiString("example.org")).path(new AsciiString("/foo"));
    private final Http2Headers response = new DefaultHttp2Headers()
            .status(HttpResponseStatus.OK.codeAsText());

    @BeforeEach
    public void setUp() throws Exception {
        setUp(Http2FrameCodecBuilder.forServer(), new Http2Settings());
    }

    @AfterEach
    public void tearDown() throws Exception {
        if (inboundHandler != null) {
            inboundHandler.finishAndReleaseAll();
            inboundHandler = null;
        }
        if (channel != null) {
            channel.finishAndReleaseAll();
            channel.close();
            channel = null;
        }
    }

    private void setUp(Http2FrameCodecBuilder frameCodecBuilder, Http2Settings initialRemoteSettings) throws Exception {
        setUp(frameCodecBuilder, initialRemoteSettings, true);
    }

    private void setUp(Http2FrameCodecBuilder frameCodecBuilder, Http2Settings initialRemoteSettings, boolean preface)
            throws Exception {
        /*
         * Some tests call this method twice. Once with JUnit's @Before and once directly to pass special settings.
         * This call ensures that in case of two consecutive calls to setUp(), the previous channel is shutdown and
         * ByteBufs are released correctly.
         */
        tearDown();

        frameWriter = Http2TestUtil.mockedFrameWriter();

        frameCodec = frameCodecBuilder.frameWriter(frameWriter).frameLogger(new Http2FrameLogger(LogLevel.TRACE))
                .initialSettings(initialRemoteSettings).build();
        inboundHandler = new LastInboundHandler();

        channel = new EmbeddedChannel();
        frameInboundWriter = new Http2FrameInboundWriter(channel);
        channel.connect(new InetSocketAddress(0));
        channel.pipeline().addLast(frameCodec);
        channel.pipeline().addLast(inboundHandler);
        channel.pipeline().fireChannelActive();

        // Handshake
        verify(frameWriter).writeSettings(eqFrameCodecCtx(), anyHttp2Settings(), anyChannelPromise());
        verifyNoMoreInteractions(frameWriter);

        if (preface) {
            channel.writeInbound(Http2CodecUtil.connectionPrefaceBuf());

            frameInboundWriter.writeInboundSettings(initialRemoteSettings);

            verify(frameWriter).writeSettingsAck(eqFrameCodecCtx(), anyChannelPromise());

            frameInboundWriter.writeInboundSettingsAck();

            Http2SettingsFrame settingsFrame = inboundHandler.readInbound();
            assertNotNull(settingsFrame);
            Http2SettingsAckFrame settingsAckFrame = inboundHandler.readInbound();
            assertNotNull(settingsAckFrame);
        }
    }

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free