Class EventLoopGroupRule
java.lang.Object
org.junit.rules.ExternalResource
com.linecorp.armeria.testing.junit4.common.EventLoopGroupRule
- All Implemented Interfaces:
TestRule
A
TestRule
that provides an EventLoopGroup
. For example:
> public class MyTest {
> @ClassRule
> public static final EventLoopGroupRule eventLoopGroup = new EventLoopGroupRule(4);
>
> @Test
> public void test() {
> ClientFactory f = ClientFactory.builder()
> .workerGroup(eventLoopGroup.get())
> .build();
> ...
> }
> }
- See Also:
-
Constructor Summary
ConstructorDescriptionEventLoopGroupRule
(int numThreads) Creates a newTestRule
that provides anEventLoopGroup
.EventLoopGroupRule
(int numThreads, boolean useDaemonThreads) Creates a newTestRule
that provides anEventLoopGroup
.EventLoopGroupRule
(int numThreads, String threadNamePrefix) Creates a newTestRule
that provides anEventLoopGroup
.EventLoopGroupRule
(int numThreads, String threadNamePrefix, boolean useDaemonThreads) Creates a newTestRule
that provides anEventLoopGroup
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
after()
Shuts down all threads created by thisTestRule
asynchronously.protected void
before()
get()
Returns theEventLoopGroup
.Methods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
EventLoopGroupRule
public EventLoopGroupRule(int numThreads) Creates a newTestRule
that provides anEventLoopGroup
.- Parameters:
numThreads
- the number of event loop threads
-
EventLoopGroupRule
public EventLoopGroupRule(int numThreads, boolean useDaemonThreads) Creates a newTestRule
that provides anEventLoopGroup
.- Parameters:
numThreads
- the number of event loop threadsuseDaemonThreads
- whether to create daemon threads or not
-
EventLoopGroupRule
Creates a newTestRule
that provides anEventLoopGroup
.- Parameters:
numThreads
- the number of event loop threadsthreadNamePrefix
- the prefix of thread names
-
EventLoopGroupRule
Creates a newTestRule
that 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
- Overrides:
before
in classExternalResource
- Throws:
Throwable
-
after
protected void after()Shuts down all threads created by thisTestRule
asynchronously. Callrule.get().shutdownGracefully().sync()
if you want to wait for complete termination.- Overrides:
after
in classExternalResource
-