Package io.netty.buffer

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


    public void frameShouldSplit() throws Http2Exception {
        controller.initialOutboundWindowSize(5);

        final ByteBuf data = dummyData(5, 5);
        try {
            send(STREAM_A, data.slice(0, 5), 5);

            // Verify that a partial frame of 5 was sent.
            ArgumentCaptor<ByteBuf> argument = ArgumentCaptor.forClass(ByteBuf.class);
            // None of the padding should be sent in the frame.
            captureWrite(STREAM_A, argument, 0, false);
View Full Code Here


    public void frameShouldSplitPadding() throws Http2Exception {
        controller.initialOutboundWindowSize(5);

        final ByteBuf data = dummyData(3, 7);
        try {
            send(STREAM_A, data.slice(0, 3), 7);

            // Verify that a partial frame of 5 was sent.
            ArgumentCaptor<ByteBuf> argument = ArgumentCaptor.forClass(ByteBuf.class);
            captureWrite(STREAM_A, argument, 2, false);
            final ByteBuf writtenBuf = argument.getValue();
View Full Code Here

    public void emptyFrameShouldSplitPadding() throws Http2Exception {
        controller.initialOutboundWindowSize(5);

        final ByteBuf data = dummyData(0, 10);
        try {
            send(STREAM_A, data.slice(0, 0), 10);

            // Verify that a partial frame of 5 was sent.
            ArgumentCaptor<ByteBuf> argument = ArgumentCaptor.forClass(ByteBuf.class);
            captureWrite(STREAM_A, argument, 5, false);
            final ByteBuf writtenBuf = argument.getValue();
View Full Code Here

    public void windowUpdateShouldSendFrame() throws Http2Exception {
        controller.initialOutboundWindowSize(10);

        final ByteBuf data = dummyData(10, 10);
        try {
            send(STREAM_A, data.slice(0, 10), 10);
            verifyWrite(STREAM_A, data.slice(0, 10), 0);

            // Update the window and verify that the rest of the frame is written.
            controller.updateOutboundWindowSize(STREAM_A, 10);
            verifyWrite(STREAM_A, Unpooled.EMPTY_BUFFER, 10);
View Full Code Here

        controller.initialOutboundWindowSize(10);

        final ByteBuf data = dummyData(10, 10);
        try {
            send(STREAM_A, data.slice(0, 10), 10);
            verifyWrite(STREAM_A, data.slice(0, 10), 0);

            // Update the window and verify that the rest of the frame is written.
            controller.updateOutboundWindowSize(STREAM_A, 10);
            verifyWrite(STREAM_A, Unpooled.EMPTY_BUFFER, 10);
            assertEquals(DEFAULT_WINDOW_SIZE - data.readableBytes(), window(CONNECTION_STREAM_ID));
View Full Code Here

    public void initialWindowUpdateShouldSendFrame() throws Http2Exception {
        controller.initialOutboundWindowSize(0);

        final ByteBuf data = dummyData(10, 0);
        try {
            send(STREAM_A, data.slice(), 0);
            verifyNoWrite(STREAM_A);

            // Verify that the entire frame was sent.
            controller.initialOutboundWindowSize(10);
            ArgumentCaptor<ByteBuf> argument = ArgumentCaptor.forClass(ByteBuf.class);
View Full Code Here

            controller.initialOutboundWindowSize(initWindow - secondWindowSize);
            assertEquals(-secondWindowSize, streamA.outboundFlow().window());

            // Queue up a write. It should not be written now because the window is negative
            resetFrameWriter();
            send(STREAM_A, data2.slice(), 0);
            verifyNoWrite(STREAM_A);

            // Open the window size back up a bit (no send should happen)
            controller.updateOutboundWindowSize(STREAM_A, 5);
            assertEquals(-5, streamA.outboundFlow().window());
View Full Code Here

        controller.initialOutboundWindowSize(0);

        // First send a frame that will get buffered.
        final ByteBuf data = dummyData(10, 0);
        try {
            send(STREAM_A, data.slice(), 0);
            verifyNoWrite(STREAM_A);

            // Now send an empty frame on the same stream and verify that it's also buffered.
            send(STREAM_A, Unpooled.EMPTY_BUFFER, 0);
            verifyNoWrite(STREAM_A);
View Full Code Here

            verifyNoWrite(STREAM_A);

            // Re-expand the window and verify that both frames were sent.
            controller.initialOutboundWindowSize(10);

            verifyWrite(STREAM_A, data.slice(), 0);
            verifyWrite(STREAM_A, Unpooled.EMPTY_BUFFER, 0);
        } finally {
            manualSafeRelease(data);
        }
    }
View Full Code Here

        // Set the connection window size to zero.
        exhaustStreamWindow(CONNECTION_STREAM_ID);

        final ByteBuf data = dummyData(10, 0);
        try {
            send(STREAM_A, data.slice(), 0);
            verifyNoWrite(STREAM_A);

            // Verify that the entire frame was sent.
            controller.updateOutboundWindowSize(CONNECTION_STREAM_ID, 10);
            assertEquals(0, window(CONNECTION_STREAM_ID));
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.