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 newExtensionthat provides anEventLoopGroup.EventLoopGroupExtension(int numThreads, boolean useDaemonThreads) Creates a newExtensionthat provides anEventLoopGroup.EventLoopGroupExtension(int numThreads, String threadNamePrefix) Creates a newExtensionthat provides anEventLoopGroup.EventLoopGroupExtension(int numThreads, String threadNamePrefix, boolean useDaemonThreads) Creates a newExtensionthat provides anEventLoopGroup. -
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 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 newExtensionthat provides anEventLoopGroup.- Parameters:
numThreads- the number of event loop threads
-
EventLoopGroupExtension
public EventLoopGroupExtension(int numThreads, boolean useDaemonThreads) Creates a newExtensionthat provides anEventLoopGroup.- Parameters:
numThreads- the number of event loop threadsuseDaemonThreads- whether to create daemon threads or not
-
EventLoopGroupExtension
Creates a newExtensionthat provides anEventLoopGroup.- Parameters:
numThreads- the number of event loop threadsthreadNamePrefix- the prefix of thread names
-
EventLoopGroupExtension
Creates a newExtensionthat provides anEventLoopGroup.- Parameters:
numThreads- the number of event loop threadsthreadNamePrefix- the prefix of thread namesuseDaemonThreads- whether to create daemon threads or not
-
-
Method Details
-
get
Returns theEventLoopGroup. -
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
-