From 7dab9636e475a38510f03cab3a2c2c39bedff402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Endre=20S=C3=A1ndor=20Varga?= Date: Thu, 2 Oct 2014 17:02:57 +0200 Subject: [PATCH] =htc Add test case for bind failures --- .../test/scala/akka/http/ClientServerSpec.scala | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/akka-http-core/src/test/scala/akka/http/ClientServerSpec.scala b/akka-http-core/src/test/scala/akka/http/ClientServerSpec.scala index 11d2d98a74..174e105bea 100644 --- a/akka-http-core/src/test/scala/akka/http/ClientServerSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/ClientServerSpec.scala @@ -11,7 +11,7 @@ import scala.annotation.tailrec import scala.concurrent.Await import scala.concurrent.duration._ import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpec } -import akka.actor.ActorSystem +import akka.actor.{ Status, ActorSystem } import akka.io.IO import akka.testkit.TestProbe import akka.stream.FlowMaterializer @@ -56,6 +56,21 @@ class ClientServerSpec extends WordSpec with Matchers with BeforeAndAfterAll { // TODO: verify unbinding effect } + "report failure if bind fails" in { + val (hostname, port) = temporaryServerHostnameAndPort() + val commander = TestProbe() + commander.send(IO(Http), Http.Bind(hostname, port)) + val binding = commander.expectMsgType[Http.ServerBinding] + commander.send(IO(Http), Http.Bind(hostname, port)) + commander.expectMsgType[Status.Failure] + + // Clean up + val c = StreamTestKit.SubscriberProbe[Http.IncomingConnection]() + binding.connectionStream.subscribe(c) + val sub = c.expectSubscription() + sub.cancel() + } + "properly complete a simple request/response cycle" in new TestSetup { val (clientOut, clientIn) = openNewClientConnection[Symbol]() val (serverIn, serverOut) = acceptConnection()