Class ActorSystemExtension

java.lang.Object
org.apache.pekko.http.javadsl.testkit.ActorSystemExtension
All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension

public class ActorSystemExtension extends Object implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback
A JUnit 5 (Jupiter) Extension that manages the lifecycle of an ActorSystem.

This is the JUnit 5 counterpart of ActorSystemResource which uses JUnit 4's ExternalResource. It implements BeforeEachCallback and AfterEachCallback to create and terminate the ActorSystem around each test method.

Usage with @RegisterExtension:


 @RegisterExtension
 ActorSystemExtension systemExtension = new ActorSystemExtension("MyTest", ConfigFactory.empty());
 

Or use it indirectly through JUnitJupiterRouteTest.

  • Constructor Details

    • ActorSystemExtension

      public ActorSystemExtension(String name, com.typesafe.config.Config additionalConfig)
  • Method Details

    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
    • config

      protected com.typesafe.config.Config config()
    • createSystem

      protected org.apache.pekko.actor.ActorSystem createSystem()
    • materializer

      public org.apache.pekko.stream.Materializer materializer()
    • system

      public org.apache.pekko.actor.ActorSystem system()