Created
August 7, 2012 18:45
-
-
Save derekwyatt/3288247 to your computer and use it in GitHub Desktop.
Test of the TestWorker in the Master / Worker remote node pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WorkerSpec extends TestKit(ActorSystem("WorkerSpec")) | |
| with ImplicitSender | |
| with WordSpec | |
| with BeforeAndAfterAll | |
| with MustMatchers { | |
| override def afterAll() { | |
| system.shutdown() | |
| } | |
| def worker(name: String) = system.actorOf(Props( | |
| new TestWorker(ActorPath.fromString( | |
| "akka://%s/user/%s".format(system.name, name))))) | |
| "Worker" should { | |
| "work" in { | |
| // Spin up the master | |
| val m = system.actorOf(Props[Master], "master") | |
| // Create three workers | |
| val w1 = worker("master") | |
| val w2 = worker("master") | |
| val w3 = worker("master") | |
| // Send some work to the master | |
| m ! "Hithere" | |
| m ! "Guys" | |
| m ! "So" | |
| m ! "What's" | |
| m ! "Up?" | |
| // We should get it all back | |
| expectMsgAllOf("Hithere", "Guys", "So", "What's", "Up?") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment