Search in sources :

Example 61 with Executable

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

Example 62 with Executable

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

Example 63 with Executable

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

Example 64 with Executable

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

Example 65 with Executable

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);
        }
    });
}
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