Search in sources :

Example 41 with Executable

use of org.junit.jupiter.api.function.Executable in project netty by netty.

the class DefaultHttp2FrameReaderTest method failedWhenHeaderFrameDependsOnItself.

@Test
public void failedWhenHeaderFrameDependsOnItself() throws Http2Exception {
    final ByteBuf input = Unpooled.buffer();
    try {
        Http2Headers headers = new DefaultHttp2Headers().authority("foo").method("get").path("/").scheme("https");
        writeHeaderFramePriorityPresent(input, 1, headers, new Http2Flags().endOfHeaders(true).endOfStream(true).priorityPresent(true), 1, 10);
        assertThrows(Http2Exception.class, new Executable() {

            @Override
            public void execute() throws Throwable {
                frameReader.readFrame(ctx, input, listener);
            }
        });
    } finally {
        input.release();
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 42 with Executable

use of org.junit.jupiter.api.function.Executable in project netty by netty.

the class DefaultHttp2FrameReaderTest method failedWhenWindowUpdateFrameWithZeroDelta.

@Test
public void failedWhenWindowUpdateFrameWithZeroDelta() throws Http2Exception {
    final ByteBuf input = Unpooled.buffer();
    try {
        writeFrameHeader(input, 4, WINDOW_UPDATE, new Http2Flags(), 0);
        input.writeInt(0);
        assertThrows(Http2Exception.class, new Executable() {

            @Override
            public void execute() throws Throwable {
                frameReader.readFrame(ctx, input, listener);
            }
        });
    } finally {
        input.release();
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 43 with Executable

use of org.junit.jupiter.api.function.Executable in project netty by netty.

the class DefaultHttp2FrameReaderTest method failedWhenSettingsFrameWithWrongPayloadLength.

@Test
public void failedWhenSettingsFrameWithWrongPayloadLength() throws Http2Exception {
    final ByteBuf input = Unpooled.buffer();
    try {
        writeFrameHeader(input, 8, SETTINGS, new Http2Flags(), 0);
        input.writeInt(SETTINGS_MAX_HEADER_LIST_SIZE);
        input.writeInt(1024);
        assertThrows(Http2Exception.class, new Executable() {

            @Override
            public void execute() throws Throwable {
                frameReader.readFrame(ctx, input, listener);
            }
        });
    } finally {
        input.release();
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 44 with Executable

use of org.junit.jupiter.api.function.Executable in project netty by netty.

the class DefaultHttp2HeadersDecoderTest method decodeLargerThanHeaderListSizeButLessThanGoAway.

@Test
public void decodeLargerThanHeaderListSizeButLessThanGoAway() throws Exception {
    decoder.maxHeaderListSize(MIN_HEADER_LIST_SIZE, MAX_HEADER_LIST_SIZE);
    final ByteBuf buf = encode(b(":method"), b("GET"));
    final int streamId = 1;
    Http2Exception.HeaderListSizeException e = assertThrows(Http2Exception.HeaderListSizeException.class, new Executable() {

        @Override
        public void execute() throws Throwable {
            decoder.decodeHeaders(streamId, buf);
        }
    });
    assertEquals(streamId, e.streamId());
    buf.release();
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 45 with Executable

use of org.junit.jupiter.api.function.Executable in project netty by netty.

the class DefaultHttp2HeadersDecoderTest method decodeLargerThanHeaderListSizeButLessThanGoAwayWithInitialDecoderSettings.

@Test
public void decodeLargerThanHeaderListSizeButLessThanGoAwayWithInitialDecoderSettings() throws Exception {
    final ByteBuf buf = encode(b(":method"), b("GET"), b("test_header"), b(String.format("%09000d", 0).replace('0', 'A')));
    final int streamId = 1;
    try {
        Http2Exception.HeaderListSizeException e = assertThrows(Http2Exception.HeaderListSizeException.class, new Executable() {

            @Override
            public void execute() throws Throwable {
                decoder.decodeHeaders(streamId, buf);
            }
        });
        assertEquals(streamId, e.streamId());
    } finally {
        buf.release();
    }
}
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