use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class SnappyFrameDecoderTest method testUncompressedDataBeforeStreamIdentifier.
@Test
public void testUncompressedDataBeforeStreamIdentifier() {
final ByteBuf in = Unpooled.wrappedBuffer(new byte[] { 0x01, 0x05, 0x00, 0x00, 'n', 'e', 't', 't', 'y' });
assertThrows(DecompressionException.class, new Executable() {
@Override
public void execute() throws Throwable {
channel.writeInbound(in);
}
});
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class SnappyFrameDecoderTest method testInvalidChecksumThrowsException.
// The following two tests differ in only the checksum provided for the literal
// uncompressed string "netty"
@Test
public void testInvalidChecksumThrowsException() {
final EmbeddedChannel channel = new EmbeddedChannel(new SnappyFrameDecoder(true));
try {
// checksum here is presented as 0
final ByteBuf in = Unpooled.wrappedBuffer(new byte[] { (byte) 0xff, 0x06, 0x00, 0x00, 0x73, 0x4e, 0x61, 0x50, 0x70, 0x59, 0x01, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 'n', 'e', 't', 't', 'y' });
assertThrows(DecompressionException.class, new Executable() {
@Override
public void execute() {
channel.writeInbound(in);
}
});
} finally {
channel.finishAndReleaseAll();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class Bzip2DecoderTest method testStreamCrcError.
@Test
public void testStreamCrcError() {
final byte[] data = Arrays.copyOf(DATA, DATA.length);
data[41] = (byte) 0xDD;
assertThrows(DecompressionException.class, new Executable() {
@Override
public void execute() {
tryDecodeAndCatchBufLeaks(channel, Unpooled.wrappedBuffer(data));
}
}, "stream CRC error");
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class Bzip2DecoderTest method testIncorrectSelectorsNumber.
@Test
public void testIncorrectSelectorsNumber() {
final byte[] data = Arrays.copyOf(DATA, DATA.length);
data[25] = 0x2F;
final ByteBuf in = Unpooled.wrappedBuffer(data);
assertThrows(DecompressionException.class, new Executable() {
@Override
public void execute() {
channel.writeInbound(in);
}
}, "incorrect selectors number");
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class Bzip2DecoderTest method testInvalidBlockSize.
@Test
public void testInvalidBlockSize() {
final ByteBuf in = Unpooled.buffer();
in.writeMedium(MAGIC_NUMBER);
// incorrect block size
in.writeByte('0');
assertThrows(DecompressionException.class, new Executable() {
@Override
public void execute() {
channel.writeInbound(in);
}
}, "block size is invalid");
}
Aggregations