Search in sources :

Example 26 with Executable

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

the class TokenIndexAccessorTest method updaterShouldHandleRandomizedUpdatesWithCheckpoint.

@Test
void updaterShouldHandleRandomizedUpdatesWithCheckpoint() throws Throwable {
    Executable additionalOperation = this::maybeCheckpoint;
    updaterShouldHandleRandomizedUpdates(additionalOperation);
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with Executable

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

the class DecoratingHttp2ConnectionEncoderTest method testConsumeReceivedSettingsThrows.

@Test
public void testConsumeReceivedSettingsThrows() {
    Http2ConnectionEncoder encoder = mock(Http2ConnectionEncoder.class);
    final DecoratingHttp2ConnectionEncoder decoratingHttp2ConnectionEncoder = new DecoratingHttp2ConnectionEncoder(encoder);
    assertThrows(IllegalStateException.class, new Executable() {

        @Override
        public void execute() {
            decoratingHttp2ConnectionEncoder.consumeReceivedSettings(Http2Settings.defaultSettings());
        }
    });
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 28 with Executable

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

the class DefaultHttp2ConnectionDecoderTest method windowUpdateReadForUnknownStreamShouldThrow.

@Test
public void windowUpdateReadForUnknownStreamShouldThrow() throws Exception {
    when(connection.streamMayHaveExisted(STREAM_ID)).thenReturn(false);
    when(connection.stream(STREAM_ID)).thenReturn(null);
    assertThrows(Http2Exception.class, new Executable() {

        @Override
        public void execute() throws Throwable {
            decode().onWindowUpdateRead(ctx, STREAM_ID, 10);
        }
    });
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 29 with Executable

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

the class DefaultHttp2ConnectionDecoderTest method dataContentLengthInvalid.

private void dataContentLengthInvalid(boolean negative) throws Exception {
    final ByteBuf data = dummyData();
    final int padding = 10;
    int processedBytes = data.readableBytes() + padding;
    mockFlowControl(processedBytes);
    try {
        if (negative) {
            assertThrows(Http2Exception.StreamException.class, new Executable() {

                @Override
                public void execute() throws Throwable {
                    decode().onHeadersRead(ctx, STREAM_ID, new DefaultHttp2Headers().setLong(HttpHeaderNames.CONTENT_LENGTH, -1L), padding, false);
                }
            });
        } else {
            decode().onHeadersRead(ctx, STREAM_ID, new DefaultHttp2Headers().setLong(HttpHeaderNames.CONTENT_LENGTH, 1L), padding, false);
            assertThrows(Http2Exception.StreamException.class, new Executable() {

                @Override
                public void execute() throws Throwable {
                    decode().onDataRead(ctx, STREAM_ID, data, padding, true);
                }
            });
            verify(localFlow).receiveFlowControlledFrame(eq(stream), eq(data), eq(padding), eq(true));
            verify(localFlow).consumeBytes(eq(stream), eq(processedBytes));
            verify(listener, times(1)).onHeadersRead(eq(ctx), anyInt(), any(Http2Headers.class), eq(0), eq(DEFAULT_PRIORITY_WEIGHT), eq(false), eq(padding), eq(false));
        }
        // Verify that the event was absorbed and not propagated to the observer.
        verify(listener, never()).onDataRead(eq(ctx), anyInt(), any(ByteBuf.class), anyInt(), anyBoolean());
    } finally {
        data.release();
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Executable(org.junit.jupiter.api.function.Executable)

Example 30 with Executable

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

the class DefaultHttp2ConnectionDecoderTest method headersContentLength.

private void headersContentLength(final boolean negative) throws Exception {
    final int padding = 10;
    when(connection.isServer()).thenReturn(true);
    assertThrows(Http2Exception.StreamException.class, new Executable() {

        @Override
        public void execute() throws Throwable {
            decode().onHeadersRead(ctx, STREAM_ID, new DefaultHttp2Headers().setLong(HttpHeaderNames.CONTENT_LENGTH, negative ? -1L : 1L), padding, true);
        }
    });
    // Verify that the event was absorbed and not propagated to the observer.
    verify(listener, never()).onHeadersRead(eq(ctx), anyInt(), any(Http2Headers.class), anyInt(), anyShort(), anyBoolean(), anyInt(), anyBoolean());
}
Also used : Executable(org.junit.jupiter.api.function.Executable)

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