List of usage examples for io.netty.buffer ByteBuf writeInt
public abstract ByteBuf writeInt(int value);
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testHttpRstStreamFrameReservedBits() throws Exception { int length = 4; byte flags = (byte) 0xFF; // should ignore any flags int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01; int errorCode = RANDOM.nextInt(); ByteBuf frame = rstStreamFrame(length, flags, streamId); setReservedBits(frame);/*from ww w .j ava 2 s .c o m*/ frame.writeInt(errorCode); decoder.decode(frame); verify(delegate).readRstStreamFrame(streamId, errorCode); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testInvalidHttpRstStreamFrame() throws Exception { int length = 8; // invalid length byte flags = 0; int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01; int errorCode = RANDOM.nextInt(); ByteBuf frame = rstStreamFrame(length, flags, streamId); frame.writeInt(errorCode); decoder.decode(frame);/*from ww w . j a v a 2 s. com*/ verify(delegate).readFrameError(anyString()); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testIllegalHttpRstStreamFrame() throws Exception { int length = 4; byte flags = 0; int streamId = 0; // illegal stream identifier int errorCode = RANDOM.nextInt(); ByteBuf frame = rstStreamFrame(length, flags, streamId); frame.writeInt(errorCode); decoder.decode(frame);//from www . j a va 2s . c om verify(delegate).readFrameError(anyString()); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testHttpSettingsFrame() throws Exception { int length = 6; byte flags = 0; int streamId = 0; // connection identifier int id = RANDOM.nextInt() & 0xFFFF; int value = RANDOM.nextInt(); ByteBuf frame = settingsFrame(length, flags, streamId); frame.writeShort(id);// w w w . java 2 s. c om frame.writeInt(value); decoder.decode(frame); InOrder inOrder = inOrder(delegate); inOrder.verify(delegate).readSettingsFrame(false); inOrder.verify(delegate).readSetting(id, value); inOrder.verify(delegate).readSettingsEnd(); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testHttpSettingsFrameWithMultiples() throws Exception { int length = 12; byte flags = 0; int streamId = 0; // connection identifier int id = RANDOM.nextInt() & 0xFFFF; int value1 = RANDOM.nextInt(); int value2 = RANDOM.nextInt(); ByteBuf frame = settingsFrame(length, flags, streamId); frame.writeShort(id);// ww w .j a v a 2s . c o m frame.writeInt(value1); frame.writeShort(id); frame.writeInt(value2); decoder.decode(frame); InOrder inOrder = inOrder(delegate); inOrder.verify(delegate).readSettingsFrame(false); inOrder.verify(delegate).readSetting(id, value1); inOrder.verify(delegate).readSetting(id, value2); inOrder.verify(delegate).readSettingsEnd(); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testHttpSettingsFrameReservedBits() throws Exception { int length = 6; byte flags = (byte) 0xFE; // should ignore any unknown flags int streamId = 0; // connection identifier int id = RANDOM.nextInt() & 0xFFFF; int value = RANDOM.nextInt(); ByteBuf frame = settingsFrame(length, flags, streamId); setReservedBits(frame);//from ww w . j a v a2 s .c om frame.writeShort(id); frame.writeInt(value); decoder.decode(frame); InOrder inOrder = inOrder(delegate); inOrder.verify(delegate).readSettingsFrame(false); inOrder.verify(delegate).readSetting(id, value); inOrder.verify(delegate).readSettingsEnd(); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testInvalidHttpSettingsFrame() throws Exception { int length = 8; // invalid length byte flags = 0; int streamId = 0; // connection identifier int id = RANDOM.nextInt() & 0xFFFF; int value = RANDOM.nextInt(); ByteBuf frame = settingsFrame(length, flags, streamId); frame.writeShort(id);/*from w ww. j a v a2s . c om*/ frame.writeInt(value); decoder.decode(frame); verify(delegate).readFrameError(anyString()); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testInvalidHttpSettingsAckFrame() throws Exception { int length = 6; // invalid length byte flags = 0x01; // ACK int streamId = 0; // connection identifier int id = RANDOM.nextInt() & 0xFFFF; int value = RANDOM.nextInt(); ByteBuf frame = settingsFrame(length, flags, streamId); frame.writeShort(id);/*from www . j a v a 2s . c o m*/ frame.writeInt(value); decoder.decode(frame); verify(delegate).readFrameError(anyString()); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testIllegalHttpSettingsFrame() throws Exception { int length = 6; byte flags = 0; int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01; // illegal stream identifier int id = RANDOM.nextInt() & 0xFFFF; int value = RANDOM.nextInt(); ByteBuf frame = settingsFrame(length, flags, streamId); frame.writeShort(id);/*from w w w . j a v a 2 s.c om*/ frame.writeInt(value); decoder.decode(frame); verify(delegate).readFrameError(anyString()); verifyNoMoreInteractions(delegate); }
From source file:com.twitter.http2.HttpFrameDecoderTest.java
License:Apache License
@Test public void testHttpPushPromiseFrame() throws Exception { int headerBlockLength = 16; int length = 4 + headerBlockLength; byte flags = 0x04; // END_HEADERS int streamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01; int promisedStreamId = RANDOM.nextInt() & 0x7FFFFFFF | 0x01; ByteBuf frame = pushPromiseFrame(length, flags, streamId); frame.writeInt(promisedStreamId); writeRandomData(frame, headerBlockLength); decoder.decode(frame);// www .j av a 2s . c om InOrder inOrder = inOrder(delegate); inOrder.verify(delegate).readPushPromiseFrame(streamId, promisedStreamId); inOrder.verify(delegate).readHeaderBlock(frame.slice(HTTP_FRAME_HEADER_SIZE + 4, headerBlockLength)); inOrder.verify(delegate).readHeaderBlockEnd(); verifyNoMoreInteractions(delegate); }