Class TestKitJunitResource
java.lang.Object
org.junit.rules.ExternalResource
org.apache.pekko.actor.testkit.typed.javadsl.TestKitJunitResource
- All Implemented Interfaces:
org.junit.rules.TestRule
public final class TestKitJunitResource
extends org.junit.rules.ExternalResource
A Junit external resource for the
ActorTestKit, making it possible to have Junit manage the lifecycle of the testkit.
The testkit will be automatically shut down when the test completes or fails.
Note that Junit is not provided as a transitive dependency of the testkit module but must be added explicitly to your project to use this.
Example:
public class MyActorTest {
@ClassRule
public static final TestKitResource testKit = new TestKitResource();
@Test
public void testBlah() throws Exception {
// spawn actors etc using the testKit
ActorRef<Message> ref = testKit.spawn(behavior);
}
}
By default config is loaded from application-test.conf if that exists, otherwise
using default configuration from the reference.conf resources that ship with the Akka libraries.
The application.conf of your project is not used in this case.
A specific configuration can be passed as constructor parameter.
-
Constructor Summary
ConstructorsConstructorDescriptionConfig loaded fromapplication-test.confif that exists, otherwise using default configuration from the reference.conf resources that ship with the Akka libraries.TestKitJunitResource(com.typesafe.config.Config customConfig) Use a custom config for the actor system.TestKitJunitResource(com.typesafe.config.Config customConfig, TestKitSettings settings) Use a custom config for the actor system, and a custompekko.actor.testkit.typed.TestKitSettings.TestKitJunitResource(String customConfig) Use a custom config for the actor system.TestKitJunitResource(ActorSystem<?> system) Use a custompekko.actor.typed.ActorSystemfor the actor system. -
Method Summary
Modifier and TypeMethodDescriptionvoidafter()See corresponding method onActorTestKitSee corresponding method onActorTestKit<M> TestProbe<M>See corresponding method onActorTestKit<M> TestProbe<M>createTestProbe(Class<M> clazz) See corresponding method onActorTestKit<M> TestProbe<M>createTestProbe(String name) See corresponding method onActorTestKit<M> TestProbe<M>createTestProbe(String name, Class<M> clazz) See corresponding method onActorTestKitSee corresponding method onActorTestKitSee corresponding method onActorTestKitAdditional testing utilities for serialization.<T> ActorRef<T>See corresponding method onActorTestKit<T> ActorRef<T>See corresponding method onActorTestKit<T> ActorRef<T>See corresponding method onActorTestKit<T> ActorRef<T>See corresponding method onActorTestKit<T> voidSee corresponding method onActorTestKit<T> voidSee corresponding method onActorTestKitsystem()See corresponding method onActorTestKittestKit()See corresponding method onActorTestKittimeout()See corresponding method onActorTestKitMethods inherited from class org.junit.rules.ExternalResource
apply, before
-
Constructor Details
-
TestKitJunitResource
-
TestKitJunitResource
public TestKitJunitResource()Config loaded fromapplication-test.confif that exists, otherwise using default configuration from the reference.conf resources that ship with the Akka libraries. The application.conf of your project is not used in this case. -
TestKitJunitResource
Use a custompekko.actor.typed.ActorSystemfor the actor system. -
TestKitJunitResource
Use a custom config for the actor system. -
TestKitJunitResource
public TestKitJunitResource(com.typesafe.config.Config customConfig) Use a custom config for the actor system. -
TestKitJunitResource
Use a custom config for the actor system, and a custompekko.actor.testkit.typed.TestKitSettings.
-
-
Method Details
-
after
public void after()- Overrides:
afterin classorg.junit.rules.ExternalResource
-
createDeadLetterProbe
See corresponding method onActorTestKit -
createDroppedMessageProbe
See corresponding method onActorTestKit -
createTestProbe
See corresponding method onActorTestKit -
createTestProbe
See corresponding method onActorTestKit -
createTestProbe
See corresponding method onActorTestKit -
createTestProbe
See corresponding method onActorTestKit -
createUnhandledMessageProbe
See corresponding method onActorTestKit -
scheduler
See corresponding method onActorTestKit -
serializationTestKit
Additional testing utilities for serialization. -
spawn
See corresponding method onActorTestKit -
spawn
See corresponding method onActorTestKit -
spawn
See corresponding method onActorTestKit -
spawn
See corresponding method onActorTestKit -
stop
See corresponding method onActorTestKit -
stop
See corresponding method onActorTestKit -
system
See corresponding method onActorTestKit -
testKit
-
testKitSettings
See corresponding method onActorTestKit -
timeout
See corresponding method onActorTestKit
-