Package com.couchbase.client.deps.io.netty.buffer

Examples of com.couchbase.client.deps.io.netty.buffer.ByteBuf


        assertFalse(decoded.content());
    }

    @Test
    public void shouldReleaseBufferWhenDecoded() {
        ByteBuf content = Unpooled.copiedBuffer("false", CharsetUtil.UTF_8);
        JsonBooleanDocument decoded = converter.decode("id", content, 0, 0, TranscoderUtils.JSON_COMMON_FLAGS,
            ResponseStatus.SUCCESS);
        assertEquals(0, content.refCnt());
    }
View Full Code Here


        assertEquals(0, content.refCnt());
    }

    @Test(expected = TranscodingException.class)
    public void shouldReleaseBufferWhenError() {
        ByteBuf content = Unpooled.copiedBuffer("false", CharsetUtil.UTF_8);
        int wrongFlags = 1234;
        try {
            converter.decode("id", content, 0, 0, wrongFlags, ResponseStatus.SUCCESS);
        } finally {
            assertEquals(0, content.refCnt());
        }
    }
View Full Code Here

        assertEquals("value", document.content().toString(CharsetUtil.UTF_8));
    }

    @Test
    public void shouldNotReleaseBufferWhenDecoded() {
        ByteBuf content = ReferenceCountUtil.releaseLater(Unpooled.copiedBuffer("value", CharsetUtil.UTF_8));
        converter.decode("id", content, 0, 0, TranscoderUtils.BINARY_COMMON_FLAGS,
            ResponseStatus.SUCCESS);
        assertEquals(1, content.refCnt());
    }
View Full Code Here

        assertEquals(1, content.refCnt());
    }

    @Test(expected = TranscodingException.class)
    public void shouldReleaseBufferWhenError() {
        ByteBuf content = Unpooled.copiedBuffer("value", CharsetUtil.UTF_8);
        int wrongFlags = 1234;
        try {
            converter.decode("id", content, 0, 0, wrongFlags,
                ResponseStatus.SUCCESS);
        } finally {
            assertEquals(0, content.refCnt());
        }
    }
View Full Code Here

        assertEquals(TranscoderUtils.JSON_COMPAT_FLAGS, (long) encoded.value2());
    }

    @Test
    public void shouldDecodeEmptyJsonArray() {
        ByteBuf content = Unpooled.copiedBuffer("[]", CharsetUtil.UTF_8);
        JsonArrayDocument decoded = converter.decode("id", content, 0, 0, TranscoderUtils.JSON_COMMON_FLAGS,
            ResponseStatus.SUCCESS);
        assertTrue(decoded.content().isEmpty());
    }
View Full Code Here

        assertTrue(decoded.content().isEmpty());
    }

    @Test(expected = TranscodingException.class)
    public void shouldFailToDecodeWithWrongOldFlags() {
        ByteBuf content = Unpooled.copiedBuffer("[]", CharsetUtil.UTF_8);
        int wrongFlags = 1234;
        converter.decode("id", content, 0, 0, wrongFlags, ResponseStatus.SUCCESS);
    }
View Full Code Here

        converter.decode("id", content, 0, 0, wrongFlags, ResponseStatus.SUCCESS);
    }

    @Test(expected = TranscodingException.class)
    public void shouldFailToDecodeWithWrongCommonFlags() {
        ByteBuf content = Unpooled.copiedBuffer("[]", CharsetUtil.UTF_8);
        int wrongFlags = TranscoderUtils.BINARY_COMMON_FLAGS;
        converter.decode("id", content, 0, 0, wrongFlags, ResponseStatus.SUCCESS);
    }
View Full Code Here

        assertEquals(TranscoderUtils.JSON_COMPAT_FLAGS, (long) encoded.value2());
    }

    @Test
    public void shouldDecodeObjectWithEmptyArray() {
        ByteBuf content = Unpooled.copiedBuffer("[{}]", CharsetUtil.UTF_8);
        JsonArrayDocument decoded = converter.decode("id", content, 0, 0,
            TranscoderUtils.JSON_COMMON_FLAGS, ResponseStatus.SUCCESS);

        assertFalse(decoded.content().isEmpty());
        assertEquals(1, decoded.content().size());
View Full Code Here

        assertEquals(TranscoderUtils.JSON_COMPAT_FLAGS, (long) encoded.value2());
    }

    @Test
    public void shouldDecodeMixedJsonValues() throws Exception {
        ByteBuf content = Unpooled.copiedBuffer("[\"Hello World\",1,9223372036854775807,11.3322,true]",
            CharsetUtil.UTF_8);
        JsonArrayDocument decoded = converter.decode("id", content, 0, 0, TranscoderUtils.JSON_COMMON_FLAGS,
            ResponseStatus.SUCCESS);
        JsonArray found = decoded.content();
View Full Code Here

    }


    @Test
    public void shouldReleaseBufferWhenDecoded() {
        ByteBuf content = Unpooled.copiedBuffer("[]", CharsetUtil.UTF_8);
        JsonArrayDocument decoded = converter.decode("id", content, 0, 0, TranscoderUtils.JSON_COMMON_FLAGS,
            ResponseStatus.SUCCESS);
        assertEquals(0, content.refCnt());
    }
View Full Code Here

TOP

Related Classes of com.couchbase.client.deps.io.netty.buffer.ByteBuf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.