Home / Class/ ServerBootstrapTest Class — netty Architecture

ServerBootstrapTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  ea70f915_ade9_644f_5c4a_f1b52d559227["ServerBootstrapTest"]
  4cb25767_9d7b_ae03_fd96_1d9f233d2145["ServerBootstrapTest.java"]
  ea70f915_ade9_644f_5c4a_f1b52d559227 -->|defined in| 4cb25767_9d7b_ae03_fd96_1d9f233d2145
  684a2544_8fc4_b5e1_4801_b0f754017f46["testSetOptionsThrow()"]
  ea70f915_ade9_644f_5c4a_f1b52d559227 -->|method| 684a2544_8fc4_b5e1_4801_b0f754017f46
  9d4156da_42a4_7689_3b2f_7bb887bd014f["testHandlerRegister()"]
  ea70f915_ade9_644f_5c4a_f1b52d559227 -->|method| 9d4156da_42a4_7689_3b2f_7bb887bd014f
  849b43bf_92b2_5490_9e6a_722445b1b448["testParentHandler()"]
  ea70f915_ade9_644f_5c4a_f1b52d559227 -->|method| 849b43bf_92b2_5490_9e6a_722445b1b448
  4fbf71dd_fd1a_aa88_751e_788b5cc479b3["testParentHandlerViaChannelInitializer()"]
  ea70f915_ade9_644f_5c4a_f1b52d559227 -->|method| 4fbf71dd_fd1a_aa88_751e_788b5cc479b3
  f82d1300_2427_7857_c406_c8772495c3a3["optionsAndAttributesMustBeAvailableOnChildChannelInit()"]
  ea70f915_ade9_644f_5c4a_f1b52d559227 -->|method| f82d1300_2427_7857_c406_c8772495c3a3
  7998833b_0ad4_de6a_47d6_2a6cb97dfde0["mustCallInitializerExtensions()"]
  ea70f915_ade9_644f_5c4a_f1b52d559227 -->|method| 7998833b_0ad4_de6a_47d6_2a6cb97dfde0

Relationship Graph

Source Code

transport/src/test/java/io/netty/bootstrap/ServerBootstrapTest.java lines 53–280

public class ServerBootstrapTest {

    @Test
    public void testSetOptionsThrow() {
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
        try {
            final ChannelFuture cf = new ServerBootstrap()
                    .group(group)
                    .channelFactory(new ChannelFactory<ServerChannel>() {
                        @Override
                        public ServerChannel newChannel() {
                            return new TestServerChannel();
                        }
                    })
                    .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 4242)
                    .handler(new ChannelInboundHandlerAdapter())
                    .childHandler(new ChannelInboundHandlerAdapter())
                    .register();

            assertThrows(UnsupportedOperationException.class, new Executable() {
                @Override
                public void execute() throws Throwable {
                    cf.syncUninterruptibly();
                }
            });
            assertFalse(cf.channel().isActive());
        } finally {
            group.shutdownGracefully();
        }
    }

    @Test
    @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
    public void testHandlerRegister() throws Exception {
        final CountDownLatch latch = new CountDownLatch(1);
        final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
        try {
            ServerBootstrap sb = new ServerBootstrap();
            sb.channel(LocalServerChannel.class)
              .group(group)
              .childHandler(new ChannelInboundHandlerAdapter())
              .handler(new ChannelHandlerAdapter() {
                  @Override
                  public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
                      try {
                          assertTrue(ctx.executor().inEventLoop());
                      } catch (Throwable cause) {
                          error.set(cause);
                      } finally {
                          latch.countDown();
                      }
                  }
              });
            sb.register().syncUninterruptibly();
            latch.await();
            assertNull(error.get());
        } finally {
            group.shutdownGracefully();
        }
    }

    @Test
    @Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
    public void testParentHandler() throws Exception {
        testParentHandler(false);
    }

    @Test
    @Timeout(value = 3000, unit = TimeUnit.MILLISECONDS)
    public void testParentHandlerViaChannelInitializer() throws Exception {
        testParentHandler(true);
    }

    private static void testParentHandler(boolean channelInitializer) throws Exception {
        final LocalAddress addr = new LocalAddress(UUID.randomUUID().toString());
        final CountDownLatch readLatch = new CountDownLatch(1);
        final CountDownLatch initLatch = new CountDownLatch(1);

        final ChannelHandler handler = new ChannelInboundHandlerAdapter() {
            @Override

Frequently Asked Questions

What is the ServerBootstrapTest class?
ServerBootstrapTest is a class in the netty codebase, defined in transport/src/test/java/io/netty/bootstrap/ServerBootstrapTest.java.
Where is ServerBootstrapTest defined?
ServerBootstrapTest is defined in transport/src/test/java/io/netty/bootstrap/ServerBootstrapTest.java at line 53.

Analyze Your Own Codebase

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

Try Supermodel Free