Skip to content

Instantly share code, notes, and snippets.

@phaller
Created March 8, 2012 22:58
Show Gist options
  • Save phaller/2003998 to your computer and use it in GitHub Desktop.
Save phaller/2003998 to your computer and use it in GitHub Desktop.
package org.akkatrain
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner
import akka.util.Duration
import akka.actor.ActorSystem
import akka.actor.Props
import akka.pattern.ask
import akka.util.Timeout
import akka.dispatch.Await
@RunWith(classOf[JUnitRunner])
class ActorsSpec extends Specification {
"A ComputeActor" should {
"respond with the correct results" in {
val timeout = Duration(1000, "millis")
val sys = ActorSystem()
val worker = sys.actorOf(Props[ComputeActor])
val future = worker.ask("hello world")(Timeout(2000))
Await.result(future, timeout).asInstanceOf[Int] must beEqualTo(11)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment