aboutsummaryrefslogtreecommitdiff
path: root/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala')
-rw-r--r--tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala87
1 files changed, 0 insertions, 87 deletions
diff --git a/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala b/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala
deleted file mode 100644
index b2b44a2..0000000
--- a/tests/src/test/scala/com/softwaremill/sttp/StreamingTests.scala
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.softwaremill.sttp
-
-import akka.http.scaladsl.server.Directives._
-import akka.http.scaladsl.server.Route
-import com.softwaremill.sttp.streaming._
-import com.softwaremill.sttp.testing.streaming.TestStreamingBackend
-import com.typesafe.scalalogging.StrictLogging
-import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers}
-
-import scala.language.higherKinds
-
-class StreamingTests
- extends FlatSpec
- with Matchers
- with BeforeAndAfterAll
- with StrictLogging
- with TestHttpServer
- with ForceWrapped {
-
- override val serverRoutes: Route =
- path("echo") {
- post {
- parameterMap { _ =>
- entity(as[String]) { body: String =>
- complete(body)
- }
- }
- }
- }
-
- override def port = 51824
-
- val body = "streaming test"
-
- var closeBackends: List[() => Unit] = Nil
-
- runTests("Akka Http", new AkkaHttpStreamingTests(actorSystem))
- runTests("Monix Async Http Client", new AsyncHttpClientMonixStreamingTests)
- runTests("Monix OkHttp", new OkHttpMonixStreamingTests)
- runTests("fs2 Async Http Client", new AsyncHttpClientFs2StreamingTests)
-
- def runTests[R[_], S](name: String, testStreamingBackend: TestStreamingBackend[R, S]): Unit = {
- import testStreamingBackend._
-
- closeBackends = (() => backend.close()) :: closeBackends
-
- name should "stream request body" in {
- val response = sttp
- .post(uri"$endpoint/echo")
- .streamBody(bodyProducer(body))
- .send()
- .force()
-
- response.unsafeBody shouldBe body
- }
-
- it should "receive a stream" in {
- val response = sttp
- .post(uri"$endpoint/echo")
- .body(body)
- .response(asStream[S])
- .send()
- .force()
-
- bodyConsumer(response.unsafeBody).force() shouldBe body
- }
-
- it should "receive a stream from an https site" in {
- val response = sttp
- // of course, you should never rely on the internet being available
- // in tests, but that's so much easier than setting up an https
- // testing server
- .get(uri"https://softwaremill.com")
- .response(asStream[S])
- .send()
- .force()
-
- bodyConsumer(response.unsafeBody).force() should include("</div>")
- }
- }
-
- override protected def afterAll(): Unit = {
- closeBackends.foreach(_())
- super.afterAll()
- }
-
-}