Search in sources :

Example 46 with ByteBuf

use of io.netty.buffer.ByteBuf in project netty by netty.

the class SpdyHeaderBlockRawDecoderTest method testMissingValue.

@Test
public void testMissingValue() throws Exception {
    ByteBuf headerBlock = Unpooled.buffer(16);
    headerBlock.writeInt(1);
    headerBlock.writeInt(4);
    headerBlock.writeBytes(nameBytes);
    headerBlock.writeInt(5);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);
    decoder.endHeaderBlock(frame);
    assertFalse(headerBlock.isReadable());
    assertTrue(frame.isInvalid());
    assertEquals(0, frame.headers().names().size());
    headerBlock.release();
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 47 with ByteBuf

use of io.netty.buffer.ByteBuf in project netty by netty.

the class SpdyHeaderBlockRawDecoderTest method testNegativeNameValuePairs.

@Test
public void testNegativeNameValuePairs() throws Exception {
    ByteBuf headerBlock = Unpooled.buffer(4);
    headerBlock.writeInt(-1);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);
    assertFalse(headerBlock.isReadable());
    assertTrue(frame.isInvalid());
    assertEquals(0, frame.headers().names().size());
    headerBlock.release();
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 48 with ByteBuf

use of io.netty.buffer.ByteBuf in project netty by netty.

the class SpdyHeaderBlockRawDecoderTest method testIllegalValueStartsWithNull.

@Test
public void testIllegalValueStartsWithNull() throws Exception {
    ByteBuf headerBlock = Unpooled.buffer(22);
    headerBlock.writeInt(1);
    headerBlock.writeInt(4);
    headerBlock.writeBytes(nameBytes);
    headerBlock.writeInt(6);
    headerBlock.writeByte(0);
    headerBlock.writeBytes(valueBytes);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);
    assertFalse(headerBlock.isReadable());
    assertTrue(frame.isInvalid());
    assertEquals(0, frame.headers().names().size());
    headerBlock.release();
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 49 with ByteBuf

use of io.netty.buffer.ByteBuf in project netty by netty.

the class SpdyHeaderBlockRawDecoderTest method testIllegalValueEndsWithNull.

@Test
public void testIllegalValueEndsWithNull() throws Exception {
    ByteBuf headerBlock = Unpooled.buffer(22);
    headerBlock.writeInt(1);
    headerBlock.writeInt(4);
    headerBlock.writeBytes(nameBytes);
    headerBlock.writeInt(6);
    headerBlock.writeBytes(valueBytes);
    headerBlock.writeByte(0);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);
    assertFalse(headerBlock.isReadable());
    assertTrue(frame.isInvalid());
    assertEquals(0, frame.headers().names().size());
    headerBlock.release();
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 50 with ByteBuf

use of io.netty.buffer.ByteBuf in project netty by netty.

the class SpdyHeaderBlockRawDecoderTest method testIllegalValueMultipleNulls.

@Test
public void testIllegalValueMultipleNulls() throws Exception {
    ByteBuf headerBlock = Unpooled.buffer(28);
    headerBlock.writeInt(1);
    headerBlock.writeInt(4);
    headerBlock.writeBytes(nameBytes);
    headerBlock.writeInt(12);
    headerBlock.writeBytes(valueBytes);
    headerBlock.writeByte(0);
    headerBlock.writeByte(0);
    headerBlock.writeBytes(valueBytes);
    decoder.decode(ByteBufAllocator.DEFAULT, headerBlock, frame);
    decoder.endHeaderBlock(frame);
    assertFalse(headerBlock.isReadable());
    assertTrue(frame.isInvalid());
    assertEquals(0, frame.headers().names().size());
    headerBlock.release();
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1557 Test (org.junit.Test)668 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)162 IOException (java.io.IOException)99 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)89 CompositeByteBuf (io.netty.buffer.CompositeByteBuf)81 Test (org.testng.annotations.Test)68 InetSocketAddress (java.net.InetSocketAddress)60 Channel (io.netty.channel.Channel)57 ChannelFuture (io.netty.channel.ChannelFuture)56 ArrayList (java.util.ArrayList)55 Map (java.util.Map)45 ChannelPromise (io.netty.channel.ChannelPromise)41 AtomicReference (java.util.concurrent.atomic.AtomicReference)36 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)35 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)34 HashMap (java.util.HashMap)34 CountDownLatch (java.util.concurrent.CountDownLatch)34 RecyclableDuplicateByteBuf (io.netty.buffer.RecyclableDuplicateByteBuf)32 EventLoopGroup (io.netty.channel.EventLoopGroup)32