Class EventLoopRule

java.lang.Object
org.junit.rules.ExternalResource
com.linecorp.armeria.testing.junit4.common.EventLoopRule
All Implemented Interfaces:
TestRule

public final class EventLoopRule
extends ExternalResource
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:
EventLoopGroupRule
  • Constructor Details

    • EventLoopRule

      public EventLoopRule()
      Creates a new TestRule that provides an EventLoop.
    • EventLoopRule

      public EventLoopRule​(boolean useDaemonThread)
      Creates a new TestRule that provides an EventLoop.
      Parameters:
      useDaemonThread - whether to create a daemon thread or not
    • EventLoopRule

      public EventLoopRule​(String threadNamePrefix)
      Creates a new TestRule that provides an EventLoop.
      Parameters:
      threadNamePrefix - the prefix of a thread name
    • EventLoopRule

      public EventLoopRule​(String threadNamePrefix, boolean useDaemonThread)
      Creates a new TestRule that provides an EventLoop.
      Parameters:
      threadNamePrefix - the prefix of a thread name
      useDaemonThread - whether to create a daemon thread or not
  • Method Details