Class EventLoopGroupRule
java.lang.Object
org.junit.rules.ExternalResource
com.linecorp.armeria.testing.junit4.common.EventLoopGroupRule
- All Implemented Interfaces:
TestRule
public final class EventLoopGroupRule extends ExternalResource
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:
EventLoopRule
-
Constructor Summary
Constructors Constructor Description EventLoopGroupRule(int numThreads)Creates a newTestRulethat provides anEventLoopGroup.EventLoopGroupRule(int numThreads, boolean useDaemonThreads)Creates a newTestRulethat provides anEventLoopGroup.EventLoopGroupRule(int numThreads, String threadNamePrefix)Creates a newTestRulethat provides anEventLoopGroup.EventLoopGroupRule(int numThreads, String threadNamePrefix, boolean useDaemonThreads)Creates a newTestRulethat provides anEventLoopGroup. -
Method Summary
Modifier and Type Method Description protected voidafter()Shuts down all threads created by thisTestRuleasynchronously.protected voidbefore()EventLoopGroupget()Returns theEventLoopGroup.
-
Constructor Details
-
EventLoopGroupRule
public EventLoopGroupRule(int numThreads)Creates a newTestRulethat provides anEventLoopGroup.- Parameters:
numThreads- the number of event loop threads
-
EventLoopGroupRule
public EventLoopGroupRule(int numThreads, boolean useDaemonThreads)Creates a newTestRulethat provides anEventLoopGroup.- Parameters:
numThreads- the number of event loop threadsuseDaemonThreads- whether to create daemon threads or not
-
EventLoopGroupRule
Creates a newTestRulethat provides anEventLoopGroup.- Parameters:
numThreads- the number of event loop threadsthreadNamePrefix- the prefix of thread names
-
EventLoopGroupRule
Creates a newTestRulethat 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:
beforein classExternalResource- Throws:
Throwable
-
after
protected void after()Shuts down all threads created by thisTestRuleasynchronously. Callrule.get().shutdownGracefully().sync()if you want to wait for complete termination.- Overrides:
afterin classExternalResource
-