!htc #15726: Akka HTTP with the new DSL
This commit is contained in:
parent
c1d26c8ff7
commit
ed27f86791
58 changed files with 554 additions and 503 deletions
|
|
@ -12,7 +12,7 @@ import scala.util.DynamicVariable
|
|||
import scala.reflect.ClassTag
|
||||
import org.scalatest.Suite
|
||||
import akka.actor.ActorSystem
|
||||
import akka.stream.FlowMaterializer
|
||||
import akka.stream.scaladsl2.FlowMaterializer
|
||||
import akka.http.client.RequestBuilding
|
||||
import akka.http.util.FastFuture
|
||||
import akka.http.server._
|
||||
|
|
@ -121,7 +121,7 @@ trait RouteTest extends RequestBuilding with RouteTestResultComponent {
|
|||
new TildeArrow[RequestContext, Future[RouteResult]] {
|
||||
type Out = RouteTestResult
|
||||
def apply(request: HttpRequest, route: Route): Out = {
|
||||
val routeTestResult = new RouteTestResult(timeout.duration)(setup.materializer)
|
||||
val routeTestResult = new RouteTestResult(timeout.duration)
|
||||
val effectiveRequest =
|
||||
request.withEffectiveUri(
|
||||
securedConnection = defaultHostInfo.securedConnection,
|
||||
|
|
|
|||
|
|
@ -5,12 +5,10 @@
|
|||
package akka.http.testkit
|
||||
|
||||
import java.util.concurrent.CountDownLatch
|
||||
import org.reactivestreams.Publisher
|
||||
import scala.collection.immutable
|
||||
import scala.concurrent.duration._
|
||||
import scala.concurrent.{ Await, ExecutionContext }
|
||||
import akka.stream.FlowMaterializer
|
||||
import akka.stream.scaladsl.Flow
|
||||
import akka.stream.scaladsl2._
|
||||
import akka.http.model.HttpEntity.ChunkStreamPart
|
||||
import akka.http.server._
|
||||
import akka.http.model._
|
||||
|
|
@ -82,21 +80,21 @@ trait RouteTestResultComponent {
|
|||
|
||||
case HttpEntity.Default(contentType, contentLength, data) ⇒
|
||||
val dataChunks = awaitAllElements(data);
|
||||
{ () ⇒ HttpEntity.Default(contentType, contentLength, Flow(dataChunks).toPublisher()) }
|
||||
{ () ⇒ HttpEntity.Default(contentType, contentLength, Source(dataChunks)) }
|
||||
|
||||
case HttpEntity.CloseDelimited(contentType, data) ⇒
|
||||
val dataChunks = awaitAllElements(data);
|
||||
{ () ⇒ HttpEntity.CloseDelimited(contentType, Flow(dataChunks).toPublisher()) }
|
||||
{ () ⇒ HttpEntity.CloseDelimited(contentType, Source(dataChunks)) }
|
||||
|
||||
case HttpEntity.Chunked(contentType, chunks) ⇒
|
||||
val dataChunks = awaitAllElements(chunks);
|
||||
{ () ⇒ HttpEntity.Chunked(contentType, Flow(dataChunks).toPublisher()) }
|
||||
{ () ⇒ HttpEntity.Chunked(contentType, Source(dataChunks)) }
|
||||
}
|
||||
|
||||
private def failNeitherCompletedNorRejected(): Nothing =
|
||||
failTest("Request was neither completed nor rejected within " + timeout)
|
||||
|
||||
private def awaitAllElements[T](data: Publisher[T]): immutable.Seq[T] =
|
||||
Await.result(Flow(data).grouped(Int.MaxValue).toFuture(), timeout)
|
||||
private def awaitAllElements[T](data: Source[T]): immutable.Seq[T] =
|
||||
Await.result(data.grouped(Int.MaxValue).runWith(FutureDrain()), timeout)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue