Class EventLoopExtension
java.lang.Object
com.linecorp.armeria.testing.junit5.common.AbstractAllOrEachExtension
com.linecorp.armeria.testing.junit5.common.EventLoopExtension
- All Implemented Interfaces:
AfterAllCallback,AfterEachCallback,BeforeAllCallback,BeforeEachCallback,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
ConstructorsConstructorDescriptionEventLoopExtension(boolean useDaemonThread) EventLoopExtension(String threadNamePrefix) EventLoopExtension(String threadNamePrefix, boolean useDaemonThread) EventLoopExtension(ThreadFactory threadFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidafter(ExtensionContext context) Shuts down all threads created by thisExtensionasynchronously.voidbefore(ExtensionContext context) A method that should be run at the beginning of a test lifecycle.get()Returns theEventLoop.Methods inherited from class com.linecorp.armeria.testing.junit5.common.AbstractAllOrEachExtension
afterAll, afterEach, beforeAll, beforeEach, runForEachTest
-
Constructor Details
-
EventLoopExtension
public EventLoopExtension() -
EventLoopExtension
public EventLoopExtension(boolean useDaemonThread) - Parameters:
useDaemonThread- whether to create a daemon thread or not
-
EventLoopExtension
- Parameters:
threadNamePrefix- the prefix of a thread name
-
EventLoopExtension
- Parameters:
threadNamePrefix- the prefix of a thread nameuseDaemonThread- whether to create a daemon thread or not
-
EventLoopExtension
- Parameters:
threadFactory- the factory used to create threads.
-
-
Method Details
-
get
Returns theEventLoop. -
before
Description copied from class:AbstractAllOrEachExtensionA 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:
beforein classAbstractAllOrEachExtension- Throws:
Exception
-
after
Shuts down all threads created by thisExtensionasynchronously. Callrule.get().shutdownGracefully().sync()if you want to wait for complete termination.- Specified by:
afterin classAbstractAllOrEachExtension- Throws:
Exception
-