diff options
author | adamw <adam@warski.org> | 2017-09-14 11:03:21 +0100 |
---|---|---|
committer | adamw <adam@warski.org> | 2017-09-14 11:03:21 +0100 |
commit | fbc71ee712635ed64c50ca694735a84ec794eb11 (patch) | |
tree | bf1dd7335306b7f320262d45d0d5b6d02f5a0b27 /tests/src/test/scala | |
parent | a971d409cb1063a2089d936abf3d3ab70bbbabb6 (diff) | |
download | sttp-fbc71ee712635ed64c50ca694735a84ec794eb11.tar.gz sttp-fbc71ee712635ed64c50ca694735a84ec794eb11.tar.bz2 sttp-fbc71ee712635ed64c50ca694735a84ec794eb11.zip |
Renaming "handler" to "backend"
Diffstat (limited to 'tests/src/test/scala')
10 files changed, 56 insertions, 56 deletions
diff --git a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala index f544750..de033df 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/BasicTests.scala @@ -14,13 +14,13 @@ import akka.http.scaladsl.server.Route import akka.http.scaladsl.server.directives.Credentials import akka.util.ByteString import better.files._ -import com.softwaremill.sttp.akkahttp.AkkaHttpHandler -import com.softwaremill.sttp.asynchttpclient.cats.AsyncHttpClientCatsHandler -import com.softwaremill.sttp.asynchttpclient.future.AsyncHttpClientFutureHandler -import com.softwaremill.sttp.asynchttpclient.monix.AsyncHttpClientMonixHandler -import com.softwaremill.sttp.asynchttpclient.scalaz.AsyncHttpClientScalazHandler -import com.softwaremill.sttp.okhttp.monix.OkHttpMonixHandler -import com.softwaremill.sttp.okhttp.{OkHttpFutureHandler, OkHttpSyncHandler} +import com.softwaremill.sttp.akkahttp.AkkaHttpBackend +import com.softwaremill.sttp.asynchttpclient.cats.AsyncHttpClientCatsBackend +import com.softwaremill.sttp.asynchttpclient.future.AsyncHttpClientFutureBackend +import com.softwaremill.sttp.asynchttpclient.monix.AsyncHttpClientMonixBackend +import com.softwaremill.sttp.asynchttpclient.scalaz.AsyncHttpClientScalazBackend +import com.softwaremill.sttp.okhttp.monix.OkHttpMonixBackend +import com.softwaremill.sttp.okhttp.{OkHttpFutureBackend, OkHttpSyncBackend} import com.typesafe.scalalogging.StrictLogging import org.scalatest.concurrent.{IntegrationPatience, ScalaFutures} import org.scalatest.{path => _, _} @@ -174,32 +174,32 @@ class BasicTests override def port = 51823 - var closeHandlers: List[() => Unit] = Nil + var closeBackends: List[() => Unit] = Nil - runTests("HttpURLConnection")(HttpURLConnectionHandler(), + runTests("HttpURLConnection")(HttpURLConnectionBackend(), ForceWrappedValue.id) - runTests("Akka HTTP")(AkkaHttpHandler.usingActorSystem(actorSystem), + runTests("Akka HTTP")(AkkaHttpBackend.usingActorSystem(actorSystem), ForceWrappedValue.future) - runTests("Async Http Client - Future")(AsyncHttpClientFutureHandler(), + runTests("Async Http Client - Future")(AsyncHttpClientFutureBackend(), ForceWrappedValue.future) - runTests("Async Http Client - Scalaz")(AsyncHttpClientScalazHandler(), + runTests("Async Http Client - Scalaz")(AsyncHttpClientScalazBackend(), ForceWrappedValue.scalazTask) - runTests("Async Http Client - Monix")(AsyncHttpClientMonixHandler(), + runTests("Async Http Client - Monix")(AsyncHttpClientMonixBackend(), ForceWrappedValue.monixTask) runTests("Async Http Client - Cats Effect")( - AsyncHttpClientCatsHandler[cats.effect.IO](), + AsyncHttpClientCatsBackend[cats.effect.IO](), ForceWrappedValue.catsIo) - runTests("OkHttpSyncClientHandler")(OkHttpSyncHandler(), ForceWrappedValue.id) - runTests("OkHttpAsyncClientHandler - Future")(OkHttpFutureHandler(), + runTests("OkHttpSyncClientHandler")(OkHttpSyncBackend(), ForceWrappedValue.id) + runTests("OkHttpAsyncClientHandler - Future")(OkHttpFutureBackend(), ForceWrappedValue.future) - runTests("OkHttpAsyncClientHandler - Monix")(OkHttpMonixHandler(), + runTests("OkHttpAsyncClientHandler - Monix")(OkHttpMonixBackend(), ForceWrappedValue.monixTask) def runTests[R[_]](name: String)( - implicit handler: SttpHandler[R, Nothing], + implicit backend: SttpBackend[R, Nothing], forceResponse: ForceWrappedValue[R]): Unit = { - closeHandlers = handler.close _ :: closeHandlers + closeBackends = backend.close _ :: closeBackends val postEcho = sttp.post(uri"$endpoint/echo") val testBody = "this is the body" @@ -639,7 +639,7 @@ class BasicTests name should "break redirect loops" in { val resp = loop.send().force() resp.code should be(0) - resp.history should have size (FollowRedirectsHandler.MaxRedirects) + resp.history should have size (FollowRedirectsBackend.MaxRedirects) } } @@ -667,7 +667,7 @@ class BasicTests } override protected def afterAll(): Unit = { - closeHandlers.foreach(_()) + closeBackends.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 53ea798..66d040c 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala @@ -5,27 +5,27 @@ import org.scalatest.{FlatSpec, Matchers} import scala.tools.reflect.ToolBoxError class IllTypedTests extends FlatSpec with Matchers { - "compilation" should "fail when trying to stream using the default handler" in { + "compilation" should "fail when trying to stream using the default backend" in { val thrown = intercept[ToolBoxError] { EvalScala( """ import com.softwaremill.sttp._ import akka.stream.scaladsl.Source import akka.util.ByteString - implicit val sttpHandler = HttpURLConnectionHandler + implicit val sttpBackend = HttpURLConnectionBackend() sttp.get(uri"http://example.com").response(asStream[Source[ByteString, Any]]).send() """) } thrown.getMessage should include( - "could not find implicit value for parameter handler: com.softwaremill.sttp.SttpHandler[R,akka.stream.scaladsl.Source[akka.util.ByteString,Any]]") + "could not find implicit value for parameter backend: com.softwaremill.sttp.SttpBackend[R,akka.stream.scaladsl.Source[akka.util.ByteString,Any]]") } "compilation" should "fail when trying to send a request without giving an URL" in { val thrown = intercept[ToolBoxError] { EvalScala(""" import com.softwaremill.sttp._ - implicit val sttpHandler = HttpURLConnectionHandler() + implicit val sttpBackend = HttpURLConnectionBackend() 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 1f6b78c..018c3ab 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala @@ -31,7 +31,7 @@ class StreamingTests val body = "streaming test" - var closeHandlers: List[() => Unit] = Nil + var closeBackends: List[() => Unit] = Nil runTests("Akka Http", new AkkaHttpStreamingTests(actorSystem)) runTests("Monix Async Http Client", new AsyncHttpClientMonixStreamingTests) @@ -40,10 +40,10 @@ class StreamingTests def runTests[R[_], S]( name: String, - testStreamingHandler: TestStreamingHandler[R, S]): Unit = { - import testStreamingHandler._ + testStreamingBackend: TestStreamingBackend[R, S]): Unit = { + import testStreamingBackend._ - closeHandlers = handler.close _ :: closeHandlers + closeBackends = backend.close _ :: closeBackends name should "stream request body" in { val response = sttp @@ -81,7 +81,7 @@ class StreamingTests } override protected def afterAll(): Unit = { - closeHandlers.foreach(_()) + closeBackends.foreach(_()) super.afterAll() } diff --git a/tests/src/test/scala/com/softwaremill/sttp/streaming/AkkaHttpStreamingTests.scala b/tests/src/test/scala/com/softwaremill/sttp/streaming/AkkaHttpStreamingTests.scala index 25a8d6e..3fca682 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/streaming/AkkaHttpStreamingTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/streaming/AkkaHttpStreamingTests.scala @@ -5,17 +5,17 @@ import akka.actor.ActorSystem import akka.stream.Materializer import akka.stream.scaladsl.Source import akka.util.ByteString -import com.softwaremill.sttp.akkahttp.AkkaHttpHandler -import com.softwaremill.sttp.{ForceWrappedValue, SttpHandler} +import com.softwaremill.sttp.akkahttp.AkkaHttpBackend +import com.softwaremill.sttp.{ForceWrappedValue, SttpBackend} import scala.concurrent.Future class AkkaHttpStreamingTests(actorSystem: ActorSystem)( implicit materializer: Materializer) - extends TestStreamingHandler[Future, Source[ByteString, Any]] { + extends TestStreamingBackend[Future, Source[ByteString, Any]] { - override implicit val handler: SttpHandler[Future, Source[ByteString, Any]] = - AkkaHttpHandler.usingActorSystem(actorSystem) + override implicit val backend: SttpBackend[Future, Source[ByteString, Any]] = + AkkaHttpBackend.usingActorSystem(actorSystem) override implicit val forceResponse: ForceWrappedValue[Future] = ForceWrappedValue.future diff --git a/tests/src/test/scala/com/softwaremill/sttp/streaming/AsyncHttpClientFs2StreamingTests.scala b/tests/src/test/scala/com/softwaremill/sttp/streaming/AsyncHttpClientFs2StreamingTests.scala index b55d104..735a5c3 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/streaming/AsyncHttpClientFs2StreamingTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/streaming/AsyncHttpClientFs2StreamingTests.scala @@ -4,15 +4,15 @@ import java.nio.ByteBuffer import cats.effect._ import cats.implicits._ -import com.softwaremill.sttp.asynchttpclient.fs2.AsyncHttpClientFs2Handler -import com.softwaremill.sttp.{ForceWrappedValue, SttpHandler} +import com.softwaremill.sttp.asynchttpclient.fs2.AsyncHttpClientFs2Backend +import com.softwaremill.sttp.{ForceWrappedValue, SttpBackend} import fs2._ class AsyncHttpClientFs2StreamingTests - extends TestStreamingHandler[IO, Stream[IO, ByteBuffer]] { + extends TestStreamingBackend[IO, Stream[IO, ByteBuffer]] { - override implicit val handler: SttpHandler[IO, Stream[IO, ByteBuffer]] = - AsyncHttpClientFs2Handler[IO]() + override implicit val backend: SttpBackend[IO, Stream[IO, ByteBuffer]] = + AsyncHttpClientFs2Backend[IO]() override implicit val forceResponse: ForceWrappedValue[IO] = ForceWrappedValue.catsIo diff --git a/tests/src/test/scala/com/softwaremill/sttp/streaming/AsyncHttpClientMonixStreamingTests.scala b/tests/src/test/scala/com/softwaremill/sttp/streaming/AsyncHttpClientMonixStreamingTests.scala index a76aa26..0357668 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/streaming/AsyncHttpClientMonixStreamingTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/streaming/AsyncHttpClientMonixStreamingTests.scala @@ -2,16 +2,16 @@ package com.softwaremill.sttp.streaming import java.nio.ByteBuffer -import com.softwaremill.sttp.SttpHandler -import com.softwaremill.sttp.asynchttpclient.monix.AsyncHttpClientMonixHandler +import com.softwaremill.sttp.SttpBackend +import com.softwaremill.sttp.asynchttpclient.monix.AsyncHttpClientMonixBackend import monix.eval.Task import monix.reactive.Observable -class AsyncHttpClientMonixStreamingTests extends MonixBaseHandler { +class AsyncHttpClientMonixStreamingTests extends MonixBaseBackend { import monix.execution.Scheduler.Implicits.global - override implicit val handler: SttpHandler[Task, Observable[ByteBuffer]] = - AsyncHttpClientMonixHandler() + override implicit val backend: SttpBackend[Task, Observable[ByteBuffer]] = + AsyncHttpClientMonixBackend() } diff --git a/tests/src/test/scala/com/softwaremill/sttp/streaming/MonixBaseHandler.scala b/tests/src/test/scala/com/softwaremill/sttp/streaming/MonixBaseBackend.scala index b34a4ae..3510fbc 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/streaming/MonixBaseHandler.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/streaming/MonixBaseBackend.scala @@ -6,8 +6,8 @@ import com.softwaremill.sttp.ForceWrappedValue import monix.eval.Task import monix.reactive.Observable -trait MonixBaseHandler - extends TestStreamingHandler[Task, Observable[ByteBuffer]] { +trait MonixBaseBackend + extends TestStreamingBackend[Task, Observable[ByteBuffer]] { override implicit def forceResponse: ForceWrappedValue[Task] = ForceWrappedValue.monixTask diff --git a/tests/src/test/scala/com/softwaremill/sttp/streaming/OkHttpMonixStreamingTests.scala b/tests/src/test/scala/com/softwaremill/sttp/streaming/OkHttpMonixStreamingTests.scala index 2ea1322..9bfcc26 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/streaming/OkHttpMonixStreamingTests.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/streaming/OkHttpMonixStreamingTests.scala @@ -2,16 +2,16 @@ package com.softwaremill.sttp.streaming import java.nio.ByteBuffer -import com.softwaremill.sttp.SttpHandler -import com.softwaremill.sttp.okhttp.monix.OkHttpMonixHandler +import com.softwaremill.sttp.SttpBackend +import com.softwaremill.sttp.okhttp.monix.OkHttpMonixBackend import monix.eval.Task import monix.reactive.Observable -class OkHttpMonixStreamingTests extends MonixBaseHandler { +class OkHttpMonixStreamingTests extends MonixBaseBackend { import monix.execution.Scheduler.Implicits.global - override implicit val handler: SttpHandler[Task, Observable[ByteBuffer]] = - OkHttpMonixHandler() + override implicit val backend: SttpBackend[Task, Observable[ByteBuffer]] = + OkHttpMonixBackend() } diff --git a/tests/src/test/scala/com/softwaremill/sttp/streaming/TestStreamingHandler.scala b/tests/src/test/scala/com/softwaremill/sttp/streaming/TestStreamingBackend.scala index b786e49..5fc1c57 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/streaming/TestStreamingHandler.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/streaming/TestStreamingBackend.scala @@ -1,11 +1,11 @@ package com.softwaremill.sttp.streaming -import com.softwaremill.sttp.{ForceWrappedValue, SttpHandler} +import com.softwaremill.sttp.{ForceWrappedValue, SttpBackend} import scala.language.higherKinds -trait TestStreamingHandler[R[_], S] { - implicit def handler: SttpHandler[R, S] +trait TestStreamingBackend[R[_], S] { + implicit def backend: SttpBackend[R, S] implicit def forceResponse: ForceWrappedValue[R] diff --git a/tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala b/tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala index 7e4d5a9..4eea904 100644 --- a/tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala +++ b/tests/src/test/scala/com/softwaremill/sttp/testHelpers.scala @@ -73,7 +73,7 @@ object ForceWrappedValue extends ScalaFutures with TestingPatience { try { wrapped.runAsync.futureValue } catch { - case e: TestFailedException => throw e.getCause + case e: TestFailedException if e.getCause != null => throw e.getCause } } val catsIo = new ForceWrappedValue[cats.effect.IO] { |