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
ConstructorsConstructorDescriptionEventLoopGroupRule(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.EventLoopGroupRule(int numThreads, ThreadFactory threadFactory) Creates a newTestRulethat provides anEventLoopGroup. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafter()Shuts down all threads created by thisTestRuleasynchronously.protected voidbefore()get()Returns theEventLoopGroup.Methods inherited from class org.junit.rules.ExternalResource
apply
-
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
-
EventLoopGroupRule
Creates a newTestRulethat provides anEventLoopGroup.- Parameters:
numThreads- the number of event loop threadsthreadFactory- the factory used to create threads.
-
-
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
-