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
ConstructorDescriptionEventLoopRule
(boolean useDaemonThread) EventLoopRule
(String threadNamePrefix) EventLoopRule
(String threadNamePrefix, boolean useDaemonThread) -
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
-
-
Method Details
-
get
Returns theEventLoop
. -
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
-