Home / Class/ NativeTransportTest Class — netty Architecture

NativeTransportTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  cf2ab480_cb38_d68d_b212_10cd6ceaf507["NativeTransportTest"]
  63ebc9a8_ed3b_0d3b_cc0d_a3682cb06591["NativeTransportTest.java"]
  cf2ab480_cb38_d68d_b212_10cd6ceaf507 -->|defined in| 63ebc9a8_ed3b_0d3b_cc0d_a3682cb06591
  9c7dbd49_5204_a879_ce8b_4bb886667e6c["testKQueue()"]
  cf2ab480_cb38_d68d_b212_10cd6ceaf507 -->|method| 9c7dbd49_5204_a879_ce8b_4bb886667e6c
  438f4eeb_17ae_44dd_72aa_a9eddec27dab["testEpoll()"]
  cf2ab480_cb38_d68d_b212_10cd6ceaf507 -->|method| 438f4eeb_17ae_44dd_72aa_a9eddec27dab
  dccb987c_c122_8920_1a97_bec70ab06615["testIoUring()"]
  cf2ab480_cb38_d68d_b212_10cd6ceaf507 -->|method| dccb987c_c122_8920_1a97_bec70ab06615
  e3cf72c2_5742_f496_2183_5b6382f859d4["mySetupClientHostnameValidation()"]
  cf2ab480_cb38_d68d_b212_10cd6ceaf507 -->|method| e3cf72c2_5742_f496_2183_5b6382f859d4

Relationship Graph

Source Code

testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/NativeTransportTest.java lines 55–153

public class NativeTransportTest {

    @EnabledOnOs(OS.MAC)
    @Test
    public void testKQueue() throws Exception {
        mySetupClientHostnameValidation(
                KQueueIoHandler.newFactory(),
                KQueueServerSocketChannel.class,
                KQueueSocketChannel.class);
    }

    @EnabledOnOs(OS.LINUX)
    @Test
    public void testEpoll() throws Exception {
        mySetupClientHostnameValidation(
                EpollIoHandler.newFactory(),
                EpollServerSocketChannel.class,
                EpollSocketChannel.class);
    }

    @EnabledOnOs(OS.LINUX)
    @Test
    public void testIoUring() throws Exception {
        mySetupClientHostnameValidation(
                IoUringIoHandler.newFactory(),
                IoUringServerSocketChannel.class,
                IoUringSocketChannel.class);
    }

    private void mySetupClientHostnameValidation(IoHandlerFactory ioHandlerFactory,
                                                 Class<? extends ServerSocketChannel> serverSocketChannelFactory,
                                                 Class<? extends SocketChannel> socketChannelFactory
    ) throws InterruptedException {

        ServerBootstrap sb = new ServerBootstrap();
        Bootstrap cb = new Bootstrap();

        sb.group(new MultiThreadIoEventLoopGroup(ioHandlerFactory));
        sb.channel(serverSocketChannelFactory);
        sb.childHandler(new ChannelInitializer() {
            @Override
            protected void initChannel(Channel ch) throws Exception {
                ChannelPipeline p = ch.pipeline();

                p.addLast(new ChannelInboundHandlerAdapter() {
                    @Override
                    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
                        if (msg instanceof ByteBuf) {
                            ctx.write(msg);
                        } else {
                            super.channelRead(ctx, msg);
                        }
                    }
                    @Override
                    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
                        ctx.flush();
                    }
                });
            }
        });

        List<String> received = Collections.synchronizedList(new ArrayList<>());

        cb.group(new MultiThreadIoEventLoopGroup(ioHandlerFactory));
        cb.channel(socketChannelFactory);
        cb.handler(new ChannelInitializer<Channel>() {
            @Override
            protected void initChannel(Channel ch) throws Exception {
                ChannelPipeline p = ch.pipeline();
                p.addLast(new ChannelInboundHandlerAdapter() {
                    @Override
                    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
                        if (msg instanceof ByteBuf) {
                            ByteBuf buff = (ByteBuf) msg;
                            try {
                                received.add(buff.toString(StandardCharsets.UTF_8));
                            } finally {
                                buff.release();
                            }
                        }
                    }

Frequently Asked Questions

What is the NativeTransportTest class?
NativeTransportTest is a class in the netty codebase, defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/NativeTransportTest.java.
Where is NativeTransportTest defined?
NativeTransportTest is defined in testsuite-jpms/src/test/java/io/netty/testsuite_jpms/test/NativeTransportTest.java at line 55.

Analyze Your Own Codebase

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

Try Supermodel Free