=str #18902 in tests (due to grouped+Sink.head) empty response stream would throw

This commit is contained in:
Konrad Malawski 2015-11-10 13:51:13 +01:00
parent e50a5ee6fc
commit 985e3b1c2f
2 changed files with 38 additions and 3 deletions

View file

@ -5,9 +5,11 @@
package akka.http.scaladsl.testkit
import java.util.concurrent.CountDownLatch
import akka.dispatch.ExecutionContexts
import scala.collection.immutable
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
import scala.concurrent.{ Await, ExecutionContext }
import akka.stream.Materializer
import akka.stream.scaladsl._
import akka.http.scaladsl.model.HttpEntity.ChunkStreamPart
@ -95,7 +97,11 @@ trait RouteTestResultComponent {
private def failNeitherCompletedNorRejected(): Nothing =
failTest("Request was neither completed nor rejected within " + timeout)
private def awaitAllElements[T](data: Source[T, _]): immutable.Seq[T] =
data.grouped(100000).runWith(Sink.head).awaitResult(timeout)
private def awaitAllElements[T](data: Source[T, _]): immutable.Seq[T] = {
data.grouped(100000).runWith(Sink.head).recover({
case e: NoSuchElementException Nil
})(ExecutionContexts.sameThreadExecutionContext)
.awaitResult(timeout)
}
}
}