Package io.netty.channel.embedded

Examples of io.netty.channel.embedded.EmbeddedChannel.readInbound()


        EmbeddedChannel chDecoderGZip = new EmbeddedChannel(createDecoder(ZlibWrapper.GZIP));
        try {
            chDecoderGZip.writeInbound(deflatedData.copy());
            assertTrue(chDecoderGZip.finish());
            ByteBuf buf = chDecoderGZip.readInbound();
            assertEquals(buf, data);
            assertNull(chDecoderGZip.readInbound());
            data.release();
            deflatedData.release();
            buf.release();
View Full Code Here


        try {
            chDecoderGZip.writeInbound(deflatedData.copy());
            assertTrue(chDecoderGZip.finish());
            ByteBuf buf = chDecoderGZip.readInbound();
            assertEquals(buf, data);
            assertNull(chDecoderGZip.readInbound());
            data.release();
            deflatedData.release();
            buf.release();
        } finally {
            dispose(chDecoderGZip);
View Full Code Here

            }

            byte[] decompressed = new byte[data.readableBytes()];
            int offset = 0;
            for (;;) {
                ByteBuf buf = chDecoderZlib.readInbound();
                if (buf == null) {
                    break;
                }
                int length = buf.readableBytes();
                buf.readBytes(decompressed, offset, length);
View Full Code Here

                if (offset == decompressed.length) {
                    break;
                }
            }
            assertEquals(data, Unpooled.wrappedBuffer(decompressed));
            assertNull(chDecoderZlib.readInbound());

            // Closing an encoder channel will generate a footer.
            assertTrue(chEncoder.finish());
            for (;;) {
                Object msg = chEncoder.readOutbound();
View Full Code Here

            }

            // Decoder should not generate anything at all.
            boolean decoded = false;
            for (;;) {
                ByteBuf buf = chDecoderZlib.readInbound();
                if (buf == null) {
                    break;
                }

                buf.release();
View Full Code Here

        assertTrue(chDecoder.finish());

        ByteBuf decoded = Unpooled.buffer(data.length);

        for (;;) {
            ByteBuf buf = chDecoder.readInbound();
            if (buf == null) {
                break;
            }
            decoded.writeBytes(buf);
            buf.release();
View Full Code Here

                WebSocketExtension.RSV1 | WebSocketExtension.RSV3,
                compressedPayload.slice(0, compressedPayload.readableBytes() - 4));

        // execute
        decoderChannel.writeInbound(compressedFrame);
        BinaryWebSocketFrame uncompressedFrame = decoderChannel.readInbound();

        // test
        assertNotNull(uncompressedFrame);
        assertNotNull(uncompressedFrame.content());
        assertTrue(uncompressedFrame instanceof BinaryWebSocketFrame);
View Full Code Here

        BinaryWebSocketFrame frame = new BinaryWebSocketFrame(true,
                WebSocketExtension.RSV3, Unpooled.wrappedBuffer(payload));

        // execute
        decoderChannel.writeInbound(frame);
        BinaryWebSocketFrame newFrame = decoderChannel.readInbound();

        // test
        assertNotNull(newFrame);
        assertNotNull(newFrame.content());
        assertTrue(newFrame instanceof BinaryWebSocketFrame);
View Full Code Here

        assertTrue(compressedFrame instanceof BinaryWebSocketFrame);
        assertEquals(WebSocketExtension.RSV1 | WebSocketExtension.RSV3, compressedFrame.rsv());

        decoderChannel.writeInbound(compressedFrame.content());
        decoderChannel.writeInbound(DeflateDecoder.FRAME_TAIL);
        ByteBuf uncompressedPayload = decoderChannel.readInbound();
        assertEquals(300, uncompressedPayload.readableBytes());

        byte[] finalPayload = new byte[300];
        uncompressedPayload.readBytes(finalPayload);
        assertTrue(Arrays.equals(finalPayload, payload));
View Full Code Here

        assertFalse(compressedFrame1.isFinalFragment());
        assertFalse(compressedFrame2.isFinalFragment());
        assertTrue(compressedFrame3.isFinalFragment());

        decoderChannel.writeInbound(compressedFrame1.content());
        ByteBuf uncompressedPayload1 = decoderChannel.readInbound();
        byte[] finalPayload1 = new byte[100];
        uncompressedPayload1.readBytes(finalPayload1);
        assertTrue(Arrays.equals(finalPayload1, payload1));
        uncompressedPayload1.release();
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.