Moving to s.c.EC and s.c.A, compiles but tests aren't passing

This commit is contained in:
Viktor Klang 2012-06-29 16:40:36 +02:00
parent e62a0eee1c
commit 8ede1f55e9
12 changed files with 28 additions and 20 deletions

View file

@ -9,6 +9,7 @@ import akka.actor.TypedActor;
import akka.dispatch.*;
import akka.actor.*;
import akka.japi.*;
import scala.concurrent.Await;
import scala.concurrent.util.Duration;
import java.util.concurrent.TimeUnit;

View file

@ -202,14 +202,14 @@ public class UntypedActorDocTestBase {
ActorSystem system = ActorSystem.create("MySystem");
ActorRef actorRef = system.actorOf(new Props(MyUntypedActor.class));
//#gracefulStop
try {
//FIXME URGENT Await.result should have a @throws clause
//try {
Future<Boolean> stopped = gracefulStop(actorRef, Duration.create(5, TimeUnit.SECONDS), system);
Await.result(stopped, Duration.create(6, TimeUnit.SECONDS));
// the actor has been stopped
} catch (AskTimeoutException e) {
//} catch (AskTimeoutException e) {
// the actor wasn't stopped within 5 seconds
}
//}
//#gracefulStop
system.shutdown();
}

View file

@ -5,6 +5,7 @@ package docs.future;
//#imports1
import akka.dispatch.*;
import scala.concurrent.Await;
import akka.util.Timeout;
//#imports1
@ -40,8 +41,8 @@ import static akka.dispatch.Futures.reduce;
//#imports6
//#imports7
import scala.concurrent.ExecutionContexts;
import scala.concurrent.ExecutionContextExecutorService;
import scala.concurrent.ExecutionContext;
import scala.concurrent.ExecutionContext$;
//#imports7
@ -79,17 +80,17 @@ public class FutureDocTestBase {
system.shutdown();
}
@Test public void useCustomExecutionContext() throws Exception {
@SuppressWarnings("unchecked") @Test public void useCustomExecutionContext() throws Exception {
ExecutorService yourExecutorServiceGoesHere = Executors.newSingleThreadExecutor();
//#diy-execution-context
ExecutionContextExecutorService ec =
ExecutionContexts.fromExecutorService(yourExecutorServiceGoesHere);
ExecutionContext ec =
ExecutionContext$.MODULE$.fromExecutorService(yourExecutorServiceGoesHere, (scala.Function1<java.lang.Throwable,scala.runtime.BoxedUnit>)(ExecutionContext$.MODULE$.fromExecutorService$default$2()));
//Use ec with your Futures
Future<String> f1 = Futures.successful("foo", ec);
// Then you shut the ec down somewhere at the end of your program/application.
ec.shutdown();
// Then you shut the ExecutorService down somewhere at the end of your program/application.
yourExecutorServiceGoesHere.shutdown();
//#diy-execution-context
}