Home / Class/ Http2ClientUpgradeCodecTest Class — netty Architecture

Http2ClientUpgradeCodecTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  6a7cc45f_da6d_114a_431c_4c918d4aed61["Http2ClientUpgradeCodecTest"]
  962040bb_d746_0698_4041_d9b7459c2759["Http2ClientUpgradeCodecTest.java"]
  6a7cc45f_da6d_114a_431c_4c918d4aed61 -->|defined in| 962040bb_d746_0698_4041_d9b7459c2759
  23697de5_1395_bc7d_c1f7_1512b84d6e7f["testUpgradeToHttp2ConnectionHandler()"]
  6a7cc45f_da6d_114a_431c_4c918d4aed61 -->|method| 23697de5_1395_bc7d_c1f7_1512b84d6e7f
  94cf2f90_a330_e104_ce0c_aa7e3708d5c6["testUpgradeToHttp2FrameCodec()"]
  6a7cc45f_da6d_114a_431c_4c918d4aed61 -->|method| 94cf2f90_a330_e104_ce0c_aa7e3708d5c6
  e0a973db_9ce6_02ce_54a6_011f4da02e0b["testUpgradeToHttp2MultiplexCodec()"]
  6a7cc45f_da6d_114a_431c_4c918d4aed61 -->|method| e0a973db_9ce6_02ce_54a6_011f4da02e0b
  4c53ef62_a0fe_543d_f1ae_34bad6b90abb["testUpgradeToHttp2FrameCodecWithMultiplexer()"]
  6a7cc45f_da6d_114a_431c_4c918d4aed61 -->|method| 4c53ef62_a0fe_543d_f1ae_34bad6b90abb
  841a489a_2b43_8386_4324_5135b611f75b["testUpgrade()"]
  6a7cc45f_da6d_114a_431c_4c918d4aed61 -->|method| 841a489a_2b43_8386_4324_5135b611f75b

Relationship Graph

Source Code

codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ClientUpgradeCodecTest.java lines 30–86

public class Http2ClientUpgradeCodecTest {

    @Test
    public void testUpgradeToHttp2ConnectionHandler() throws Exception {
        testUpgrade(new Http2ConnectionHandlerBuilder().server(false).frameListener(
            new Http2FrameAdapter()).build(), null);
    }

    @Test
    public void testUpgradeToHttp2FrameCodec() throws Exception {
        testUpgrade(Http2FrameCodecBuilder.forClient().build(), null);
    }

    @Test
    public void testUpgradeToHttp2MultiplexCodec() throws Exception {
        testUpgrade(Http2MultiplexCodecBuilder.forClient(new HttpInboundHandler())
            .withUpgradeStreamHandler(new ChannelInboundHandlerAdapter()).build(), null);
    }

    @Test
    public void testUpgradeToHttp2FrameCodecWithMultiplexer() throws Exception {
        testUpgrade(Http2FrameCodecBuilder.forClient().build(),
            new Http2MultiplexHandler(new HttpInboundHandler(), new HttpInboundHandler()));
    }

    private static void testUpgrade(Http2ConnectionHandler handler, Http2MultiplexHandler multiplexer)
            throws Exception {
        FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "*");

        EmbeddedChannel channel = new EmbeddedChannel(new ChannelInboundHandlerAdapter());
        ChannelHandlerContext ctx = channel.pipeline().firstContext();

        Http2ClientUpgradeCodec codec;

        if (multiplexer == null) {
            codec = new Http2ClientUpgradeCodec("connectionHandler", handler);
        } else {
            codec = new Http2ClientUpgradeCodec("connectionHandler", handler, multiplexer);
        }

        codec.setUpgradeHeaders(ctx, request);
        // Flush the channel to ensure we write out all buffered data
        channel.flush();

        codec.upgradeTo(ctx, null);
        assertNotNull(channel.pipeline().get("connectionHandler"));

        if (multiplexer != null) {
            assertNotNull(channel.pipeline().get(Http2MultiplexHandler.class));
        }

        assertTrue(channel.finishAndReleaseAll());
    }

    @ChannelHandler.Sharable
    private static final class HttpInboundHandler extends ChannelInboundHandlerAdapter { }
}

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free