aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Guymer <sam@guymer.me>2018-05-20 21:02:37 +1000
committerSam Guymer <sam@guymer.me>2018-05-20 21:02:37 +1000
commitbcb94e252a96c78b1db29aebe47b18bfd337e764 (patch)
tree7462765d4dfcb2eda9a21591aba1bcfc51352b9f
parent92e10991df0d168d1972d4618fcc7e02e2e0a0fa (diff)
downloadsttp-bcb94e252a96c78b1db29aebe47b18bfd337e764.tar.gz
sttp-bcb94e252a96c78b1db29aebe47b18bfd337e764.tar.bz2
sttp-bcb94e252a96c78b1db29aebe47b18bfd337e764.zip
Code review updates
Remove tests sub project, all tests are now in core. Remove TestStreamingBackend, StreamingTest now has the required abstract methods.
-rw-r--r--akka-http-backend/src/test/scala/com/softwaremill/sttp/akkahttp/AkkaHttpStreamingTest.scala (renamed from akka-http-backend/src/test/scala/com/softwaremill/sttp/akkahttp/AkkaHttpStreamingTests.scala)14
-rw-r--r--async-http-client-backend/fs2/src/test/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2HttpStreamingTest.scala11
-rw-r--r--async-http-client-backend/monix/src/test/scala/com/softwaremill/sttp/asynchttpclient/monix/AsyncHttpClientMonixStreamingTest.scala19
-rw-r--r--build.sbt37
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/MonadError.scala9
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/HttpURLConnectionHttpTest.scala (renamed from tests/src/test/scala/com/softwaremill/sttp/HttpURLConnectionHttpTest.scala)3
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala (renamed from tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala)11
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/TryHttpURLConnectionHttpTest.scala (renamed from tests/src/test/scala/com/softwaremill/sttp/TryHttpURLConnectionHttpTest.scala)5
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/testing/EvalScala.scala (renamed from tests/src/test/scala/com/softwaremill/sttp/EvalScala.scala)2
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/testing/streaming/StreamingTest.scala14
-rw-r--r--core/src/test/scala/com/softwaremill/sttp/testing/streaming/TestStreamingBackend.scala16
-rw-r--r--docs/backends/custom.rst29
-rw-r--r--implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala26
-rw-r--r--implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixTestStreamingBackend.scala28
-rw-r--r--okhttp-backend/monix/src/test/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixStreamingTest.scala19
-rw-r--r--tests/src/test/resources/binaryfile.jpgbin42010 -> 0 bytes
-rw-r--r--tests/src/test/resources/logback.xml12
-rw-r--r--tests/src/test/resources/textfile.txt100
18 files changed, 90 insertions, 265 deletions
diff --git a/akka-http-backend/src/test/scala/com/softwaremill/sttp/akkahttp/AkkaHttpStreamingTests.scala b/akka-http-backend/src/test/scala/com/softwaremill/sttp/akkahttp/AkkaHttpStreamingTest.scala
index e8ab9d7..494ecd2 100644
--- a/akka-http-backend/src/test/scala/com/softwaremill/sttp/akkahttp/AkkaHttpStreamingTests.scala
+++ b/akka-http-backend/src/test/scala/com/softwaremill/sttp/akkahttp/AkkaHttpStreamingTest.scala
@@ -2,12 +2,12 @@ package com.softwaremill.sttp.akkahttp
import akka.NotUsed
import akka.actor.ActorSystem
-import akka.stream.{ActorMaterializer, Materializer}
+import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import akka.util.ByteString
import com.softwaremill.sttp.SttpBackend
import com.softwaremill.sttp.testing.ConvertToFuture
-import com.softwaremill.sttp.testing.streaming.{StreamingTest, TestStreamingBackend}
+import com.softwaremill.sttp.testing.streaming.StreamingTest
import scala.concurrent.Future
@@ -16,15 +16,6 @@ class AkkaHttpStreamingTest extends StreamingTest[Future, Source[ByteString, Any
private implicit val actorSystem: ActorSystem = ActorSystem("sttp-test")
private implicit val materializer: ActorMaterializer = ActorMaterializer()
- override val testStreamingBackend: TestStreamingBackend[Future, Source[ByteString, Any]] =
- new AkkaHttpTestStreamingBackend(actorSystem)
-}
-
-class AkkaHttpTestStreamingBackend(
- actorSystem: ActorSystem
-)(implicit materializer: Materializer)
- extends TestStreamingBackend[Future, Source[ByteString, Any]] {
-
override implicit val backend: SttpBackend[Future, Source[ByteString, Any]] =
AkkaHttpBackend.usingActorSystem(actorSystem)
@@ -36,5 +27,4 @@ class AkkaHttpTestStreamingBackend(
override def bodyConsumer(stream: Source[ByteString, Any]): Future[String] =
stream.map(_.utf8String).runReduce(_ + _)
-
}
diff --git a/async-http-client-backend/fs2/src/test/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2HttpStreamingTest.scala b/async-http-client-backend/fs2/src/test/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2HttpStreamingTest.scala
index 565db5c..56bb18b 100644
--- a/async-http-client-backend/fs2/src/test/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2HttpStreamingTest.scala
+++ b/async-http-client-backend/fs2/src/test/scala/com/softwaremill/sttp/asynchttpclient/fs2/AsyncHttpClientFs2HttpStreamingTest.scala
@@ -5,21 +5,14 @@ import java.nio.ByteBuffer
import cats.effect.IO
import cats.instances.string._
import com.softwaremill.sttp.SttpBackend
-import com.softwaremill.sttp.testing.streaming.{StreamingTest, TestStreamingBackend}
+import com.softwaremill.sttp.testing.streaming.StreamingTest
import com.softwaremill.sttp.testing.ConvertToFuture
import fs2.{Chunk, Stream, text}
import scala.concurrent.Future
class AsyncHttpClientFs2HttpStreamingTest extends StreamingTest[IO, Stream[IO, ByteBuffer]] {
- override val testStreamingBackend: TestStreamingBackend[IO, Stream[IO, ByteBuffer]] =
- new AsyncHttpClientFs2TestStreamingBackend
-}
-
-class AsyncHttpClientFs2TestStreamingBackend extends TestStreamingBackend[IO, Stream[IO, ByteBuffer]] {
-
- override implicit val backend: SttpBackend[IO, Stream[IO, ByteBuffer]] =
- AsyncHttpClientFs2Backend[IO]()
+ override implicit val backend: SttpBackend[IO, Stream[IO, ByteBuffer]] = AsyncHttpClientFs2Backend[IO]()
override implicit val convertToFuture: ConvertToFuture[IO] =
new ConvertToFuture[IO] {
diff --git a/async-http-client-backend/monix/src/test/scala/com/softwaremill/sttp/asynchttpclient/monix/AsyncHttpClientMonixStreamingTest.scala b/async-http-client-backend/monix/src/test/scala/com/softwaremill/sttp/asynchttpclient/monix/AsyncHttpClientMonixStreamingTest.scala
index 34c15ff..8e93074 100644
--- a/async-http-client-backend/monix/src/test/scala/com/softwaremill/sttp/asynchttpclient/monix/AsyncHttpClientMonixStreamingTest.scala
+++ b/async-http-client-backend/monix/src/test/scala/com/softwaremill/sttp/asynchttpclient/monix/AsyncHttpClientMonixStreamingTest.scala
@@ -3,24 +3,11 @@ package com.softwaremill.sttp.asynchttpclient.monix
import java.nio.ByteBuffer
import com.softwaremill.sttp.SttpBackend
-import com.softwaremill.sttp.impl.monix.MonixTestStreamingBackend
-import com.softwaremill.sttp.testing.streaming.{StreamingTest, TestStreamingBackend}
+import com.softwaremill.sttp.impl.monix.MonixStreamingTest
import monix.eval.Task
import monix.reactive.Observable
-class AsyncHttpClientMonixStreamingTest extends StreamingTest[Task, Observable[ByteBuffer]] {
+class AsyncHttpClientMonixStreamingTest extends MonixStreamingTest {
- override val testStreamingBackend: TestStreamingBackend[Task, Observable[ByteBuffer]] =
- new AsyncHttpClientMonixTestStreamingBackend
-}
-
-class AsyncHttpClientMonixTestStreamingBackend extends MonixTestStreamingBackend[ByteBuffer] {
-
- import monix.execution.Scheduler.Implicits.global
-
- override def toByteArray(v: ByteBuffer): Array[Byte] = v.array()
- override def fromByteArray(v: Array[Byte]): ByteBuffer = ByteBuffer.wrap(v)
-
- override implicit val backend: SttpBackend[Task, Observable[ByteBuffer]] =
- AsyncHttpClientMonixBackend()
+ override implicit val backend: SttpBackend[Task, Observable[ByteBuffer]] = AsyncHttpClientMonixBackend()
}
diff --git a/build.sbt b/build.sbt
index 461a88e..6bcaf1a 100644
--- a/build.sbt
+++ b/build.sbt
@@ -58,16 +58,17 @@ lazy val rootProject = (project in file("."))
json4s,
braveBackend,
prometheusBackend,
- tests,
testServer
)
lazy val core: Project = (project in file("core"))
.settings(commonSettings: _*)
+ .settings(testServerSettings: _*)
.settings(
name := "core",
libraryDependencies ++= Seq(
"com.github.pathikrit" %% "better-files" % "3.4.0" % "test",
+ "org.scala-lang" % "scala-compiler" % scalaVersion.value % "test",
scalaTest % "test"
),
publishArtifact in Test := true // allow implementations outside of this repo
@@ -78,6 +79,7 @@ lazy val cats: Project = (project in file("implementations/cats"))
.settings(commonSettings: _*)
.settings(
name := "cats",
+ publishArtifact in Test := true,
libraryDependencies ++= Seq("org.typelevel" %% "cats-effect" % "1.0.0-RC")
)
.dependsOn(core % "compile->compile;test->test")
@@ -86,6 +88,7 @@ lazy val monix: Project = (project in file("implementations/monix"))
.settings(commonSettings: _*)
.settings(
name := "monix",
+ publishArtifact in Test := true,
libraryDependencies ++= Seq("io.monix" %% "monix" % "3.0.0-RC1")
)
.dependsOn(core % "compile->compile;test->test")
@@ -94,6 +97,7 @@ lazy val scalaz: Project = (project in file("implementations/scalaz"))
.settings(commonSettings: _*)
.settings(
name := "scalaz",
+ publishArtifact in Test := true,
libraryDependencies ++= Seq("org.scalaz" %% "scalaz-concurrent" % "7.2.22")
)
.dependsOn(core % "compile->compile;test->test")
@@ -235,36 +239,6 @@ lazy val prometheusBackend: Project = (project in file("metrics/prometheus-backe
)
.dependsOn(core)
-lazy val tests: Project = (project in file("tests"))
- .settings(commonSettings: _*)
- .settings(testServerSettings: _*)
- .settings(
- skip in publish := true,
- name := "tests",
- libraryDependencies ++= Seq(
- akkaHttp,
- akkaStreams,
- scalaTest,
- "com.typesafe.scala-logging" %% "scala-logging" % "3.9.0",
- "com.github.pathikrit" %% "better-files" % "3.4.0",
- "ch.qos.logback" % "logback-classic" % "1.2.3",
- "org.scala-lang" % "scala-compiler" % scalaVersion.value
- ).map(_ % "test")
- )
- .dependsOn(
- core % "compile->compile;test->test",
- cats % "compile->compile;test->test",
- monix % "compile->compile;test->test",
- scalaz % "compile->compile;test->test",
- akkaHttpBackend,
- asyncHttpClientFutureBackend,
- asyncHttpClientScalazBackend,
- asyncHttpClientMonixBackend,
- asyncHttpClientCatsBackend,
- asyncHttpClientFs2Backend,
- okhttpMonixBackend
- )
-
// https://stackoverflow.com/questions/25766797/how-do-i-start-a-server-before-running-a-test-suite-in-sbt
lazy val testServer: Project = project
.in(file("test-server"))
@@ -278,7 +252,6 @@ lazy val testServer: Project = project
startTestServer := (reStart in Test).toTask("").value
)
-// maybe use IntegrationTest instead of Test?
lazy val testServerSettings = Seq(
test in Test := (test in Test).dependsOn(startTestServer in testServer).value,
testOnly in Test := (testOnly in Test).dependsOn(startTestServer in testServer).evaluated,
diff --git a/core/src/main/scala/com/softwaremill/sttp/MonadError.scala b/core/src/main/scala/com/softwaremill/sttp/MonadError.scala
index b5b1852..a783765 100644
--- a/core/src/main/scala/com/softwaremill/sttp/MonadError.scala
+++ b/core/src/main/scala/com/softwaremill/sttp/MonadError.scala
@@ -31,15 +31,6 @@ trait MonadAsyncError[R[_]] extends MonadError[R] {
def async[T](register: (Either[Throwable, T] => Unit) => Unit): R[T]
}
-object syntax {
-
- implicit final class MonadErrorOps[R[_], A](val r: R[A]) extends AnyVal {
- def map[B](f: A => B)(implicit ME: MonadError[R]): R[B] = ME.map(r)(f)
- def flatMap[B](f: A => R[B])(implicit ME: MonadError[R]): R[B] =
- ME.flatMap(r)(f)
- }
-}
-
object IdMonad extends MonadError[Id] {
override def unit[T](t: T): Id[T] = t
override def map[T, T2](fa: Id[T])(f: (T) => T2): Id[T2] = f(fa)
diff --git a/tests/src/test/scala/com/softwaremill/sttp/HttpURLConnectionHttpTest.scala b/core/src/test/scala/com/softwaremill/sttp/HttpURLConnectionHttpTest.scala
index 599913f..807209a 100644
--- a/tests/src/test/scala/com/softwaremill/sttp/HttpURLConnectionHttpTest.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/HttpURLConnectionHttpTest.scala
@@ -1,6 +1,7 @@
package com.softwaremill.sttp
-import com.softwaremill.sttp.testing.{ConvertToFuture, HttpTest}
+import com.softwaremill.sttp.testing.ConvertToFuture
+import com.softwaremill.sttp.testing.HttpTest
class HttpURLConnectionHttpTest extends HttpTest[Id] {
diff --git a/tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala b/core/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala
index 881c60e..4336a0c 100644
--- a/tests/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/IllTypedTests.scala
@@ -1,5 +1,6 @@
package com.softwaremill.sttp
+import com.softwaremill.sttp.testing.EvalScala
import org.scalatest.{FlatSpec, Matchers}
import scala.tools.reflect.ToolBoxError
@@ -9,15 +10,17 @@ class IllTypedTests extends FlatSpec with Matchers {
val thrown = intercept[ToolBoxError] {
EvalScala("""
import com.softwaremill.sttp._
- import akka.stream.scaladsl.Source
- import akka.util.ByteString
+
+ class MyStream[T]()
+
implicit val sttpBackend = HttpURLConnectionBackend()
- sttp.get(uri"http://example.com").response(asStream[Source[ByteString, Any]]).send()
+ sttp.get(uri"http://example.com").response(asStream[MyStream[Byte]]).send()
""")
}
thrown.getMessage should include(
- "could not find implicit value for parameter backend: com.softwaremill.sttp.SttpBackend[R,akka.stream.scaladsl.Source[akka.util.ByteString,Any]]")
+ "could not find implicit value for parameter backend: com.softwaremill.sttp.SttpBackend[R,MyStream[Byte]]"
+ )
}
"compilation" should "fail when trying to send a request without giving an URL" in {
diff --git a/tests/src/test/scala/com/softwaremill/sttp/TryHttpURLConnectionHttpTest.scala b/core/src/test/scala/com/softwaremill/sttp/TryHttpURLConnectionHttpTest.scala
index 19b48fd..aad1669 100644
--- a/tests/src/test/scala/com/softwaremill/sttp/TryHttpURLConnectionHttpTest.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/TryHttpURLConnectionHttpTest.scala
@@ -1,9 +1,10 @@
package com.softwaremill.sttp
-import com.softwaremill.sttp.testing.{ConvertToFuture, HttpTest}
-
import scala.util.Try
+import com.softwaremill.sttp.testing.ConvertToFuture
+import com.softwaremill.sttp.testing.HttpTest
+
class TryHttpURLConnectionHttpTest extends HttpTest[Try] {
override implicit val backend: SttpBackend[Try, Nothing] = TryHttpURLConnectionBackend()
diff --git a/tests/src/test/scala/com/softwaremill/sttp/EvalScala.scala b/core/src/test/scala/com/softwaremill/sttp/testing/EvalScala.scala
index bac1537..255755d 100644
--- a/tests/src/test/scala/com/softwaremill/sttp/EvalScala.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/testing/EvalScala.scala
@@ -1,4 +1,4 @@
-package com.softwaremill.sttp
+package com.softwaremill.sttp.testing
object EvalScala {
import scala.tools.reflect.ToolBox
diff --git a/core/src/test/scala/com/softwaremill/sttp/testing/streaming/StreamingTest.scala b/core/src/test/scala/com/softwaremill/sttp/testing/streaming/StreamingTest.scala
index aa0af07..27a6eda 100644
--- a/core/src/test/scala/com/softwaremill/sttp/testing/streaming/StreamingTest.scala
+++ b/core/src/test/scala/com/softwaremill/sttp/testing/streaming/StreamingTest.scala
@@ -3,16 +3,22 @@ package com.softwaremill.sttp.testing.streaming
import com.softwaremill.sttp._
import com.softwaremill.sttp.testing.ForceWrapped
import org.scalatest.{AsyncFreeSpec, BeforeAndAfterAll, Matchers}
-
import scala.language.higherKinds
+import com.softwaremill.sttp.testing.ConvertToFuture
+
trait StreamingTest[R[_], S] extends AsyncFreeSpec with Matchers with BeforeAndAfterAll with ForceWrapped {
private val endpoint = "localhost:51823"
private val body = "streaming test"
- val testStreamingBackend: TestStreamingBackend[R, S]
- import testStreamingBackend._
+ implicit def backend: SttpBackend[R, S]
+
+ implicit def convertToFuture: ConvertToFuture[R]
+
+ def bodyProducer(body: String): S
+
+ def bodyConsumer(stream: S): R[String]
"stream request body" in {
sttp
@@ -58,7 +64,7 @@ trait StreamingTest[R[_], S] extends AsyncFreeSpec with Matchers with BeforeAndA
}
override protected def afterAll(): Unit = {
- testStreamingBackend.backend.close()
+ backend.close()
super.afterAll()
}
diff --git a/core/src/test/scala/com/softwaremill/sttp/testing/streaming/TestStreamingBackend.scala b/core/src/test/scala/com/softwaremill/sttp/testing/streaming/TestStreamingBackend.scala
deleted file mode 100644
index 3ea63a3..0000000
--- a/core/src/test/scala/com/softwaremill/sttp/testing/streaming/TestStreamingBackend.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.softwaremill.sttp.testing.streaming
-
-import com.softwaremill.sttp.SttpBackend
-import com.softwaremill.sttp.testing.ConvertToFuture
-
-import scala.language.higherKinds
-
-trait TestStreamingBackend[R[_], S] {
- implicit def backend: SttpBackend[R, S]
-
- implicit def convertToFuture: ConvertToFuture[R]
-
- def bodyProducer(body: String): S
-
- def bodyConsumer(stream: S): R[String]
-}
diff --git a/docs/backends/custom.rst b/docs/backends/custom.rst
index 17571e1..86bfb9d 100644
--- a/docs/backends/custom.rst
+++ b/docs/backends/custom.rst
@@ -3,10 +3,10 @@
Custom backends, logging, metrics
=================================
-It is also entirely possible to write custom backends (if doing so, please consider contributing!) or wrap an existing one. One can even write completely generic wrappers for any delegate backend, as each backend comes equipped with a monad for the response type. This brings the possibility to ``map`` and ``flatMap`` over responses.
+It is also entirely possible to write custom backends (if doing so, please consider contributing!) or wrap an existing one. One can even write completely generic wrappers for any delegate backend, as each backend comes equipped with a monad for the response type. This brings the possibility to ``map`` and ``flatMap`` over responses.
Possible use-cases for wrapper-backend include:
-
+
* logging
* capturing metrics
* request signing (transforming the request before sending it to the delegate)
@@ -60,7 +60,7 @@ Below is an example on how to implement a backend wrapper, which sends metrics f
class MetricWrapper[S](delegate: SttpBackend[Future, S],
metrics: MetricsServer)
extends SttpBackend[Future, S] {
-
+
override def send[T](request: Request[T, S]): Future[Response[T]] = {
val start = System.currentTimeMillis()
@@ -138,3 +138,26 @@ In some cases it's possible to implement a generic retry mechanism; such a mecha
}
Note that some backends also have built-in retry mechanisms, e.g. `akka-http <https://doc.akka.io/docs/akka-http/current/scala/http/client-side/host-level.html#retrying-a-request>`_ or `OkHttp <http://square.github.io/okhttp>`_ (see the builder's ``retryOnConnectionFailure`` method).
+
+Example new backend
+--------------------------------
+
+Implementing a new backend is made easy as the tests are published in the ``core`` jar file under the ``tests`` classifier. Simply add the follow dependencies to your ``build.sbt``::
+
+ "com.softwaremill.sttp" %% "core" % sttpVersion % "test" classifier "tests",
+ "com.github.pathikrit" %% "better-files" % "3.4.0" % "test",
+ "org.scalatest" %% "scalatest" % "3.0.5" % "test"
+
+Implement your backend and extend the ``HttpTest`` class::
+
+ import com.softwaremill.sttp.SttpBackend
+ import com.softwaremill.sttp.testing.{ConvertToFuture, HttpTest}
+
+ class MyCustomBackendHttpTest extends HttpTest[Future] {
+
+ override implicit val convertToFuture: ConvertToFuture[Future] = ConvertToFuture.future
+ override implicit lazy val backend: SttpBackend[Future, Nothing] = new MyCustomBackend()
+
+ }
+
+You can find a more detailed example in the `sttp-vertx <https://github.com/guymers/sttp-vertx>`_ repository.
diff --git a/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala b/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala
new file mode 100644
index 0000000..d00c056
--- /dev/null
+++ b/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixStreamingTest.scala
@@ -0,0 +1,26 @@
+package com.softwaremill.sttp.impl.monix
+
+import java.nio.ByteBuffer
+
+import com.softwaremill.sttp.testing.ConvertToFuture
+import com.softwaremill.sttp.testing.streaming.StreamingTest
+import monix.eval.Task
+import monix.reactive.Observable
+
+abstract class MonixStreamingTest extends StreamingTest[Task, Observable[ByteBuffer]] {
+
+ override implicit val convertToFuture: ConvertToFuture[Task] = convertMonixTaskToFuture
+
+ override def bodyProducer(body: String): Observable[ByteBuffer] =
+ Observable
+ .fromIterable(
+ body.getBytes("utf-8")
+ )
+ .map(v => ByteBuffer.wrap(Array(v)))
+
+ override def bodyConsumer(stream: Observable[ByteBuffer]): Task[String] =
+ stream
+ .flatMap(v => Observable.fromIterable(v.array()))
+ .toListL
+ .map(bs => new String(bs.toArray, "utf8"))
+}
diff --git a/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixTestStreamingBackend.scala b/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixTestStreamingBackend.scala
deleted file mode 100644
index f1b262b..0000000
--- a/implementations/monix/src/test/scala/com/softwaremill/sttp/impl/monix/MonixTestStreamingBackend.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.softwaremill.sttp.impl.monix
-
-import com.softwaremill.sttp.testing.ConvertToFuture
-import com.softwaremill.sttp.testing.streaming.TestStreamingBackend
-import monix.eval.Task
-import monix.reactive.Observable
-
-trait MonixTestStreamingBackend[T] extends TestStreamingBackend[Task, Observable[T]] {
-
- def toByteArray(v: T): Array[Byte]
- def fromByteArray(v: Array[Byte]): T
-
- override implicit def convertToFuture: ConvertToFuture[Task] = convertMonixTaskToFuture
-
- override def bodyProducer(body: String): Observable[T] =
- Observable
- .fromIterable(
- body.getBytes("utf-8")
- )
- .map(v => fromByteArray(Array(v)))
-
- override def bodyConsumer(stream: Observable[T]): Task[String] =
- stream
- .flatMap(v => Observable.fromIterable(toByteArray(v)))
- .toListL
- .map(bs => new String(bs.toArray, "utf8"))
-
-}
diff --git a/okhttp-backend/monix/src/test/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixStreamingTest.scala b/okhttp-backend/monix/src/test/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixStreamingTest.scala
index af9ea9c..dd08214 100644
--- a/okhttp-backend/monix/src/test/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixStreamingTest.scala
+++ b/okhttp-backend/monix/src/test/scala/com/softwaremill/sttp/okhttp/monix/OkHttpMonixStreamingTest.scala
@@ -3,24 +3,11 @@ package com.softwaremill.sttp.okhttp.monix
import java.nio.ByteBuffer
import com.softwaremill.sttp.SttpBackend
-import com.softwaremill.sttp.impl.monix.MonixTestStreamingBackend
-import com.softwaremill.sttp.testing.streaming.{StreamingTest, TestStreamingBackend}
+import com.softwaremill.sttp.impl.monix.MonixStreamingTest
import monix.eval.Task
import monix.reactive.Observable
-class OkHttpMonixStreamingTest extends StreamingTest[Task, Observable[ByteBuffer]] {
+class OkHttpMonixStreamingTest extends MonixStreamingTest {
- override val testStreamingBackend: TestStreamingBackend[Task, Observable[ByteBuffer]] =
- new OkHttpMonixTestStreamingBackend
-}
-
-class OkHttpMonixTestStreamingBackend extends MonixTestStreamingBackend[ByteBuffer] {
-
- import monix.execution.Scheduler.Implicits.global
-
- override def toByteArray(v: ByteBuffer): Array[Byte] = v.array()
- override def fromByteArray(v: Array[Byte]): ByteBuffer = ByteBuffer.wrap(v)
-
- override implicit val backend: SttpBackend[Task, Observable[ByteBuffer]] =
- OkHttpMonixBackend()
+ override implicit val backend: SttpBackend[Task, Observable[ByteBuffer]] = OkHttpMonixBackend()
}
diff --git a/tests/src/test/resources/binaryfile.jpg b/tests/src/test/resources/binaryfile.jpg
deleted file mode 100644
index b9f5c5a..0000000
--- a/tests/src/test/resources/binaryfile.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/src/test/resources/logback.xml b/tests/src/test/resources/logback.xml
deleted file mode 100644
index 1470b51..0000000
--- a/tests/src/test/resources/logback.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<configuration>
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <root level="INFO">
- <appender-ref ref="STDOUT"/>
- </root>
-</configuration>
diff --git a/tests/src/test/resources/textfile.txt b/tests/src/test/resources/textfile.txt
deleted file mode 100644
index 9904f90..0000000
--- a/tests/src/test/resources/textfile.txt
+++ /dev/null
@@ -1,100 +0,0 @@
-- Lorem ipsum dolor sit amet
-- Vivamus sem ipsum.
-- Ut molestie.
-- Donec.
-- Fusce non porta.
-- Nulla ac metus. Morbi mattis.
-- Etiam varius.
-- Nulla.
-- Phasellus id mollis.
-- Suspendisse at.
-- Quisque nec leo velit.
-- Fusce.
-- Maecenas nec tristique senectus et.
-- Integer vestibulum lorem fermentum.
-- Vestibulum consectetuer dolor.
-- Lorem ipsum in.
-- Fusce condimentum auctor scelerisque, wisi.
-- Quisque.
-- Curae.
-- Curae, Nullam.
-- Curae, Integer.
-- Vestibulum dignissim massa. Donec.
-- Pellentesque sed sem.
-- Vivamus est.
-- Maecenas elit sed est.
-- Quisque sed tellus.
-- Cum sociis natoque penatibus et.
-- Fusce aliquam.
-- Donec.
-- Sed elementum, sapien accumsan odio.
-- Nam mattis, magna lectus, tincidunt.
-- Pellentesque scelerisque a, sodales.
-- Sed sed condimentum.
-- Curae, In nonummy. Phasellus adipiscing.
-- Vestibulum quis diam mollis.
-- Sed eros. Duis ipsum.
-- Aenean pellentesque at, mollis tempus.
-- Cras ornare facilisis sodales. Aenean.
-- Cum sociis natoque penatibus.
-- Donec id nulla.
-- Quisque ut sapien.
-- Phasellus purus. Proin ultricies.
-- Aliquam auctor neque. Nunc.
-- Nam nunc fringilla non, vehicula.
-- Morbi molestie, felis ut lobortis.
-- Nulla quis.
-- In.
-- Phasellus laoreet urna.
-- Lorem ipsum.
-- Phasellus.
-- Class aptent taciti sociosqu ad.
-- Sed lacinia.
-- Pellentesque dapibus diam. Duis.
-- Suspendisse est. Curabitur.
-- Fusce condimentum justo.
-- Aenean congue quis, faucibus.
-- Ut pharetra leo. Donec.
-- Fusce.
-- Donec porta.
-- Pellentesque orci.
-- Sed.
-- Quisque rutrum, wisi vulputate wisi.
-- Cum sociis.
-- Cras.
-- Sed eros. Curabitur.
-- Proin in velit wisi, tempor.
-- Quisque eu.
-- Proin.
-- Nam pellentesque sed, imperdiet aliquam.
-- Mauris euismod. Sed euismod orci.
-- Etiam.
-- Donec.
-- Fusce wisi a metus. Proin.
-- Phasellus quis.
-- Donec non imperdiet.
-- Aenean vel bibendum a, laoreet.
-- Fusce non enim. Phasellus vulputate.
-- Donec urna elit, sit.
-- Pellentesque habitant morbi.
-- Nulla ante. Curabitur elit. Donec.
-- Cum sociis natoque penatibus.
-- Maecenas eget leo at.
-- Cum sociis natoque penatibus et.
-- Vivamus lacus.
-- Integer.
-- Curae.
-- Maecenas rhoncus. Morbi.
-- Aenean posuere.
-- Duis.
-- Suspendisse a odio fermentum libero.
-- Nam enim. Fusce enim. In.
-- Maecenas.
-- Lorem ipsum primis.
-- Curabitur ac turpis semper sed.
-- Quisque condimentum. Donec sit.
-- Integer convallis non, posuere.
-- Etiam vulputate, odio.
-- Proin id lorem. Donec quis.
-- Curae, Sed nec augue.
-- Aliquam ut turpis. \ No newline at end of file