From cc2cda8752ed49dba0b6519f5ff95d465d870065 Mon Sep 17 00:00:00 2001 From: Roland Date: Thu, 3 Jan 2013 19:53:22 +0100 Subject: [PATCH] add tests for parentChannel --- .../scala/akka/channels/ChannelSpec.scala | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/akka-macro-tests/src/test/scala/akka/channels/ChannelSpec.scala b/akka-macro-tests/src/test/scala/akka/channels/ChannelSpec.scala index a4adf79a31..e597edf754 100644 --- a/akka-macro-tests/src/test/scala/akka/channels/ChannelSpec.scala +++ b/akka-macro-tests/src/test/scala/akka/channels/ChannelSpec.scala @@ -92,7 +92,7 @@ class ChannelSpec extends AkkaSpec with ImplicitSender { expectMsg(C) lastSender must be(sender.actorRef) } - + "correctly dispatch to subchannels" in { val ref = ChannelExt(system).actorOf(new Tester) implicit val sender = ChannelExt(system).actorOf(new RecvC(testActor)) @@ -207,6 +207,30 @@ class ChannelSpec extends AkkaSpec with ImplicitSender { expectMsg(C) } + "have a working parentChannel" in { + val parent = ChannelExt(system).actorOf(new Channels[TNil, (A, Nothing) :+: TNil] { + createChild(new Channels[(A, Nothing) :+: TNil, TNil] { + parentChannel ! A + }) + channel[A] { (msg, snd) ⇒ testActor ! msg } + }) + expectMsg(A) + } + + "not permit sending wrong things to parents" in { + intercept[ToolBoxError] { + eval(""" + |import akka.channels._ + |import ChannelSpec._ + |new Channels[TNil, (A, Nothing) :+: TNil] { + | createChild(new Channels[(A, Nothing) :+: TNil, TNil] { + | parentChannel ! B + | }) + |} + """.stripMargin) + }.message must include("This ChannelRef does not support messages of type akka.channels.ChannelSpec.B.type") + } + } } \ No newline at end of file