Home / Class/ BinaryMemcacheDecoderTest Class — netty Architecture

BinaryMemcacheDecoderTest Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  842bad71_a9e0_a6bb_4ffc_95b572e61d71["BinaryMemcacheDecoderTest"]
  f8eb1495_e1e0_c1fd_453e_71820f1c0076["BinaryMemcacheDecoderTest.java"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|defined in| f8eb1495_e1e0_c1fd_453e_71820f1c0076
  5c1b57e2_426f_b98c_f54d_4ea4dc8abaac["setup()"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|method| 5c1b57e2_426f_b98c_f54d_4ea4dc8abaac
  65c39d3c_ae34_3e25_9404_f1565dddc0e5["teardown()"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|method| 65c39d3c_ae34_3e25_9404_f1565dddc0e5
  1403dcd7_4d56_3241_d601_aaadfde13296["shouldDecodeRequestWithSimpleValue()"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|method| 1403dcd7_4d56_3241_d601_aaadfde13296
  2994473e_8fa2_990b_da70_70a70d514569["shouldDecodeRequestWithChunkedContent()"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|method| 2994473e_8fa2_990b_da70_70a70d514569
  e4db78e1_92cd_7e9c_c21b_3ce1448c05ad["shouldHandleNonUniformNetworkBatches()"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|method| e4db78e1_92cd_7e9c_c21b_3ce1448c05ad
  15980d85_6f9a_55bf_7c13_5711a8d24e21["shouldHandleTwoMessagesInOneBatch()"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|method| 15980d85_6f9a_55bf_7c13_5711a8d24e21
  87bc1987_2aff_9766_072f_43193fb410d1["shouldDecodeSeparatedValues()"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|method| 87bc1987_2aff_9766_072f_43193fb410d1
  89585020_e0bd_a6c5_8733_78f21837d99b["shouldRetainCurrentMessageWhenSendingItOut()"]
  842bad71_a9e0_a6bb_4ffc_95b572e61d71 -->|method| 89585020_e0bd_a6c5_8733_78f21837d99b

Relationship Graph

Source Code

codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java lines 41–276

public class BinaryMemcacheDecoderTest {

    /**
     * Represents a GET request header with a key size of three.
     */
    private static final byte[] GET_REQUEST = {
        (byte) 0x80, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6f, 0x6f
    };

    private static final byte[] SET_REQUEST_WITH_CONTENT = {
        (byte) 0x80, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x6f, 0x6f, 0x01, 0x02, 0x03, 0x04, 0x05,
        0x06, 0x07, 0x08
    };

    private static final byte[] GET_RESPONSE_CHUNK_1 =  {
        (byte) 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e,
        0x64, (byte) 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75,
    };

    private static final byte[] GET_RESPONSE_CHUNK_2 = {
            0x6e, 0x64, (byte) 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f,
            0x75, 0x6e, 0x64
    };

    private EmbeddedChannel channel;

    @BeforeEach
    public void setup() throws Exception {
        channel = new EmbeddedChannel(new BinaryMemcacheRequestDecoder());
    }

    @AfterEach
    public void teardown() throws Exception {
        channel.finishAndReleaseAll();
    }

    /**
     * This tests a simple GET request with a key as the value.
     */
    @Test
    public void shouldDecodeRequestWithSimpleValue() {
        ByteBuf incoming = Unpooled.buffer();
        incoming.writeBytes(GET_REQUEST);
        channel.writeInbound(incoming);

        BinaryMemcacheRequest request = channel.readInbound();

        assertNotNull(request);
        assertNotNull(request.key());
        assertNull(request.extras());

        assertEquals((short) 3, request.keyLength());
        assertEquals((byte) 0, request.extrasLength());
        assertEquals(3, request.totalBodyLength());

        request.release();
        assertInstanceOf(LastMemcacheContent.class, channel.readInbound());
    }

    /**
     * This test makes sure that large content is emitted in chunks.
     */
    @Test
    public void shouldDecodeRequestWithChunkedContent() {
        int smallBatchSize = 2;
        channel = new EmbeddedChannel(new BinaryMemcacheRequestDecoder(smallBatchSize));

        ByteBuf incoming = Unpooled.buffer();
        incoming.writeBytes(SET_REQUEST_WITH_CONTENT);
        channel.writeInbound(incoming);

        BinaryMemcacheRequest request = channel.readInbound();

        assertNotNull(request);
        assertNotNull(request.key());
        assertNull(request.extras());

Frequently Asked Questions

What is the BinaryMemcacheDecoderTest class?
BinaryMemcacheDecoderTest is a class in the netty codebase, defined in codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java.
Where is BinaryMemcacheDecoderTest defined?
BinaryMemcacheDecoderTest is defined in codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java at line 41.

Analyze Your Own Codebase

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

Try Supermodel Free