Home / Class/ DefaultSocks5CommandResponseTest Class — netty Architecture

DefaultSocks5CommandResponseTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  e01c7dc8_7557_4308_a80b_72f78a32ae96["DefaultSocks5CommandResponseTest"]
  ed87bcba_2cde_dd8c_e1fb_0142657e8c2e["DefaultSocks5CommandResponseTest.java"]
  e01c7dc8_7557_4308_a80b_72f78a32ae96 -->|defined in| ed87bcba_2cde_dd8c_e1fb_0142657e8c2e
  85338175_8c32_c918_7b55_3acb5e56fdad["testConstructorParamsAreNotNull()"]
  e01c7dc8_7557_4308_a80b_72f78a32ae96 -->|method| 85338175_8c32_c918_7b55_3acb5e56fdad
  31c5ad72_9dd2_9cca_34db_99d364adc3cd["testEmptyDomain()"]
  e01c7dc8_7557_4308_a80b_72f78a32ae96 -->|method| 31c5ad72_9dd2_9cca_34db_99d364adc3cd
  bdb1f112_5940_2a72_2ecf_e595429ca4bc["testIPv4Host()"]
  e01c7dc8_7557_4308_a80b_72f78a32ae96 -->|method| bdb1f112_5940_2a72_2ecf_e595429ca4bc
  ee4169bb_ae8c_b389_f14c_852cd504f74e["testEmptyBoundAddress()"]
  e01c7dc8_7557_4308_a80b_72f78a32ae96 -->|method| ee4169bb_ae8c_b389_f14c_852cd504f74e
  0995d4f9_f08d_1b6c_0c84_95e88bffe174["testInvalidBoundAddress()"]
  e01c7dc8_7557_4308_a80b_72f78a32ae96 -->|method| 0995d4f9_f08d_1b6c_0c84_95e88bffe174
  449e07db_693f_b642_fc12_ae4f35b98d28["assertByteBufEquals()"]
  e01c7dc8_7557_4308_a80b_72f78a32ae96 -->|method| 449e07db_693f_b642_fc12_ae4f35b98d28
  2155efc4_5c52_16ce_6c6f_aca308c87c91["testValidPortRange()"]
  e01c7dc8_7557_4308_a80b_72f78a32ae96 -->|method| 2155efc4_5c52_16ce_6c6f_aca308c87c91

Relationship Graph

Source Code

codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/DefaultSocks5CommandResponseTest.java lines 28–153

public class DefaultSocks5CommandResponseTest {
    @Test
    public void testConstructorParamsAreNotNull() {
        try {
            new DefaultSocks5CommandResponse(null, Socks5AddressType.DOMAIN);
        } catch (Exception e) {
            assertTrue(e instanceof NullPointerException);
        }
        try {
            new DefaultSocks5CommandResponse(Socks5CommandStatus.FAILURE, null);
        } catch (Exception e) {
            assertTrue(e instanceof NullPointerException);
        }
    }

    /**
     * Verifies content of the response when domain is not specified.
     */
    @Test
    public void testEmptyDomain() {
        Socks5CommandResponse socks5CmdResponse = new DefaultSocks5CommandResponse(
                Socks5CommandStatus.SUCCESS, Socks5AddressType.DOMAIN);
        assertNull(socks5CmdResponse.bndAddr());
        assertEquals(0, socks5CmdResponse.bndPort());

        ByteBuf buffer = Socks5CommonTestUtils.encodeServer(socks5CmdResponse);
        byte[] expected = {
                0x05, // version
                0x00, // success reply
                0x00, // reserved
                0x03, // address type domain
                0x00, // length of domain
                0x00, // port value
                0x00
        };
        assertByteBufEquals(expected, buffer);
        buffer.release();
    }

    /**
     * Verifies content of the response when IPv4 address is specified.
     */
    @Test
    public void testIPv4Host() {
        Socks5CommandResponse socks5CmdResponse = new DefaultSocks5CommandResponse(
                Socks5CommandStatus.SUCCESS, Socks5AddressType.IPv4, "127.0.0.1", 80);
        assertEquals("127.0.0.1", socks5CmdResponse.bndAddr());
        assertEquals(80, socks5CmdResponse.bndPort());

        ByteBuf buffer = Socks5CommonTestUtils.encodeServer(socks5CmdResponse);
        byte[] expected = {
                0x05, // version
                0x00, // success reply
                0x00, // reserved
                0x01, // address type IPv4
                0x7F, // address 127.0.0.1
                0x00,
                0x00,
                0x01,
                0x00, // port
                0x50
                };
        assertByteBufEquals(expected, buffer);
        buffer.release();
    }

    /**
     * Verifies that empty domain is allowed Response.
     */
    @Test
    public void testEmptyBoundAddress() {
        Socks5CommandResponse socks5CmdResponse = new DefaultSocks5CommandResponse(
                Socks5CommandStatus.SUCCESS, Socks5AddressType.DOMAIN, "", 80);
        assertEquals("", socks5CmdResponse.bndAddr());
        assertEquals(80, socks5CmdResponse.bndPort());

        ByteBuf buffer = Socks5CommonTestUtils.encodeServer(socks5CmdResponse);
        byte[] expected = {
                0x05, // version
                0x00, // success reply
                0x00, // reserved

Frequently Asked Questions

What is the DefaultSocks5CommandResponseTest class?
DefaultSocks5CommandResponseTest is a class in the netty codebase, defined in codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/DefaultSocks5CommandResponseTest.java.
Where is DefaultSocks5CommandResponseTest defined?
DefaultSocks5CommandResponseTest is defined in codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/DefaultSocks5CommandResponseTest.java at line 28.

Analyze Your Own Codebase

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

Try Supermodel Free