diff options
author | Omar Alejandro Mainegra Sarduy <omainegra@gmail.com> | 2017-07-28 16:37:05 -0400 |
---|---|---|
committer | Omar Alejandro Mainegra Sarduy <omainegra@gmail.com> | 2017-07-28 16:37:05 -0400 |
commit | 1f9d0e2c111dc98ec23154b9b54c3693fedac834 (patch) | |
tree | 831298610fc51ceb4e99e3de67aa54fd4600661b /tests | |
parent | 75916ed78304a8b0c226c5ecd26634b541334f67 (diff) | |
parent | 4d23d6fd21317e6bf28cd23b0e149d570b55f5e8 (diff) | |
download | sttp-1f9d0e2c111dc98ec23154b9b54c3693fedac834.tar.gz sttp-1f9d0e2c111dc98ec23154b9b54c3693fedac834.tar.bz2 sttp-1f9d0e2c111dc98ec23154b9b54c3693fedac834.zip |
Merge branch 'master' into okhttp3
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() + } } |