Class EventLoopExtension
java.lang.Object
com.linecorp.armeria.testing.junit5.common.AbstractAllOrEachExtension
com.linecorp.armeria.testing.junit5.common.EventLoopExtension
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback
,org.junit.jupiter.api.extension.AfterEachCallback
,org.junit.jupiter.api.extension.BeforeAllCallback
,org.junit.jupiter.api.extension.BeforeEachCallback
,org.junit.jupiter.api.extension.Extension
An
Extension
that provides an EventLoopGroup
. For example:
> public class MyTest {
> @RegisterExtension
> public static final EventLoopExtension eventLoop = new EventLoopExtension();
>
> @Test
> public void test() {
> eventLoop.get().execute(() -> System.out.println("Hello!"));
> }
> }
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates a newExtension
that provides anEventLoop
.EventLoopExtension
(boolean useDaemonThread) Creates a newExtension
that provides anEventLoop
.EventLoopExtension
(String threadNamePrefix) Creates a newExtension
that provides anEventLoop
.EventLoopExtension
(String threadNamePrefix, boolean useDaemonThread) Creates a newExtension
that provides anEventLoop
.EventLoopExtension
(ThreadFactory threadFactory) Creates a newExtension
that provides anEventLoop
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
after
(org.junit.jupiter.api.extension.ExtensionContext context) Shuts down all threads created by thisExtension
asynchronously.void
before
(org.junit.jupiter.api.extension.ExtensionContext context) A method that should be run at the beginning of a test lifecycle.io.netty.channel.EventLoop
get()
Returns theEventLoop
.Methods inherited from class com.linecorp.armeria.testing.junit5.common.AbstractAllOrEachExtension
afterAll, afterEach, beforeAll, beforeEach, runForEachTest
-
Constructor Details
-
EventLoopExtension
public EventLoopExtension()Creates a newExtension
that provides anEventLoop
. -
EventLoopExtension
public EventLoopExtension(boolean useDaemonThread) Creates a newExtension
that provides anEventLoop
.- Parameters:
useDaemonThread
- whether to create a daemon thread or not
-
EventLoopExtension
Creates a newExtension
that provides anEventLoop
.- Parameters:
threadNamePrefix
- the prefix of a thread name
-
EventLoopExtension
Creates a newExtension
that provides anEventLoop
.- Parameters:
threadNamePrefix
- the prefix of a thread nameuseDaemonThread
- whether to create a daemon thread or not
-
EventLoopExtension
Creates a newExtension
that provides anEventLoop
.- Parameters:
threadFactory
- the factory used to create threads.
-
-
Method Details
-
get
public io.netty.channel.EventLoop get()Returns theEventLoop
. -
before
Description copied from class:AbstractAllOrEachExtension
A method that should be run at the beginning of a test lifecycle. IfAbstractAllOrEachExtension.runForEachTest()
returnsfalse
, this is run once before all tests, otherwise it is run before each test method.- Specified by:
before
in classAbstractAllOrEachExtension
- Throws:
Exception
-
after
Shuts down all threads created by thisExtension
asynchronously. Callrule.get().shutdownGracefully().sync()
if you want to wait for complete termination.- Specified by:
after
in classAbstractAllOrEachExtension
- Throws:
Exception
-