use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackHuffmanTest method testDecodeEOS.
@Test
public void testDecodeEOS() throws Http2Exception {
final byte[] buf = new byte[4];
for (int i = 0; i < 4; i++) {
buf[i] = (byte) 0xFF;
}
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
decode(buf);
}
});
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackHuffmanTest method testDecodeIllegalPadding.
@Test
public void testDecodeIllegalPadding() throws Http2Exception {
final byte[] buf = new byte[1];
// '0', invalid padding
buf[0] = 0x00;
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
decode(buf);
}
});
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method testMissingDynamicTableSizeUpdate.
@Test
public void testMissingDynamicTableSizeUpdate() throws Http2Exception {
hpackDecoder.setMaxHeaderTableSize(0);
assertEquals(0, hpackDecoder.getMaxHeaderTableSize());
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
decode("81");
}
});
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method testDecodeULE128LongOverflow2.
@Test
public void testDecodeULE128LongOverflow2() throws Http2Exception {
byte[] input = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x7F };
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, 1L);
}
});
} finally {
assertEquals(readerIndex, in.readerIndex());
in.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method failedValidationDoesntCorruptHpack.
@Test
public void failedValidationDoesntCorruptHpack() throws Exception {
final ByteBuf in1 = Unpooled.buffer(200);
ByteBuf in2 = Unpooled.buffer(200);
try {
HpackEncoder hpackEncoder = new HpackEncoder(true);
Http2Headers toEncode = new DefaultHttp2Headers();
toEncode.add(":method", "GET");
toEncode.add(":status", "200");
toEncode.add("foo", "bar");
hpackEncoder.encodeHeaders(1, in1, toEncode, NEVER_SENSITIVE);
final Http2Headers decoded = new DefaultHttp2Headers();
Http2Exception.StreamException expected = assertThrows(Http2Exception.StreamException.class, new Executable() {
@Override
public void execute() throws Throwable {
hpackDecoder.decode(1, in1, decoded, true);
}
});
assertEquals(1, expected.streamId());
// Do it again, this time without validation, to make sure the HPACK state is still sane.
decoded.clear();
hpackEncoder.encodeHeaders(1, in2, toEncode, NEVER_SENSITIVE);
hpackDecoder.decode(1, in2, decoded, false);
assertEquals(3, decoded.size());
assertEquals("GET", decoded.method().toString());
assertEquals("200", decoded.status().toString());
assertEquals("bar", decoded.get("foo").toString());
} finally {
in1.release();
in2.release();
}
}
Aggregations