Home / Class/ BootstrapTest Class — netty Architecture

BootstrapTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42["BootstrapTest"]
  e9ee9a00_988f_9508_1e47_b48bd2b962d3["BootstrapTest.java"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|defined in| e9ee9a00_988f_9508_1e47_b48bd2b962d3
  2f068845_2303_1b00_4447_dffd32abf2f4["destroy()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| 2f068845_2303_1b00_4447_dffd32abf2f4
  20e6f297_723b_384d_5ec1_b8c128c02d27["testSetOptionsThrow()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| 20e6f297_723b_384d_5ec1_b8c128c02d27
  7e5a14a0_4fdd_86e4_cab5_623871caec19["testOptionsCopied()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| 7e5a14a0_4fdd_86e4_cab5_623871caec19
  a4fd8344_788a_a33d_8b0b_21ed7be03f9c["testAttributesCopied()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| a4fd8344_788a_a33d_8b0b_21ed7be03f9c
  825388b1_2b3d_d6c5_e500_406f1feeb401["optionsAndAttributesMustBeAvailableOnChannelInit()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| 825388b1_2b3d_d6c5_e500_406f1feeb401
  ec02620b_b2da_3122_a397_bf5696c4602c["testBindDeadLock()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| ec02620b_b2da_3122_a397_bf5696c4602c
  89471cb4_eb74_6159_3ac1_58b8d4b146e3["testConnectDeadLock()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| 89471cb4_eb74_6159_3ac1_58b8d4b146e3
  61506973_ddc4_9462_a467_6079be419119["testLateRegisterSuccess()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| 61506973_ddc4_9462_a467_6079be419119
  76618058_54f9_1ad0_d1bf_f6bda033b31e["testLateRegisterSuccessBindFailed()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| 76618058_54f9_1ad0_d1bf_f6bda033b31e
  cc592760_a495_7136_21dd_a76b0b77a33e["testLateRegistrationConnect()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| cc592760_a495_7136_21dd_a76b0b77a33e
  719c8481_1da5_19bb_63a0_3292e66aeda3["testResolverDefault()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| 719c8481_1da5_19bb_63a0_3292e66aeda3
  dd2729dd_8725_11ab_46bf_18abadbe358d["testResolverDisabled()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| dd2729dd_8725_11ab_46bf_18abadbe358d
  aec196d3_73bf_1dce_045c_dfe3d4f9d9fe["testAsyncResolutionSuccess()"]
  7a7606db_8d2a_bfe0_9993_4aaa8e0a6e42 -->|method| aec196d3_73bf_1dce_045c_dfe3d4f9d9fe

Relationship Graph

Source Code

transport/src/test/java/io/netty/bootstrap/BootstrapTest.java lines 79–615

public class BootstrapTest {

    private static final EventLoopGroup groupA = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
    private static final EventLoopGroup groupB = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
    private static final ChannelInboundHandler dummyHandler = new DummyHandler();

    @AfterAll
    public static void destroy() {
        groupA.shutdownGracefully();
        groupB.shutdownGracefully();
        groupA.terminationFuture().syncUninterruptibly();
        groupB.terminationFuture().syncUninterruptibly();
    }

    @Test
    public void testSetOptionsThrow() {
        final ChannelFuture cf = new Bootstrap()
                .group(groupA)
                .channelFactory(new ChannelFactory<Channel>() {
                    @Override
                    public Channel newChannel() {
                        return new TestChannel();
                    }
                })
                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 4242)
                .handler(new ChannelInboundHandlerAdapter())
                .register();

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

    @Test
    public void testOptionsCopied() {
        final Bootstrap bootstrapA = new Bootstrap();
        bootstrapA.option(ChannelOption.AUTO_READ, true);
        Map.Entry<ChannelOption<?>, Object>[] channelOptions = bootstrapA.newOptionsArray();
        bootstrapA.option(ChannelOption.AUTO_READ, false);
        assertEquals(ChannelOption.AUTO_READ, channelOptions[0].getKey());
        assertEquals(true, channelOptions[0].getValue());
    }

    @Test
    public void testAttributesCopied() {
        AttributeKey<String> key = AttributeKey.valueOf(UUID.randomUUID().toString());
        String value = "value";
        final Bootstrap bootstrapA = new Bootstrap();
        bootstrapA.attr(key, value);
        Map.Entry<AttributeKey<?>, Object>[] attributesArray = bootstrapA.newAttributesArray();
        bootstrapA.attr(key, "value2");
        assertEquals(key, attributesArray[0].getKey());
        assertEquals(value, attributesArray[0].getValue());
    }

    @Test
    public void optionsAndAttributesMustBeAvailableOnChannelInit() throws InterruptedException {
        final AttributeKey<String> key = AttributeKey.valueOf(UUID.randomUUID().toString());
        new Bootstrap()
                .group(groupA)
                .channel(LocalChannel.class)
                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 4242)
                .attr(key, "value")
                .handler(new ChannelInitializer<LocalChannel>() {
                    @Override
                    protected void initChannel(LocalChannel ch) throws Exception {
                        Integer option = ch.config().getOption(ChannelOption.CONNECT_TIMEOUT_MILLIS);
                        assertEquals(4242, (int) option);
                        assertEquals("value", ch.attr(key).get());
                    }
                })
                .bind(LocalAddress.ANY).sync();
    }

    @Test
    @Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
    public void testBindDeadLock() throws Exception {

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free