Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.readBytes()


     */
    @Test
    public void shouldHandleNonUniformNetworkBatches() {
        ByteBuf incoming = Unpooled.copiedBuffer(SET_REQUEST_WITH_CONTENT);
        while (incoming.isReadable()) {
            channel.writeInbound(incoming.readBytes(5));
        }

        BinaryMemcacheRequest request = channel.readInbound();

        assertThat(request, notNullValue());
View Full Code Here


        EmbeddedChannel channel = new EmbeddedChannel(new StringEncoder());
        Assert.assertTrue(channel.writeOutbound(msg));
        Assert.assertTrue(channel.finish());
        ByteBuf buf = channel.readOutbound();
        byte[] data = new byte[buf.readableBytes()];
        buf.readBytes(data);
        Assert.assertArrayEquals(msg.getBytes(CharsetUtil.UTF_8), data);
        Assert.assertNull(channel.readOutbound());
        buf.release();
    }
}
View Full Code Here

            // Do stuff with the message (for now just print it)
            ByteBuf content = msg.content();
            if (content.isReadable()) {
                int contentLength = content.readableBytes();
                byte[] arr = new byte[contentLength];
                content.readBytes(arr);
                System.out.println(new String(arr, 0, contentLength, CharsetUtil.UTF_8));
            }

            promise.setSuccess();
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.