Package io.netty.buffer

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


        rnd.nextBytes(data);

        ByteBuf buf = Unpooled.wrappedBuffer(data);
        for (int i = 0; i < 4096; i ++) {
            buf.setIndex(0, data.length);
            ch.writeInbound(buf.retain());
            ch.checkException();
            assertNull(ch.readInbound());
        }
        buf.release();
    }
View Full Code Here


    private void runTest(String expectedApplicationProtocol) throws Exception {
        final ByteBuf clientMessage = Unpooled.copiedBuffer("I am a client".getBytes());
        final ByteBuf serverMessage = Unpooled.copiedBuffer("I am a server".getBytes());
        try {
            writeAndVerifyReceived(clientMessage.retain(), clientChannel, serverLatch, serverReceiver);
            writeAndVerifyReceived(serverMessage.retain(), serverConnectedChannel, clientLatch, clientReceiver);
            if (expectedApplicationProtocol != null) {
                verifyApplicationLevelProtocol(clientChannel, expectedApplicationProtocol);
                verifyApplicationLevelProtocol(serverConnectedChannel, expectedApplicationProtocol);
            }
        } finally {
View Full Code Here

    }

    @Test
    public void dataShouldRoundtrip() throws Exception {
        final ByteBuf data = dummyData();
        writer.writeData(ctx, 1000, data.retain().duplicate(), 0, false, promise);

        ByteBuf frame = null;
        try {
            frame = captureWrite();
            reader.readFrame(ctx, frame, listener);
View Full Code Here

    }

    @Test
    public void dataWithPaddingShouldRoundtrip() throws Exception {
        final ByteBuf data = dummyData();
        writer.writeData(ctx, 1, data.retain().duplicate(), 0xFF, true, promise);

        ByteBuf frame = null;
        try {
            frame = captureWrite();
            reader.readFrame(ctx, frame, listener);
View Full Code Here

    }

    @Test
    public void pingShouldRoundtrip() throws Exception {
        ByteBuf data = dummyData();
        writer.writePing(ctx, false, data.retain().duplicate(), promise);

        ByteBuf frame = null;
        try {
            frame = captureWrite();
            reader.readFrame(ctx, frame, listener);
View Full Code Here

    }

    @Test
    public void pingAckShouldRoundtrip() throws Exception {
        ByteBuf data = dummyData();
        writer.writePing(ctx, true, data.retain().duplicate(), promise);

        ByteBuf frame = null;
        try {
            frame = captureWrite();
            reader.readFrame(ctx, frame, listener);
View Full Code Here

    }

    @Test
    public void goAwayShouldRoundtrip() throws Exception {
        ByteBuf data = dummyData();
        writer.writeGoAway(ctx, 1, MAX_UNSIGNED_INT, data.retain().duplicate(), promise);

        ByteBuf frame = null;
        try {
            frame = captureWrite();
            reader.readFrame(ctx, frame, listener);
View Full Code Here

        bootstrapEnv(1);
        try {
            runInChannel(clientChannel, new Http2Runnable() {
                @Override
                public void run() {
                    frameWriter.writeGoAway(ctx(), 0x7FFFFFFF, 0xFFFFFFFFL, data.retain(), newPromise());
                    ctx().flush();
                }
            });
            awaitRequests();
            verify(serverListener).onGoAwayRead(any(ChannelHandlerContext.class), eq(0x7FFFFFFF),
View Full Code Here

        try {
            bootstrapEnv(1);
            runInChannel(clientChannel, new Http2Runnable() {
                @Override
                public void run() {
                    frameWriter.writePing(ctx(), true, data.retain(), newPromise());
                    ctx().flush();
                }
            });
            awaitRequests();
            verify(serverListener).onPingAckRead(any(ChannelHandlerContext.class), any(ByteBuf.class));
View Full Code Here

            runInChannel(clientChannel, new Http2Runnable() {
                @Override
                public void run() {
                    for (int i = 1; i < numStreams + 1; ++i) {
                        frameWriter.writeHeaders(ctx(), i, headers, 0, (short) 16, false, 0, false, newPromise());
                        frameWriter.writeData(ctx(), i, data.retain(), 0, true, newPromise());
                        ctx().flush();
                    }
                }
            });
            awaitRequests(30);
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.