Class TestKitSupport

Object
akka.javasdk.testkit.AsyncCallsSupport
akka.javasdk.testkit.TestKitSupport

@TestInstance(PER_CLASS) public abstract class TestKitSupport extends AsyncCallsSupport
This class provided the necessary infrastructure to run integration test for projects built with the Java SDK. Users should let their test classes extend this class.

This class wires-up a local service using the user's defined components.

Users can interact with their components via their public endpoint via an HTTP client or internally through the {{componentClient}}.

On test teardown, the service and the runtime will be stopped.

  • Field Details

    • testKit

      protected TestKit testKit
    • componentClient

      protected akka.javasdk.client.ComponentClient componentClient
    • timerScheduler

      protected akka.javasdk.timer.TimerScheduler timerScheduler
    • httpClient

      protected akka.javasdk.http.HttpClient httpClient
      A http client for interacting with the service under test, the client will not be authenticated and will appear to the service as a request with the internet principal.
  • Constructor Details

    • TestKitSupport

      public TestKitSupport()
  • Method Details

    • testKitSettings

      protected TestKit.Settings testKitSettings()
      Override this to use custom settings for an integration test
    • beforeAll

      @BeforeAll public void beforeAll()
    • afterAll

      @AfterAll public void afterAll()
    • getDependency

      public <T> T getDependency(Class<T> clazz)
      Lookup a specific object as provided by the service dependency provider
    • getGrpcEndpointClient

      public <T extends akka.grpc.javadsl.AkkaGrpcClient> T getGrpcEndpointClient(Class<T> grpcClientClass)
      Get a gRPC client for an endpoint provided by this service. Requests will appear as coming from this service itself from an ACL perspective.
      Parameters:
      grpcClientClass - The generated Akka gRPC client interface for a gRPC endpoint in this service
    • getGrpcEndpointClient

      public <T extends akka.grpc.javadsl.AkkaGrpcClient> T getGrpcEndpointClient(Class<T> grpcClientClass, akka.javasdk.Principal requestPrincipal)
      Get a gRPC client for an endpoint provided by this service but specify the client principal for the ACLs.
      Parameters:
      grpcClientClass - The generated Akka gRPC client interface for a gRPC endpoint in this service
      requestPrincipal - A principal that any request from the returned service will have when requests are handled in the endpoint.
    • getSanitizer

      public akka.javasdk.Sanitizer getSanitizer()
      Returns:
      The configured sanitizer for the service, for test assertions that the expected anonymization is applied. Will always return an instance, if no sanitization rules are configured, the returned sanitizer will return all text fed to it as is.