<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.12</artifactId>
<version>2.6.16</version>
<scope>test</scope>
</dependency>
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.testkit.JavaTestKit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class MyActorTest {
static ActorSystem system;
@BeforeClass
public static void setup() {
system = ActorSystem.create();
}
@AfterClass
public static void teardown() {
JavaTestKit.shutdownActorSystem(system);
}
@Test
public void testConcurrency() {
new JavaTestKit(system) {{
final Props props = Props.create(MyActor.class);
final ActorRef myActor = system.actorOf(props);
myActor.tell("message", getRef());
expectNoMessage();
}};
}
}