Home / Class/ KQueueChannelConfigTest Class — netty Architecture

KQueueChannelConfigTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  f5c650c9_a464_cc61_c859_bf9e0f794480["KQueueChannelConfigTest"]
  62163b5e_5fae_1acf_e205_9fcab5e50f89["KQueueChannelConfigTest.java"]
  f5c650c9_a464_cc61_c859_bf9e0f794480 -->|defined in| 62163b5e_5fae_1acf_e205_9fcab5e50f89
  eabbfb9c_772e_a495_9160_8a86732f0f8f["before()"]
  f5c650c9_a464_cc61_c859_bf9e0f794480 -->|method| eabbfb9c_772e_a495_9160_8a86732f0f8f
  0be4fd0d_60e8_eae9_7cd7_e6adcc3b53c6["testOptionGetThrowsChannelException()"]
  f5c650c9_a464_cc61_c859_bf9e0f794480 -->|method| 0be4fd0d_60e8_eae9_7cd7_e6adcc3b53c6
  0f3512bd_1421_043c_0807_4314491809e8["testOptionSetThrowsChannelException()"]
  f5c650c9_a464_cc61_c859_bf9e0f794480 -->|method| 0f3512bd_1421_043c_0807_4314491809e8
  8425fb37_f65b_4094_41b5_e2989cda26cf["testSoLingerNoAssertError()"]
  f5c650c9_a464_cc61_c859_bf9e0f794480 -->|method| 8425fb37_f65b_4094_41b5_e2989cda26cf
  7729fb06_dbf6_2d86_23a2_9197be70df36["testIntegerOption()"]
  f5c650c9_a464_cc61_c859_bf9e0f794480 -->|method| 7729fb06_dbf6_2d86_23a2_9197be70df36
  980ad931_58af_48d0_a6eb_87454eb53591["testRawOption()"]
  f5c650c9_a464_cc61_c859_bf9e0f794480 -->|method| 980ad931_58af_48d0_a6eb_87454eb53591

Relationship Graph

Source Code

transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueChannelConfigTest.java lines 39–122

public class KQueueChannelConfigTest {
    @BeforeEach
    public void before() {
        KQueue.ensureAvailability();
    }

    @Test
    public void testOptionGetThrowsChannelException() throws Exception {
        KQueueSocketChannel channel = new KQueueSocketChannel();
        channel.config().getSoLinger();
        channel.fd().close();
        try {
            channel.config().getSoLinger();
            fail();
        } catch (ChannelException e) {
            // expected
        }
    }

    @Test
    public void testOptionSetThrowsChannelException() throws Exception {
        KQueueSocketChannel channel = new KQueueSocketChannel();
        channel.config().setKeepAlive(true);
        channel.fd().close();
        try {
            channel.config().setKeepAlive(true);
            fail();
        } catch (ChannelException e) {
            // expected
        }
    }

    // See https://github.com/netty/netty/issues/7159
    @Test
    public void testSoLingerNoAssertError() throws Exception {
        EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, KQueueIoHandler.newFactory());

        try {
            Bootstrap bootstrap = new Bootstrap();
            KQueueSocketChannel ch = (KQueueSocketChannel) bootstrap.group(group)
                    .channel(KQueueSocketChannel.class)
                    .option(ChannelOption.SO_LINGER, 10)
                    .handler(new ChannelInboundHandlerAdapter())
                    .bind(new InetSocketAddress(0)).syncUninterruptibly().channel();
            ch.close().syncUninterruptibly();
        } finally {
            group.shutdownGracefully();
        }
    }

    @Test
    public void testIntegerOption() throws Exception {
        KQueueSocketChannel channel = new KQueueSocketChannel();
        IntegerUnixChannelOption opt = new IntegerUnixChannelOption("INT_OPT", 0xffff, 0x0004);
        Integer zero = 0;
        assertEquals(zero, channel.config().getOption(opt));
        channel.config().setOption(opt, 1);
        assertNotEquals(zero, channel.config().getOption(opt));
        channel.fd().close();
    }

    @Test
    public void testRawOption() throws Exception {
        KQueueSocketChannel channel = new KQueueSocketChannel();
        // Value for SOL_SOCKET and SO_REUSEADDR
        // See https://opensource.apple.com/source/xnu/xnu-201/bsd/sys/socket.h.auto.html
        RawUnixChannelOption opt = new RawUnixChannelOption("RAW_OPT", 0xffff, 0x0004, 4);

        CleanableDirectBuffer disabledCleanable = Buffer.allocateDirectBufferWithNativeOrder(4);
        ByteBuffer disabled = disabledCleanable.buffer();
        disabled.putInt(0).flip();
        assertEquals(disabled, channel.config().getOption(opt));

        CleanableDirectBuffer enabledCleanable = Buffer.allocateDirectBufferWithNativeOrder(4);
        ByteBuffer enabled = enabledCleanable.buffer();
        enabled.putInt(1).flip();

        channel.config().setOption(opt, enabled);
        assertNotEquals(disabled, channel.config().getOption(opt));
        channel.fd().close();
        disabledCleanable.clean();

Frequently Asked Questions

What is the KQueueChannelConfigTest class?
KQueueChannelConfigTest is a class in the netty codebase, defined in transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueChannelConfigTest.java.
Where is KQueueChannelConfigTest defined?
KQueueChannelConfigTest is defined in transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueChannelConfigTest.java at line 39.

Analyze Your Own Codebase

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

Try Supermodel Free