Home / Function/ testTLVEncodeProxy() — netty Function Reference

testTLVEncodeProxy() — netty Function Reference

Architecture documentation for the testTLVEncodeProxy() function in HaProxyMessageEncoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  09712c06_4bf8_0520_4bbd_891fba66c7c4["testTLVEncodeProxy()"]
  4545ac9d_2f62_4ac7_c80f_5975d8175456["HaProxyMessageEncoderTest"]
  09712c06_4bf8_0520_4bbd_891fba66c7c4 -->|defined in| 4545ac9d_2f62_4ac7_c80f_5975d8175456
  style 09712c06_4bf8_0520_4bbd_891fba66c7c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HaProxyMessageEncoderTest.java lines 231–272

    @Test
    public void testTLVEncodeProxy() {
        EmbeddedChannel ch = new EmbeddedChannel(INSTANCE);

        List<HAProxyTLV> tlvs = new ArrayList<HAProxyTLV>();

        ByteBuf helloWorld = Unpooled.copiedBuffer("hello world", CharsetUtil.US_ASCII);
        HAProxyTLV alpnTlv = new HAProxyTLV(Type.PP2_TYPE_ALPN, (byte) 0x01, helloWorld.copy());
        tlvs.add(alpnTlv);

        ByteBuf arbitrary = Unpooled.copiedBuffer("an arbitrary string", CharsetUtil.US_ASCII);
        HAProxyTLV authorityTlv = new HAProxyTLV(Type.PP2_TYPE_AUTHORITY, (byte) 0x01, arbitrary.copy());
        tlvs.add(authorityTlv);

        HAProxyMessage message = new HAProxyMessage(
                HAProxyProtocolVersion.V2, HAProxyCommand.PROXY, HAProxyProxiedProtocol.TCP4,
                "192.168.0.1", "192.168.0.11", 56324, 443, tlvs);
        assertTrue(ch.writeOutbound(message));

        ByteBuf byteBuf = ch.readOutbound();

        // length
        assertEquals(byteBuf.getUnsignedShort(14), byteBuf.readableBytes() - V2_HEADER_BYTES_LENGTH);

        // skip to tlv section
        ByteBuf tlv = byteBuf.skipBytes(V2_HEADER_BYTES_LENGTH + IPv4_ADDRESS_BYTES_LENGTH);

        // alpn tlv
        assertEquals(alpnTlv.typeByteValue(), tlv.readByte());
        short bufLength = tlv.readShort();
        assertEquals(helloWorld.array().length, bufLength);
        assertEquals(helloWorld, tlv.readSlice(bufLength));

        // authority tlv
        assertEquals(authorityTlv.typeByteValue(), tlv.readByte());
        bufLength = tlv.readShort();
        assertEquals(arbitrary.array().length, bufLength);
        assertEquals(arbitrary, tlv.readSlice(bufLength));

        byteBuf.release();
        assertFalse(ch.finish());
    }

Domain

Subdomains

Frequently Asked Questions

What does testTLVEncodeProxy() do?
testTLVEncodeProxy() is a function in the netty codebase, defined in codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HaProxyMessageEncoderTest.java.
Where is testTLVEncodeProxy() defined?
testTLVEncodeProxy() is defined in codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HaProxyMessageEncoderTest.java at line 231.

Analyze Your Own Codebase

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

Try Supermodel Free