Class AkkaServerlessTestkit


  • public class AkkaServerlessTestkit
    extends java.lang.Object
    Testkit for running Akka Serverless services locally.

    Requires Docker for starting a local instance of Akka Serverless.

    Create an AkkaServerlessTestkit with an AkkaServerless service descriptor, and then start() the testkit before testing the service with gRPC or HTTP clients. Call stop() after tests are complete.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  AkkaServerlessTestkit.Settings
      Settings for AkkaServerlessTestkit.
    • Constructor Summary

      Constructors 
      Constructor Description
      AkkaServerlessTestkit​(com.akkaserverless.javasdk.AkkaServerless akkaServerless)
      Create a new testkit for an AkkaServerless service descriptor.
      AkkaServerlessTestkit​(com.akkaserverless.javasdk.AkkaServerless akkaServerless, AkkaServerlessTestkit.Settings settings)
      Create a new testkit for an AkkaServerless service descriptor with custom settings.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static int availableLocalPort()
      Get an available local port for testing.
      akka.actor.ActorSystem getActorSystem()
      Get an ActorSystem for creating Akka gRPC or Akka HTTP clients.
      akka.grpc.GrpcClientSettings getGrpcClientSettings()
      Get GrpcClientSettings for creating Akka gRPC clients.
      int getPort()
      Get the local port where the Akka Serverless service is available.
      AkkaServerlessTestkit start()
      Start this testkit with default configuration (loaded from application.conf).
      AkkaServerlessTestkit start​(com.typesafe.config.Config config)
      Start this testkit with custom configuration (overrides application.conf).
      void stop()
      Stop the testkit and local Akka Serverless.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AkkaServerlessTestkit

        public AkkaServerlessTestkit​(com.akkaserverless.javasdk.AkkaServerless akkaServerless)
        Create a new testkit for an AkkaServerless service descriptor.
        Parameters:
        akkaServerless - AkkaServerless service descriptor
      • AkkaServerlessTestkit

        public AkkaServerlessTestkit​(com.akkaserverless.javasdk.AkkaServerless akkaServerless,
                                     AkkaServerlessTestkit.Settings settings)
        Create a new testkit for an AkkaServerless service descriptor with custom settings.
        Parameters:
        akkaServerless - AkkaServerless service descriptor
        settings - custom testkit settings
    • Method Detail

      • start

        public AkkaServerlessTestkit start()
        Start this testkit with default configuration (loaded from application.conf).
        Returns:
        this AkkaServerlessTestkit
      • start

        public AkkaServerlessTestkit start​(com.typesafe.config.Config config)
        Start this testkit with custom configuration (overrides application.conf).
        Parameters:
        config - custom test configuration for the AkkaServerlessRunner
        Returns:
        this AkkaServerlessTestkit
      • getPort

        public int getPort()
        Get the local port where the Akka Serverless service is available.
        Returns:
        local Akka Serverless port
      • getActorSystem

        public akka.actor.ActorSystem getActorSystem()
        Get an ActorSystem for creating Akka gRPC or Akka HTTP clients.
        Returns:
        test actor system
      • getGrpcClientSettings

        public akka.grpc.GrpcClientSettings getGrpcClientSettings()
        Get GrpcClientSettings for creating Akka gRPC clients.
        Returns:
        test gRPC client settings
      • stop

        public void stop()
        Stop the testkit and local Akka Serverless.
      • availableLocalPort

        public static int availableLocalPort()
        Get an available local port for testing.
        Returns:
        available local port