use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method testDecodeULE128IntOverflow1.
@Test
public void testDecodeULE128IntOverflow1() throws Http2Exception {
byte[] input = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x07 };
final ByteBuf in = Unpooled.wrappedBuffer(input);
final int readerIndex = in.readerIndex();
try {
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
decodeULE128(in, 1);
}
});
} finally {
assertEquals(readerIndex, in.readerIndex());
in.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class DefaultHttp2ConnectionDecoderTest method dataReadForUnknownStreamShouldApplyFlowControl.
@Test
public void dataReadForUnknownStreamShouldApplyFlowControl() throws Exception {
when(connection.stream(STREAM_ID)).thenReturn(null);
final ByteBuf data = dummyData();
final int padding = 10;
int processedBytes = data.readableBytes() + padding;
try {
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
decode().onDataRead(ctx, STREAM_ID, data, padding, true);
}
});
verify(localFlow).receiveFlowControlledFrame(eq((Http2Stream) null), eq(data), eq(padding), eq(true));
verify(localFlow).consumeBytes(eq((Http2Stream) null), eq(processedBytes));
verify(localFlow).frameWriter(any(Http2FrameWriter.class));
verifyNoMoreInteractions(localFlow);
// Verify that the event was absorbed and not propagated to the observer.
verify(listener, never()).onDataRead(eq(ctx), anyInt(), any(ByteBuf.class), anyInt(), anyBoolean());
} finally {
data.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class DefaultHttp2ConnectionDecoderTest method dataReadForStreamInInvalidStateShouldThrow.
@Test
public void dataReadForStreamInInvalidStateShouldThrow() throws Exception {
// Throw an exception when checking stream state.
when(stream.state()).thenReturn(Http2Stream.State.CLOSED);
final ByteBuf data = dummyData();
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
decode().onDataRead(ctx, STREAM_ID, data, 10, true);
}
});
data.release();
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class DefaultHttp2FrameReaderTest method failedWhenDataFrameNotAssociateWithStream.
@Test
public void failedWhenDataFrameNotAssociateWithStream() throws Http2Exception {
final ByteBuf input = Unpooled.buffer();
ByteBuf payload = Unpooled.buffer();
try {
payload.writeByte(1);
writeFrameHeader(input, payload.readableBytes(), DATA, new Http2Flags().endOfStream(true), 0);
input.writeBytes(payload);
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
frameReader.readFrame(ctx, input, listener);
}
});
} finally {
payload.release();
input.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class DefaultHttp2FrameReaderTest method failedWhenSettingsFrameOnNonZeroStream.
@Test
public void failedWhenSettingsFrameOnNonZeroStream() throws Http2Exception {
final ByteBuf input = Unpooled.buffer();
try {
writeFrameHeader(input, 6, SETTINGS, new Http2Flags(), 1);
input.writeShort(SETTINGS_MAX_HEADER_LIST_SIZE);
input.writeInt(1024);
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
frameReader.readFrame(ctx, input, listener);
}
});
} finally {
input.release();
}
}
Aggregations