Class EventLoopRule
java.lang.Object
org.junit.rules.ExternalResource
com.linecorp.armeria.testing.junit4.common.EventLoopRule
- All Implemented Interfaces:
TestRule
A
TestRule that provides an EventLoopGroup. For example:
> public class MyTest {
> @ClassRule
> public static final EventLoopRule eventLoop = new EventLoopRule();
>
> @Test
> public void test() {
> eventLoop.get().execute(() -> System.out.println("Hello!"));
> }
> }
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEventLoopRule(boolean useDaemonThread) EventLoopRule(String threadNamePrefix) EventLoopRule(String threadNamePrefix, boolean useDaemonThread) EventLoopRule(ThreadFactory threadFactory) -
Method Summary
Methods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
EventLoopRule
public EventLoopRule() -
EventLoopRule
public EventLoopRule(boolean useDaemonThread) - Parameters:
useDaemonThread- whether to create a daemon thread or not
-
EventLoopRule
- Parameters:
threadNamePrefix- the prefix of a thread name
-
EventLoopRule
- Parameters:
threadNamePrefix- the prefix of a thread nameuseDaemonThread- whether to create a daemon thread or not
-
EventLoopRule
- Parameters:
threadFactory- the factory used to create threads.
-
-
Method Details
-
get
Returns theEventLoop. -
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
-