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