Search in sources :

Example 96 with Executable

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

the class SingleThreadEventExecutorTest method testWrappedExecutorIsShutdown.

@Test
public void testWrappedExecutorIsShutdown() {
    ExecutorService executorService = Executors.newSingleThreadExecutor();
    final SingleThreadEventExecutor executor = new SingleThreadEventExecutor(null, executorService, false) {

        @Override
        protected void run() {
            while (!confirmShutdown()) {
                Runnable task = takeTask();
                if (task != null) {
                    task.run();
                }
            }
        }
    };
    executorService.shutdownNow();
    executeShouldFail(executor);
    executeShouldFail(executor);
    assertThrows(RejectedExecutionException.class, new Executable() {

        @Override
        public void execute() {
            executor.shutdownGracefully().syncUninterruptibly();
        }
    });
    assertTrue(executor.isShutdown());
}
Also used : LazyRunnable(io.netty.util.concurrent.AbstractEventExecutor.LazyRunnable) ExecutorService(java.util.concurrent.ExecutorService) Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 97 with Executable

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

the class PromiseCombinerTest method testFinishCalledTwiceThrows.

@SuppressWarnings("unchecked")
@Test
public void testFinishCalledTwiceThrows() {
    combiner.finish(p1);
    assertThrows(IllegalStateException.class, new Executable() {

        @Override
        public void execute() {
            combiner.finish(p1);
        }
    });
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 98 with Executable

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

the class PromiseCombinerTest method testAddAllAfterFinish.

@SuppressWarnings("unchecked")
@Test
public void testAddAllAfterFinish() {
    combiner.finish(p1);
    assertThrows(IllegalStateException.class, new Executable() {

        @Override
        public void execute() {
            combiner.addAll(p2);
        }
    });
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 99 with Executable

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

the class PromiseCombinerTest method testAddAfterFinish.

@Test
public void testAddAfterFinish() {
    combiner.finish(p1);
    assertThrows(IllegalStateException.class, new Executable() {

        @Override
        public void execute() {
            combiner.add(p2);
        }
    });
}
Also used : Executable(org.junit.jupiter.api.function.Executable) Test(org.junit.jupiter.api.Test)

Example 100 with Executable

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

the class SslHandlerTest method testNonByteBufWriteIsReleased.

@Test
public void testNonByteBufWriteIsReleased() throws Exception {
    SSLEngine engine = newServerModeSSLEngine();
    final EmbeddedChannel ch = new EmbeddedChannel(new SslHandler(engine));
    final AbstractReferenceCounted referenceCounted = new AbstractReferenceCounted() {

        @Override
        public ReferenceCounted touch(Object hint) {
            return this;
        }

        @Override
        protected void deallocate() {
        }
    };
    ExecutionException e = assertThrows(ExecutionException.class, new Executable() {

        @Override
        public void execute() throws Throwable {
            ch.write(referenceCounted).get();
        }
    });
    assertThat(e.getCause(), is(instanceOf(UnsupportedMessageTypeException.class)));
    assertEquals(0, referenceCounted.refCnt());
    assertTrue(ch.finishAndReleaseAll());
}
Also used : SSLEngine(javax.net.ssl.SSLEngine) AbstractReferenceCounted(io.netty.util.AbstractReferenceCounted) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ExecutionException(java.util.concurrent.ExecutionException) 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