From 5935e2e2b7887b13f98b2c5a2761cee3d874996b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Antonsson?= Date: Fri, 13 Dec 2013 12:16:25 +0100 Subject: [PATCH] =doc #3782 Make IODocSpec say what went wrong --- .../rst/scala/code/docs/io/IODocSpec.scala | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/akka-docs/rst/scala/code/docs/io/IODocSpec.scala b/akka-docs/rst/scala/code/docs/io/IODocSpec.scala index 2f5a81398c..b115903a7e 100644 --- a/akka-docs/rst/scala/code/docs/io/IODocSpec.scala +++ b/akka-docs/rst/scala/code/docs/io/IODocSpec.scala @@ -78,7 +78,7 @@ class Client(remote: InetSocketAddress, listener: ActorRef) extends Actor { def receive = { case CommandFailed(_: Connect) => - listener ! "failed" + listener ! "connect failed" context stop self case c @ Connected(remote, local) => @@ -86,11 +86,18 @@ class Client(remote: InetSocketAddress, listener: ActorRef) extends Actor { val connection = sender connection ! Register(self) context become { - case data: ByteString => connection ! Write(data) - case CommandFailed(w: Write) => // O/S buffer was full - case Received(data) => listener ! data - case "close" => connection ! Close - case _: ConnectionClosed => context stop self + case data: ByteString => + connection ! Write(data) + case CommandFailed(w: Write) => + // O/S buffer was full + listener ! "write failed" + case Received(data) => + listener ! data + case "close" => + connection ! Close + case _: ConnectionClosed => + listener ! "connection closed" + context stop self } } } @@ -110,6 +117,8 @@ class IODocSpec extends AkkaSpec { val listen = expectMsgType[Tcp.Bound].localAddress val client = system.actorOf(Client.props(listen, testActor), "client1") + watch(client) + val c1, c2 = expectMsgType[Tcp.Connected] c1.localAddress must be(c2.remoteAddress) c2.localAddress must be(c1.remoteAddress) @@ -117,8 +126,8 @@ class IODocSpec extends AkkaSpec { client ! ByteString("hello") expectMsgType[ByteString].utf8String must be("hello") - watch(client) client ! "close" + expectMsg("connection closed") expectTerminated(client, 1.second) }