@@ -0,0 +1,2322 @@
+package org.ak80.akkabase;%0A%0Aimport akka.actor.*;%0Aimport akka.japi.pf.ReceiveBuilder;%0Aimport akka.testkit.JavaTestKit;%0Aimport org.junit.AfterClass;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.rules.ExpectedException;%0Aimport scala.PartialFunction;%0Aimport scala.concurrent.Future;%0A%0Aimport java.util.concurrent.CompletableFuture;%0Aimport java.util.concurrent.CompletionStage;%0Aimport java.util.concurrent.ExecutionException;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport static akka.pattern.Patterns.ask;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static scala.compat.java8.FutureConverters.toJava;%0A%0Apublic class SandBoxTest %7B%0A%0A  @Rule%0A  public ExpectedException expectedException = ExpectedException.none();%0A%0A  private static ActorSystem system;%0A%0A  @BeforeClass%0A  public static void setUp() %7B%0A    system = ActorSystem.create();%0A  %7D%0A%0A  @AfterClass%0A  public static void tearDown() %7B%0A    JavaTestKit.shutdownActorSystem(system);%0A    system = null;%0A  %7D%0A%0A  @Test%0A  public void shouldReplyToPingWithPong() throws Exception %7B%0A    // Given%0A    ActorRef actorRef = system.actorOf(PongActor.create());%0A%0A    // When%0A    Future sFuture = ask(actorRef, %22Ping%22, 1000);%0A%0A    // Then%0A    CompletionStage%3CString%3E cs = toJava(sFuture);%0A    CompletableFuture%3CString%3E jFuture = (CompletableFuture%3CString%3E) cs;%0A    assertEquals(%22Pong%22, jFuture.get(1000, TimeUnit.MILLISECONDS));%0A  %7D%0A%0A  @Test%0A  public void shouldReplyToUnknownMessageWithFailure() throws Exception %7B%0A    // Given%0A    ActorRef actorRef = system.actorOf(PongActor.create());%0A%0A    // Then%0A    expectedException.expect(ExecutionException.class);%0A%0A    // When%0A    Future sFuture = ask(actorRef, %22unknown%22, 1000);%0A    CompletionStage%3CString%3E cs = toJava(sFuture);%0A    CompletableFuture%3CString%3E jFuture = (CompletableFuture%3CString%3E) cs;%0A    jFuture.get(1000, TimeUnit.MILLISECONDS);%0A  %7D%0A%0A%0A  public static class PongActor extends AbstractActor %7B%0A%0A    public static Props create() %7B%0A      return Props.create(PongActor.class);%0A    %7D%0A%0A    @Override%0A    public PartialFunction receive() %7B%0A      return ReceiveBuilder%0A          .matchEquals(%22Ping%22, s -%3E sender().tell(%22Pong%22, ActorRef.noSender()))%0A          .matchAny(x -%3E sender().tell(new Status.Failure(new Exception(%22unknown message%22)), self()))%0A          .build();%0A    %7D%0A%0A  %7D%0A%0A%0A%7D%0A%0A

Add sandbox