aboutsummaryrefslogtreecommitdiff
path: root/tests/src/test/scala/com/softwaremill/sttp
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-07-28 16:30:26 +0200
committeradamw <adam@warski.org>2017-07-28 16:30:26 +0200
commit651af891813001c517c5c821b6b75fb13ca252b5 (patch)
tree6e20fefb08e3bc2bd81d06c2c94db1dd16385c0d /tests/src/test/scala/com/softwaremill/sttp
parentf2d19f4dbce7fcf1fd89a636fed177a16b3ca3c7 (diff)
downloadsttp-651af891813001c517c5c821b6b75fb13ca252b5.tar.gz
sttp-651af891813001c517c5c821b6b75fb13ca252b5.tar.bz2
sttp-651af891813001c517c5c821b6b75fb13ca252b5.zip
Closing handlers after tests
Diffstat (limited to 'tests/src/test/scala/com/softwaremill/sttp')
-rw-r--r--tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala9
-rw-r--r--tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala13
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()
+ }
}