Skip to content

Commit

Permalink
=pro #3759 Changed to using non-deprecated ScalaTest Matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
bantonsson committed Dec 18, 2013
1 parent b8c7d7b commit 003609c
Show file tree
Hide file tree
Showing 246 changed files with 2,825 additions and 2,825 deletions.
4 changes: 2 additions & 2 deletions akka-actor-tests/src/test/scala/akka/AkkaExceptionSpec.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package akka;

import akka.actor._
import org.scalatest.matchers.MustMatchers
import org.scalatest.Matchers
import org.scalatest.WordSpec;

/**
* A spec that verified that the AkkaException has at least a single argument constructor of type String.
*
* This is required to make Akka Exceptions be friends with serialization/deserialization.
*/
class AkkaExceptionSpec extends WordSpec with MustMatchers {
class AkkaExceptionSpec extends WordSpec with Matchers {

"AkkaException" must {
"have a AkkaException(String msg) constructor to be serialization friendly" in {
Expand Down
18 changes: 9 additions & 9 deletions akka-actor-tests/src/test/scala/akka/actor/ActorDSLSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ActorDSLSpec extends AkkaSpec {
//#inbox
implicit val i = inbox()
echo ! "hello"
i.receive() must be("hello")
i.receive() should be("hello")
//#inbox
}

Expand All @@ -50,7 +50,7 @@ class ActorDSLSpec extends AkkaSpec {
i watch target
//#watch
target ! PoisonPill
i receive 1.second must be(Terminated(target)(true, false))
i receive 1.second should be(Terminated(target)(true, false))
}

"support queueing multiple queries" in {
Expand All @@ -61,11 +61,11 @@ class ActorDSLSpec extends AkkaSpec {
Future { Thread.sleep(100); i.select() { case "world" 1 } } recover { case x x },
Future { Thread.sleep(200); i.select() { case "hello" 2 } } recover { case x x }))
Thread.sleep(1000)
res.isCompleted must be(false)
res.isCompleted should be(false)
i.receiver ! 42
i.receiver ! "hello"
i.receiver ! "world"
Await.result(res, 5 second) must be(Seq(42, 1, 2))
Await.result(res, 5 second) should be(Seq(42, 1, 2))
}

"support selective receives" in {
Expand All @@ -75,8 +75,8 @@ class ActorDSLSpec extends AkkaSpec {
val result = i.select() {
case "world" true
}
result must be(true)
i.receive() must be("hello")
result should be(true)
i.receive() should be("hello")
}

"have a maximum queue size" in {
Expand All @@ -92,7 +92,7 @@ class ActorDSLSpec extends AkkaSpec {
i.receiver ! 42
expectNoMsg(1 second)
val gotit = for (_ 1 to 1000) yield i.receive()
gotit must be((1 to 1000) map (_ 0))
gotit should be((1 to 1000) map (_ 0))
intercept[TimeoutException] {
i.receive(1 second)
}
Expand Down Expand Up @@ -126,7 +126,7 @@ class ActorDSLSpec extends AkkaSpec {

implicit val i = inbox()
a ! "hello"
i.receive() must be("hi")
i.receive() should be("hi")
}

"support becomeStacked" in {
Expand Down Expand Up @@ -231,7 +231,7 @@ class ActorDSLSpec extends AkkaSpec {
})
//#nested-actor
expectMsg("hello from akka://ActorDSLSpec/user/fred/barney")
lastSender must be(a)
lastSender should be(a)
}

"support Stash" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,27 @@ class ActorFireForgetRequestReplySpec extends AkkaSpec with BeforeAndAfterEach w
val senderActor = system.actorOf(Props(new SenderActor(replyActor)))
senderActor ! "Init"
state.finished.await
state.s must be("Reply")
state.s should be("Reply")
}

"reply to bang message using implicit sender" in {
val replyActor = system.actorOf(Props[ReplyActor])
val senderActor = system.actorOf(Props(new SenderActor(replyActor)))
senderActor ! "InitImplicit"
state.finished.await
state.s must be("ReplyImplicit")
state.s should be("ReplyImplicit")
}

"shutdown crashed temporary actor" in {
filterEvents(EventFilter[Exception]("Expected exception")) {
val supervisor = system.actorOf(Props(new Supervisor(
OneForOneStrategy(maxNrOfRetries = 0)(List(classOf[Exception])))))
val actor = Await.result((supervisor ? Props[CrashingActor]).mapTo[ActorRef], timeout.duration)
actor.isTerminated must be(false)
actor.isTerminated should be(false)
actor ! "Die"
state.finished.await
Thread.sleep(1.second.dilated.toMillis)
actor.isTerminated must be(true)
actor.isTerminated should be(true)
system.stop(supervisor)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package akka.actor
import language.postfixOps

import org.scalatest.BeforeAndAfterEach
import org.scalatest.matchers.MustMatchers
import org.scalatest.Matchers

import akka.actor.Actor._
import akka.testkit._
Expand Down
164 changes: 82 additions & 82 deletions akka-actor-tests/src/test/scala/akka/actor/ActorLookupSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {
"An ActorSystem" must {

"find actors by looking up their path" in {
system.actorFor(c1.path) must be === c1
system.actorFor(c2.path) must be === c2
system.actorFor(c21.path) must be === c21
system.actorFor(system / "c1") must be === c1
system.actorFor(system / "c2") must be === c2
system.actorFor(system / "c2" / "c21") must be === c21
system.actorFor(system child "c2" child "c21") must be === c21 // test Java API
system.actorFor(system / Seq("c2", "c21")) must be === c21
system.actorFor(c1.path) should equal(c1)
system.actorFor(c2.path) should equal(c2)
system.actorFor(c21.path) should equal(c21)
system.actorFor(system / "c1") should equal(c1)
system.actorFor(system / "c2") should equal(c2)
system.actorFor(system / "c2" / "c21") should equal(c21)
system.actorFor(system child "c2" child "c21") should equal(c21) // test Java API
system.actorFor(system / Seq("c2", "c21")) should equal(c21)

import scala.collection.JavaConverters._
system.actorFor(system descendant Seq("c2", "c21").asJava) // test Java API
}

"find actors by looking up their string representation" in {
// this is only true for local actor references
system.actorFor(c1.path.toString) must be === c1
system.actorFor(c2.path.toString) must be === c2
system.actorFor(c21.path.toString) must be === c21
system.actorFor(c1.path.toString) should equal(c1)
system.actorFor(c2.path.toString) should equal(c2)
system.actorFor(c21.path.toString) should equal(c21)
}

"take actor incarnation into account when comparing actor references" in {
Expand All @@ -87,59 +87,59 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {
expectNoMsg(1 second)

// not equal because it's terminated
system.actorFor(a1.path.toString) must not be (a1)
system.actorFor(a1.path.toString) should not be (a1)

val a2 = system.actorOf(p, name)
a2.path must be(a1.path)
a2.path.toString must be(a1.path.toString)
a2 must not be (a1)
a2.toString must not be (a1.toString)
a2.path should be(a1.path)
a2.path.toString should be(a1.path.toString)
a2 should not be (a1)
a2.toString should not be (a1.toString)

watch(a2)
a2 ! PoisonPill
expectTerminated(a2)
}

"find actors by looking up their root-anchored relative path" in {
system.actorFor(c1.path.elements.mkString("/", "/", "")) must be === c1
system.actorFor(c2.path.elements.mkString("/", "/", "")) must be === c2
system.actorFor(c21.path.elements.mkString("/", "/", "")) must be === c21
system.actorFor(c1.path.elements.mkString("/", "/", "")) should equal(c1)
system.actorFor(c2.path.elements.mkString("/", "/", "")) should equal(c2)
system.actorFor(c21.path.elements.mkString("/", "/", "")) should equal(c21)
}

"find actors by looking up their relative path" in {
system.actorFor(c1.path.elements.mkString("/")) must be === c1
system.actorFor(c2.path.elements.mkString("/")) must be === c2
system.actorFor(c21.path.elements.mkString("/")) must be === c21
system.actorFor(c1.path.elements.mkString("/")) should equal(c1)
system.actorFor(c2.path.elements.mkString("/")) should equal(c2)
system.actorFor(c21.path.elements.mkString("/")) should equal(c21)
}

"find actors by looking up their path elements" in {
system.actorFor(c1.path.elements) must be === c1
system.actorFor(c2.path.elements) must be === c2
system.actorFor(c21.path.getElements) must be === c21 // test Java API
system.actorFor(c1.path.elements) should equal(c1)
system.actorFor(c2.path.elements) should equal(c2)
system.actorFor(c21.path.getElements) should equal(c21) // test Java API
}

"find system-generated actors" in {
system.actorFor("/user") must be === user
system.actorFor("/deadLetters") must be === system.deadLetters
system.actorFor("/system") must be === syst
system.actorFor(syst.path) must be === syst
system.actorFor(syst.path.toString) must be === syst
system.actorFor("/") must be === root
system.actorFor("..") must be === root
system.actorFor(root.path) must be === root
system.actorFor(root.path.toString) must be === root
system.actorFor("user") must be === user
system.actorFor("deadLetters") must be === system.deadLetters
system.actorFor("system") must be === syst
system.actorFor("user/") must be === user
system.actorFor("deadLetters/") must be === system.deadLetters
system.actorFor("system/") must be === syst
system.actorFor("/user") should equal(user)
system.actorFor("/deadLetters") should equal(system.deadLetters)
system.actorFor("/system") should equal(syst)
system.actorFor(syst.path) should equal(syst)
system.actorFor(syst.path.toString) should equal(syst)
system.actorFor("/") should equal(root)
system.actorFor("..") should equal(root)
system.actorFor(root.path) should equal(root)
system.actorFor(root.path.toString) should equal(root)
system.actorFor("user") should equal(user)
system.actorFor("deadLetters") should equal(system.deadLetters)
system.actorFor("system") should equal(syst)
system.actorFor("user/") should equal(user)
system.actorFor("deadLetters/") should equal(system.deadLetters)
system.actorFor("system/") should equal(syst)
}

"return deadLetters or EmptyLocalActorRef, respectively, for non-existing paths" in {
def check(lookup: ActorRef, result: ActorRef) = {
lookup.getClass must be === result.getClass
lookup must be === result
lookup.getClass should equal(result.getClass)
lookup should equal(result)
}
check(system.actorFor("a/b/c"), empty("a/b/c"))
check(system.actorFor(""), system.deadLetters)
Expand All @@ -153,17 +153,17 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {
"find temporary actors" in {
val f = c1 ? GetSender(testActor)
val a = expectMsgType[ActorRef]
a.path.elements.head must be === "temp"
system.actorFor(a.path) must be === a
system.actorFor(a.path.toString) must be === a
system.actorFor(a.path.elements) must be === a
system.actorFor(a.path.toString + "/") must be === a
system.actorFor(a.path.toString + "/hallo").isTerminated must be === true
f.isCompleted must be === false
a.isTerminated must be === false
a.path.elements.head should equal("temp")
system.actorFor(a.path) should equal(a)
system.actorFor(a.path.toString) should equal(a)
system.actorFor(a.path.elements) should equal(a)
system.actorFor(a.path.toString + "/") should equal(a)
system.actorFor(a.path.toString + "/hallo").isTerminated should equal(true)
f.isCompleted should equal(false)
a.isTerminated should equal(false)
a ! 42
f.isCompleted must be === true
Await.result(f, timeout.duration) must be === 42
f.isCompleted should equal(true)
Await.result(f, timeout.duration) should equal(42)
// clean-up is run as onComplete callback, i.e. dispatched on another thread
awaitCond(system.actorFor(a.path).isTerminated, 1 second)
}
Expand All @@ -176,7 +176,7 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {

"find actors by looking up their path" in {
def check(looker: ActorRef, pathOf: ActorRef, result: ActorRef) {
Await.result(looker ? LookupPath(pathOf.path), timeout.duration) must be === result
Await.result(looker ? LookupPath(pathOf.path), timeout.duration) should equal(result)
}
for {
looker all
Expand All @@ -186,11 +186,11 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {

"find actors by looking up their string representation" in {
def check(looker: ActorRef, pathOf: ActorRef, result: ActorRef) {
Await.result(looker ? LookupString(pathOf.path.toString), timeout.duration) must be === result
Await.result(looker ? LookupString(pathOf.path.toString), timeout.duration) should equal(result)
// with uid
Await.result(looker ? LookupString(pathOf.path.toSerializationFormat), timeout.duration) must be === result
Await.result(looker ? LookupString(pathOf.path.toSerializationFormat), timeout.duration) should equal(result)
// with trailing /
Await.result(looker ? LookupString(pathOf.path.toString + "/"), timeout.duration) must be === result
Await.result(looker ? LookupString(pathOf.path.toString + "/"), timeout.duration) should equal(result)
}
for {
looker all
Expand All @@ -200,8 +200,8 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {

"find actors by looking up their root-anchored relative path" in {
def check(looker: ActorRef, pathOf: ActorRef, result: ActorRef) {
Await.result(looker ? LookupString(pathOf.path.elements.mkString("/", "/", "")), timeout.duration) must be === result
Await.result(looker ? LookupString(pathOf.path.elements.mkString("/", "/", "/")), timeout.duration) must be === result
Await.result(looker ? LookupString(pathOf.path.elements.mkString("/", "/", "")), timeout.duration) should equal(result)
Await.result(looker ? LookupString(pathOf.path.elements.mkString("/", "/", "/")), timeout.duration) should equal(result)
}
for {
looker all
Expand All @@ -211,9 +211,9 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {

"find actors by looking up their relative path" in {
def check(looker: ActorRef, result: ActorRef, elems: String*) {
Await.result(looker ? LookupElems(elems), timeout.duration) must be === result
Await.result(looker ? LookupString(elems mkString "/"), timeout.duration) must be === result
Await.result(looker ? LookupString(elems mkString ("", "/", "/")), timeout.duration) must be === result
Await.result(looker ? LookupElems(elems), timeout.duration) should equal(result)
Await.result(looker ? LookupString(elems mkString "/"), timeout.duration) should equal(result)
Await.result(looker ? LookupString(elems mkString ("", "/", "/")), timeout.duration) should equal(result)
}
check(c1, user, "..")
for {
Expand All @@ -228,11 +228,11 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {
"find system-generated actors" in {
def check(target: ActorRef) {
for (looker all) {
Await.result(looker ? LookupPath(target.path), timeout.duration) must be === target
Await.result(looker ? LookupString(target.path.toString), timeout.duration) must be === target
Await.result(looker ? LookupString(target.path.toString + "/"), timeout.duration) must be === target
Await.result(looker ? LookupString(target.path.elements.mkString("/", "/", "")), timeout.duration) must be === target
if (target != root) Await.result(looker ? LookupString(target.path.elements.mkString("/", "/", "/")), timeout.duration) must be === target
Await.result(looker ? LookupPath(target.path), timeout.duration) should equal(target)
Await.result(looker ? LookupString(target.path.toString), timeout.duration) should equal(target)
Await.result(looker ? LookupString(target.path.toString + "/"), timeout.duration) should equal(target)
Await.result(looker ? LookupString(target.path.elements.mkString("/", "/", "")), timeout.duration) should equal(target)
if (target != root) Await.result(looker ? LookupString(target.path.elements.mkString("/", "/", "/")), timeout.duration) should equal(target)
}
}
for (target Seq(root, syst, user, system.deadLetters)) check(target)
Expand All @@ -243,8 +243,8 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {

def checkOne(looker: ActorRef, query: Query, result: ActorRef) {
val lookup = Await.result(looker ? query, timeout.duration)
lookup.getClass must be === result.getClass
lookup must be === result
lookup.getClass should equal(result.getClass)
lookup should equal(result)
}
def check(looker: ActorRef) {
val lookname = looker.path.elements.mkString("", "/", "/")
Expand All @@ -266,21 +266,21 @@ class ActorLookupSpec extends AkkaSpec with DefaultTimeout {
"find temporary actors" in {
val f = c1 ? GetSender(testActor)
val a = expectMsgType[ActorRef]
a.path.elements.head must be === "temp"
Await.result(c2 ? LookupPath(a.path), timeout.duration) must be === a
Await.result(c2 ? LookupString(a.path.toString), timeout.duration) must be === a
Await.result(c2 ? LookupString(a.path.elements.mkString("/", "/", "")), timeout.duration) must be === a
Await.result(c2 ? LookupString("../../" + a.path.elements.mkString("/")), timeout.duration) must be === a
Await.result(c2 ? LookupString(a.path.toString + "/"), timeout.duration) must be === a
Await.result(c2 ? LookupString(a.path.elements.mkString("/", "/", "") + "/"), timeout.duration) must be === a
Await.result(c2 ? LookupString("../../" + a.path.elements.mkString("/") + "/"), timeout.duration) must be === a
Await.result(c2 ? LookupElems(Seq("..", "..") ++ a.path.elements), timeout.duration) must be === a
Await.result(c2 ? LookupElems(Seq("..", "..") ++ a.path.elements :+ ""), timeout.duration) must be === a
f.isCompleted must be === false
a.isTerminated must be === false
a.path.elements.head should equal("temp")
Await.result(c2 ? LookupPath(a.path), timeout.duration) should equal(a)
Await.result(c2 ? LookupString(a.path.toString), timeout.duration) should equal(a)
Await.result(c2 ? LookupString(a.path.elements.mkString("/", "/", "")), timeout.duration) should equal(a)
Await.result(c2 ? LookupString("../../" + a.path.elements.mkString("/")), timeout.duration) should equal(a)
Await.result(c2 ? LookupString(a.path.toString + "/"), timeout.duration) should equal(a)
Await.result(c2 ? LookupString(a.path.elements.mkString("/", "/", "") + "/"), timeout.duration) should equal(a)
Await.result(c2 ? LookupString("../../" + a.path.elements.mkString("/") + "/"), timeout.duration) should equal(a)
Await.result(c2 ? LookupElems(Seq("..", "..") ++ a.path.elements), timeout.duration) should equal(a)
Await.result(c2 ? LookupElems(Seq("..", "..") ++ a.path.elements :+ ""), timeout.duration) should equal(a)
f.isCompleted should equal(false)
a.isTerminated should equal(false)
a ! 42
f.isCompleted must be === true
Await.result(f, timeout.duration) must be === 42
f.isCompleted should equal(true)
Await.result(f, timeout.duration) should equal(42)
// clean-up is run as onComplete callback, i.e. dispatched on another thread
awaitCond(Await.result(c2 ? LookupPath(a.path), timeout.duration).asInstanceOf[ActorRef].isTerminated, 1 second)
}
Expand Down
Loading

0 comments on commit 003609c

Please sign in to comment.