use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method unknownPseudoHeader.
@Test
public void unknownPseudoHeader() throws Exception {
final ByteBuf in = Unpooled.buffer(200);
try {
HpackEncoder hpackEncoder = new HpackEncoder(true);
Http2Headers toEncode = new DefaultHttp2Headers();
toEncode.add(":test", "1");
hpackEncoder.encodeHeaders(1, in, toEncode, NEVER_SENSITIVE);
final Http2Headers decoded = new DefaultHttp2Headers();
assertThrows(Http2Exception.StreamException.class, new Executable() {
@Override
public void execute() throws Throwable {
hpackDecoder.decode(1, in, decoded, true);
}
});
} finally {
in.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class SmtpRequestEncoderTest method testThrowsIfContentExpected.
@Test
public void testThrowsIfContentExpected() {
final EmbeddedChannel channel = new EmbeddedChannel(new SmtpRequestEncoder());
try {
assertTrue(channel.writeOutbound(SmtpRequests.data()));
assertThrows(EncoderException.class, new Executable() {
@Override
public void execute() {
channel.writeOutbound(SmtpRequests.noop());
}
});
} finally {
channel.finishAndReleaseAll();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class RedisDecoderTest method shouldErrorOnReleasecontentOfArrayChildReferenceCounted.
@Test
public void shouldErrorOnReleasecontentOfArrayChildReferenceCounted() throws Exception {
ByteBuf buf = Unpooled.buffer();
buf.writeBytes(byteBufOf("*2\r\n"));
buf.writeBytes(byteBufOf("$3\r\nFoo\r\n$3\r\nBar\r\n"));
assertTrue(channel.writeInbound(buf));
ArrayRedisMessage msg = channel.readInbound();
List<RedisMessage> children = msg.children();
final ByteBuf childBuf = ((FullBulkStringRedisMessage) children.get(0)).content();
ReferenceCountUtil.release(msg);
assertThrows(IllegalReferenceCountException.class, new Executable() {
@Override
public void execute() {
ReferenceCountUtil.release(childBuf);
}
});
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class MessageToMessageEncoderTest method testException.
/**
* Test-case for https://github.com/netty/netty/issues/1656
*/
@Test
public void testException() {
final EmbeddedChannel channel = new EmbeddedChannel(new MessageToMessageEncoder<Object>() {
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception {
throw new Exception();
}
});
assertThrows(EncoderException.class, new Executable() {
@Override
public void execute() {
channel.writeOutbound(new Object());
}
});
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class SnappyFrameDecoderTest method testReservedUnskippableChunkTypeCausesError.
@Test
public void testReservedUnskippableChunkTypeCausesError() {
final ByteBuf in = Unpooled.wrappedBuffer(new byte[] { 0x03, 0x01, 0x00, 0x00, 0x00 });
assertThrows(DecompressionException.class, new Executable() {
@Override
public void execute() {
channel.writeInbound(in);
}
});
}
Aggregations