Search in sources :

Example 71 with Executable

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);
        }
    });
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 72 with Executable

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();
    }
}
Also used : EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 73 with Executable

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");
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 74 with Executable

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");
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 75 with Executable

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");
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Aggregations

Executable (org.junit.jupiter.api.function.Executable)476 Test (org.junit.jupiter.api.Test)434 lombok.val (lombok.val)112 ByteBuf (io.netty.buffer.ByteBuf)83 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)42 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)36 CucumberException (io.cucumber.core.exception.CucumberException)20 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)19 StubStepDefinition (io.cucumber.core.backend.StubStepDefinition)15 Feature (io.cucumber.core.gherkin.Feature)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 StepDefinition (io.cucumber.core.backend.StepDefinition)14 Step (io.cucumber.core.gherkin.Step)14 Argument (io.cucumber.core.stepexpression.Argument)14 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)13 LocalChannel (io.netty.channel.local.LocalChannel)12 CucumberBackendException (io.cucumber.core.backend.CucumberBackendException)11 StepExpression (io.cucumber.core.stepexpression.StepExpression)11 SSLEngine (javax.net.ssl.SSLEngine)11 Bootstrap (io.netty.bootstrap.Bootstrap)10