Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat project/build.properties
- sbt.version=0.13.7
- $ cat build.sbt
- name := "test"
- version := "0.0.1"
- scalaVersion := "2.11.6"
- scalacOptions += "-deprecation"
- libraryDependencies ++= Seq(
- "com.typesafe.akka" %% "akka-actor" % "2.3.9",
- "com.typesafe.akka" %% "akka-testkit" % "2.3.9"
- )
- $ cat test.scala
- object Main extends App {
- import akka.actor.ActorSystem
- import akka.testkit.TestActorRef
- import akka.pattern.ask
- import akka.util.Timeout
- class Test(i: Int) {
- import akka.actor.Actor
- class MyActor(j: Int) extends Actor {
- def receive = {
- case x => sender ! (i, j, x)
- }
- }
- }
- val t = new Test(13)
- implicit val as = ActorSystem("test");
- import as.dispatcher
- val actorRef = TestActorRef(new t.MyActor(666))
- implicit val timeout = Timeout.intToTimeout(1000)
- val res = actorRef ? 'xxx
- res.map(println).onComplete{ x => as.shutdown() }
- }
- $ sbt run
- [info] Running Main
- (13,666,'xxx)
- [success] Total time: 1 s, completed 11.03.2015 9:38:08
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement