diff options
Diffstat (limited to 'tests')
3 files changed, 22 insertions, 7 deletions
diff --git a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala index 45f6430..5f17a7a 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala @@ -104,8 +104,7 @@ class BasicTests } } ~ path("secure_basic") { authenticateBasic("test realm", { - case c @ Credentials.Provided(un) - if un == "adam" && c.verify("1234") => + case c @ Credentials.Provided(un) if un == "adam" && c.verify("1234") => Some(un) case _ => None }) { userName => @@ -119,6 +118,8 @@ class BasicTests override def port = 51823 + var closeHandlers: List[() => Unit] = Nil + runTests("HttpURLConnection")(HttpURLConnectionSttpHandler, ForceWrappedValue.id) runTests("Akka HTTP")(AkkaHttpSttpHandler.usingActorSystem(actorSystem), @@ -138,6 +139,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") @@ -396,4 +399,9 @@ class BasicTests } } } + + override protected def afterAll(): Unit = { + closeHandlers.foreach(_()) + super.afterAll() + } } diff --git a/tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala b/tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala index 057ba9e..6137ed2 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala @@ -12,9 +12,8 @@ class IllTypedTests extends FlatSpec with Matchers { import com.softwaremill.sttp._ import akka.stream.scaladsl.Source import akka.util.ByteString - import java.net.URI implicit val sttpHandler = HttpURLConnectionSttpHandler - sttp.get(new URI("http://example.com")).response(asStream[Source[ByteString, Any]]).send() + sttp.get(uri"http://example.com").response(asStream[Source[ByteString, Any]]).send() """) } @@ -26,7 +25,6 @@ class IllTypedTests extends FlatSpec with Matchers { val thrown = intercept[ToolBoxError] { EvalScala(""" import com.softwaremill.sttp._ - import java.net.URI implicit val sttpHandler = HttpURLConnectionSttpHandler sttp.send() """) 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() + } } |