The Artima Developer Community
Sponsored Link

Akka Concurrency Forum
Ch 6.5 MyActorSpec

2 replies on 1 page. Most recent reply: Feb 27, 2016 12:30 PM by Denis Zjukov

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Denis Zjukov

Posts: 3
Nickname: denisz
Registered: Feb, 2016

Ch 6.5 MyActorSpec Posted: Feb 27, 2016 11:47 AM
Reply to this message Reply
Advertisement
Hi,

Could anyone clarify why the first test below is supposed to throw an exception? Thanks!


class MyActorSpec extends fixture.WordSpec with Matchers
with fixture.UnitFixture
with ParallelTestExecution {

def makeActor(system: ActorSystem): ActorRef = system.actorOf(Props[MyActor], "MyActor")

"My Actor" should {
"throw when made with the wrong name" in new ActorSys {
a[Exception] should be thrownBy {
val a = system.actorOf(Props[MyActor])
}
}
"construct without exception" in new ActorSys {
val a = makeActor(system)
}
"respond with a Pong to a Ping" in new ActorSys {
val a = makeActor(system)
a ! "Ping"
expectMsg("Pong")
}
}
}
[pre]


Derek Wyatt

Posts: 69
Nickname: dwyatt
Registered: Oct, 2012

Re: Ch 6.5 MyActorSpec Posted: Feb 27, 2016 12:16 PM
Reply to this message Reply
It's very possible that it doesn't. I've hunted through the book a bit and I can't see that it should. It's possible that a change to the text, at some point, eliminated some code that I recall writing. It was something that would throw an exception if it was built with the wrong name... however, that would have required a deep integration with the calling thread dispatcher.

I wouldn't worry about it too much... chalk it up to a bug in the book. The main idea is still that actor names must be unique, so naming them specifically in a test can be a bad idea, should you create that actor many times in a test. So you either need to use different names, or use isolated actor systems, as the text goes on to say.

Sorry about the confusion.

Denis Zjukov

Posts: 3
Nickname: denisz
Registered: Feb, 2016

Re: Ch 6.5 MyActorSpec Posted: Feb 27, 2016 12:30 PM
Reply to this message Reply
Thanks a lot for quick response! Anyway, it's a great book! I like the Plane example project :)

Flat View: This topic has 2 replies on 1 page
Topic: Ch 8.6 Testing Death Watch Previous Topic   Next Topic Topic: FSM's onTransition, transform and using

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use