Package io.netty.buffer

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


    byte[] fileContent = readFromFile(256);
    ByteBuf buf = Unpooled.copiedBuffer(fileContent);
   
    for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) // -128 ... 127
    {
      byte b = buf.readByte();
      Assert.assertTrue(i == b);
    }
  }
 
  @Ignore
View Full Code Here


    }

    private static void assertCloseWebSocketFrame(EmbeddedChannel channel) {
        ByteBuf buf = channel.readOutbound();
        Assert.assertEquals(2, buf.readableBytes());
        Assert.assertEquals((byte) 0xFF, buf.readByte());
        Assert.assertEquals((byte) 0x00, buf.readByte());
        buf.release();
    }
}
View Full Code Here

    private static void assertCloseWebSocketFrame(EmbeddedChannel channel) {
        ByteBuf buf = channel.readOutbound();
        Assert.assertEquals(2, buf.readableBytes());
        Assert.assertEquals((byte) 0xFF, buf.readByte());
        Assert.assertEquals((byte) 0x00, buf.readByte());
        buf.release();
    }
}
View Full Code Here

        boolean result = channel.writeOutbound(request);
        assertThat(result, is(true));

        ByteBuf written = channel.readOutbound();
        assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE));
        assertThat(written.readByte(), is((byte) 0x80));
        assertThat(written.readByte(), is((byte) 0x00));
        written.release();
    }

    @Test
View Full Code Here

        assertThat(result, is(true));

        ByteBuf written = channel.readOutbound();
        assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE));
        assertThat(written.readByte(), is((byte) 0x80));
        assertThat(written.readByte(), is((byte) 0x00));
        written.release();
    }

    @Test
    public void shouldEncodeCustomHeader() {
View Full Code Here

        boolean result = channel.writeOutbound(request);
        assertThat(result, is(true));

        ByteBuf written = channel.readOutbound();
        assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE));
        assertThat(written.readByte(), is((byte) 0xAA));
        assertThat(written.readByte(), is(BinaryMemcacheOpcodes.GET));
        written.release();
    }

    @Test
View Full Code Here

        assertThat(result, is(true));

        ByteBuf written = channel.readOutbound();
        assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE));
        assertThat(written.readByte(), is((byte) 0xAA));
        assertThat(written.readByte(), is(BinaryMemcacheOpcodes.GET));
        written.release();
    }

    @Test
    public void shouldEncodeExtras() {
View Full Code Here

            ByteBuf buffer = ch.readOutbound();
            if (buffer == null) {
                break;
            }
            while (buffer.isReadable()) {
                assertEquals(BYTES[i++], buffer.readByte());
                read++;
                if (i == BYTES.length) {
                    i = 0;
                }
            }
View Full Code Here

        };
        EmbeddedChannel chDeny = newEmbeddedInetChannel("192.168.57.1", denyHandler);
        ByteBuf out = chDeny.readOutbound();
        Assert.assertEquals(7, out.readableBytes());
        for (byte i = 1; i <= 7; i++) {
            Assert.assertEquals(i, out.readByte());
        }
        Assert.assertFalse(chDeny.isActive());
        Assert.assertFalse(chDeny.isOpen());

        RuleBasedIpFilter allowHandler = new RuleBasedIpFilter(filter0) {
View Full Code Here

                assertTrue("Chunk must be DefaultHttpContent", lastHttpContent instanceof DefaultHttpContent);
            }

            ByteBuf buffer = httpContent.content();
            while (buffer.isReadable()) {
                assertEquals(BYTES[i++], buffer.readByte());
                read++;
                if (i == BYTES.length) {
                    i = 0;
                }
            }
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.