Home / Class/ TestHandler Class — netty Architecture

TestHandler Class — netty Architecture

Architecture documentation for the TestHandler class in SocketFileRegionTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  10e97476_1f4e_884d_9a84_89bb17909051["TestHandler"]
  17fd8e85_6deb_f666_7391_71f550ae0452["SocketFileRegionTest.java"]
  10e97476_1f4e_884d_9a84_89bb17909051 -->|defined in| 17fd8e85_6deb_f666_7391_71f550ae0452
  f0916c46_958b_fb7e_b632_7b039f808296["TestHandler()"]
  10e97476_1f4e_884d_9a84_89bb17909051 -->|method| f0916c46_958b_fb7e_b632_7b039f808296
  99189f80_5cd6_6cd2_a739_b34b25b517ea["channelActive()"]
  10e97476_1f4e_884d_9a84_89bb17909051 -->|method| 99189f80_5cd6_6cd2_a739_b34b25b517ea
  f57b4fd0_ce30_5126_0750_098594d0bb59["channelRead0()"]
  10e97476_1f4e_884d_9a84_89bb17909051 -->|method| f57b4fd0_ce30_5126_0750_098594d0bb59
  8bcbdcff_6a4a_9210_68f3_ec9838d34fa5["channelReadComplete()"]
  10e97476_1f4e_884d_9a84_89bb17909051 -->|method| 8bcbdcff_6a4a_9210_68f3_ec9838d34fa5
  7f016959_f7c8_b589_846c_4ee88d1f39be["exceptionCaught()"]
  10e97476_1f4e_884d_9a84_89bb17909051 -->|method| 7f016959_f7c8_b589_846c_4ee88d1f39be

Relationship Graph

Source Code

testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFileRegionTest.java lines 272–317

    private static class TestHandler extends SimpleChannelInboundHandler<ByteBuf> {
        private final boolean autoRead;
        volatile Channel channel;
        final AtomicReference<Throwable> exception = new AtomicReference<Throwable>();
        volatile int counter;

        TestHandler(boolean autoRead) {
            this.autoRead = autoRead;
        }

        @Override
        public void channelActive(ChannelHandlerContext ctx)
                throws Exception {
            channel = ctx.channel();
            if (!autoRead) {
                ctx.read();
            }
        }

        @Override
        public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception {
            byte[] actual = new byte[in.readableBytes()];
            in.readBytes(actual);

            int lastIdx = counter;
            for (int i = 0; i < actual.length; i ++) {
                assertEquals(data[i + lastIdx], actual[i]);
            }
            counter += actual.length;
        }

        @Override
        public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
            if (!autoRead) {
                ctx.read();
            }
        }

        @Override
        public void exceptionCaught(ChannelHandlerContext ctx,
                Throwable cause) throws Exception {
            if (exception.compareAndSet(null, cause)) {
                ctx.close();
            }
        }
    }

Frequently Asked Questions

What is the TestHandler class?
TestHandler is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFileRegionTest.java.
Where is TestHandler defined?
TestHandler is defined in testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketFileRegionTest.java at line 272.

Analyze Your Own Codebase

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

Try Supermodel Free