Package akka.javasdk.testkit
Class TestKitSupport
Object
akka.javasdk.testkit.AsyncCallsSupport
akka.javasdk.testkit.TestKitSupport
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 Summary
FieldsModifier and TypeFieldDescriptionprotected akka.javasdk.client.ComponentClientprotected akka.javasdk.http.HttpClientA 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.protected TestKitprotected akka.javasdk.timer.TimerScheduler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterAll()void<T> TgetDependency(Class<T> clazz) Lookup a specific object as provided by the service dependency provider<T extends akka.grpc.javadsl.AkkaGrpcClient>
TgetGrpcEndpointClient(Class<T> grpcClientClass) Get a gRPC client for an endpoint provided by this service.<T extends akka.grpc.javadsl.AkkaGrpcClient>
TgetGrpcEndpointClient(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.akka.javasdk.Sanitizerprotected TestKit.SettingsOverride this to use custom settings for an integration testMethods inherited from class akka.javasdk.testkit.AsyncCallsSupport
await, await, failed
-
Field Details
-
testKit
-
componentClient
protected akka.javasdk.client.ComponentClient componentClient -
timerScheduler
protected akka.javasdk.timer.TimerScheduler timerScheduler -
httpClient
protected akka.javasdk.http.HttpClient httpClientA 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
Override this to use custom settings for an integration test -
beforeAll
@BeforeAll public void beforeAll() -
afterAll
@AfterAll public void afterAll() -
getDependency
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 servicerequestPrincipal- 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.
-