diff options
-rw-r--r-- | tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala | 9 | ||||
-rw-r--r-- | tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala | 13 |
2 files changed, 20 insertions, 2 deletions
diff --git a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala index 262fd35..90aab02 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala @@ -114,6 +114,8 @@ class BasicTests override def port = 51823 + var closeHandlers: List[() => Unit] = Nil + runTests("HttpURLConnection")(HttpURLConnectionSttpHandler, ForceWrappedValue.id) runTests("Akka HTTP")(AkkaHttpSttpHandler.usingActorSystem(actorSystem), @@ -129,6 +131,8 @@ class BasicTests implicit handler: SttpHandler[R, Nothing], forceResponse: ForceWrappedValue[R]): Unit = { + closeHandlers = handler.close _ :: closeHandlers + val postEcho = sttp.post(uri"$endpoint/echo") val testBody = "this is the body" val testBodyBytes = testBody.getBytes("UTF-8") @@ -387,4 +391,9 @@ class BasicTests } } } + + override protected def afterAll(): Unit = { + closeHandlers.foreach(_()) + super.afterAll() + } } diff --git a/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala b/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala index 7bc842c..5f04126 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala @@ -35,13 +35,16 @@ class StreamingTests override def port = 51824 + val akkaHandler = AkkaHttpSttpHandler.usingActorSystem(actorSystem) + val monixHandler = MonixAsyncHttpClientHandler() + akkaStreamingTests() monixStreamingTests() val body = "streaming test" def akkaStreamingTests(): Unit = { - implicit val handler = AkkaHttpSttpHandler.usingActorSystem(actorSystem) + implicit val handler = akkaHandler "Akka HTTP" should "stream request body" in { val response = sttp @@ -68,7 +71,7 @@ class StreamingTests } def monixStreamingTests(): Unit = { - implicit val handler = MonixAsyncHttpClientHandler() + implicit val handler = monixHandler import monix.execution.Scheduler.Implicits.global val body = "streaming test" @@ -127,4 +130,10 @@ class StreamingTests new String(bytes, "utf-8") should include("</div>") } } + + override protected def afterAll(): Unit = { + akkaHandler.close() + monixHandler.close() + super.afterAll() + } } |