Class EventLoopGroupExtension
java.lang.Object
com.linecorp.armeria.testing.junit5.common.AbstractAllOrEachExtension
com.linecorp.armeria.testing.junit5.common.EventLoopGroupExtension
- All Implemented Interfaces:
AfterAllCallback
,AfterEachCallback
,BeforeAllCallback
,BeforeEachCallback
,Extension
An
Extension
that provides an EventLoopGroup
. For example:
> public class MyTest {
> @RegisterExtension
> public static final EventLoopGroupExtension eventLoopGroup = new EventLoopGroupExtension(4);
>
> @Test
> public void test() {
> ClientFactory f = ClientFactory.builder()
> .workerGroup(eventLoopGroup.get())
> .build();
> ...
> }
> }
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEventLoopGroupExtension
(int numThreads) Creates a newExtension
that provides anEventLoopGroup
.EventLoopGroupExtension
(int numThreads, boolean useDaemonThreads) Creates a newExtension
that provides anEventLoopGroup
.EventLoopGroupExtension
(int numThreads, String threadNamePrefix) Creates a newExtension
that provides anEventLoopGroup
.EventLoopGroupExtension
(int numThreads, String threadNamePrefix, boolean useDaemonThreads) Creates a newExtension
that provides anEventLoopGroup
.EventLoopGroupExtension
(int numThreads, ThreadFactory threadFactory) Creates a newExtension
that provides anEventLoopGroup
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
after
(ExtensionContext context) Shuts down all threads created by thisExtension
asynchronously.void
before
(ExtensionContext context) A method that should be run at the beginning of a test lifecycle.get()
Returns theEventLoopGroup
.Methods inherited from class com.linecorp.armeria.testing.junit5.common.AbstractAllOrEachExtension
afterAll, afterEach, beforeAll, beforeEach, runForEachTest
-
Constructor Details
-
EventLoopGroupExtension
public EventLoopGroupExtension(int numThreads) Creates a newExtension
that provides anEventLoopGroup
.- Parameters:
numThreads
- the number of event loop threads
-
EventLoopGroupExtension
public EventLoopGroupExtension(int numThreads, boolean useDaemonThreads) Creates a newExtension
that provides anEventLoopGroup
.- Parameters:
numThreads
- the number of event loop threadsuseDaemonThreads
- whether to create daemon threads or not
-
EventLoopGroupExtension
Creates a newExtension
that provides anEventLoopGroup
.- Parameters:
numThreads
- the number of event loop threadsthreadNamePrefix
- the prefix of thread names
-
EventLoopGroupExtension
Creates a newExtension
that provides anEventLoopGroup
.- Parameters:
numThreads
- the number of event loop threadsthreadNamePrefix
- the prefix of thread namesuseDaemonThreads
- whether to create daemon threads or not
-
EventLoopGroupExtension
Creates a newExtension
that provides anEventLoopGroup
.- Parameters:
numThreads
- the number of event loop threadsthreadFactory
- the factory used to create threads.
-
-
Method Details
-
get
Returns theEventLoopGroup
. -
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
-