Permalink
Browse files

Added another test

  • Loading branch information...
1 parent 9ce0fed commit 2fda1f13cacb57c38297f1761dc695e4dd343a03 @jamie-allen committed Apr 26, 2012
@@ -15,5 +15,7 @@ class A_Actor extends Actor {
// println("Got CA message with value %d".format(y))
ca_count += 1
sender ! AC(ca_count)
+ case Blah(z) if z == 0 => throw new IllegalArgumentException("Got invalid data")
+ case Blah(z) => println("**** HERE ****"); sender ! Blah(z)
}
}
@@ -22,4 +22,6 @@ package object ats2m {
sealed trait CB_Message
case class CB(value: Int) extends CB_Message
+
+ case class Blah(value: Int)
}
@@ -10,20 +10,12 @@ import akka.actor.ActorSystem
import akka.actor.Props
import akka.testkit._
-/**
- * Required to fix implicit collision with TestKit duration
- */
-//trait DeactivatedTimeConversions extends org.specs2.time.TimeConversions {
-// override def intToRichLong(v: Int) = super.intToRichLong(v)
-// override def longToRichLong(v: Long) = super.longToRichLong(v)
-//}
-
@RunWith(classOf[JUnitRunner])
-class AkkaTestKitWithSpecs2AndMockito(_system: ActorSystem) extends TestKit(_system) with Specification with Mockito { //with DeactivatedTimeConversions {
+class AkkaTestKitWithSpecs2AndMockito(_system: ActorSystem) extends TestKit(_system) with Specification with Mockito { // with ImplicitSender {
def this() = this(ActorSystem())
- "The actor system" should {
- "make a call into the ExternalService" in {
+ "As a data owner, the actor system" should {
+ "make a call into the ExternalService so I can get updated information" in {
val externalService = mock[ExternalService].defaultReturn("Hello")
val a = system.actorOf(Props[A_Actor])
@@ -38,4 +30,11 @@ class AkkaTestKitWithSpecs2AndMockito(_system: ActorSystem) extends TestKit(_sys
there was atLeastOne(externalService).goDoSomething
}
}
+
+ "As an Actor A user" should {
+ "throw an IllegalArgumentException when it gets invalid data" in {
+ val a = TestActorRef[A_Actor]
+ a.receive(Blah(0)) must throwAn[IllegalArgumentException]
+ }
+ }
}

0 comments on commit 2fda1f1

Please sign in to comment.