diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/RequestParserSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/RequestParserSpec.scala index ebea46c7cf..0af74795b7 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/RequestParserSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/RequestParserSpec.scala @@ -438,7 +438,7 @@ class RequestParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll { override def afterAll() = system.terminate() private class Test { - def awaitAtMost: FiniteDuration = 250.millis + def awaitAtMost: FiniteDuration = 3.seconds var closeAfterResponseCompletion = Seq.empty[Boolean] class StrictEqualHttpRequest(val req: HttpRequest) { diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala index e123292eb2..5d4c290689 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala @@ -243,14 +243,16 @@ class ResponseParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll { override def afterAll() = system.terminate() private class Test { + def awaitAtMost: FiniteDuration = 3.seconds var closeAfterResponseCompletion = Seq.empty[Boolean] class StrictEqualHttpResponse(val resp: HttpResponse) { override def equals(other: scala.Any): Boolean = other match { case other: StrictEqualHttpResponse ⇒ + this.resp.copy(entity = HttpEntity.Empty) == other.resp.copy(entity = HttpEntity.Empty) && - Await.result(this.resp.entity.toStrict(250.millis), 250.millis) == - Await.result(other.resp.entity.toStrict(250.millis), 250.millis) + Await.result(this.resp.entity.toStrict(awaitAtMost), awaitAtMost) == + Await.result(other.resp.entity.toStrict(awaitAtMost), awaitAtMost) } override def toString = resp.toString @@ -319,7 +321,7 @@ class ResponseParserSpec extends FreeSpec with Matchers with BeforeAndAfterAll { private def compactEntity(entity: ResponseEntity): Future[ResponseEntity] = entity match { case x: HttpEntity.Chunked ⇒ compactEntityChunks(x.chunks).fast.map(compacted ⇒ x.copy(chunks = compacted)) - case _ ⇒ entity.toStrict(250.millis) + case _ ⇒ entity.toStrict(awaitAtMost) } private def compactEntityChunks(data: Source[ChunkStreamPart, Any]): Future[Source[ChunkStreamPart, Any]] = diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/RequestRendererSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/RequestRendererSpec.scala index 6b1afd8caf..ef99312355 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/RequestRendererSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/RequestRendererSpec.scala @@ -322,11 +322,13 @@ class RequestRendererSpec extends FreeSpec with Matchers with BeforeAndAfterAll serverAddress: InetSocketAddress = new InetSocketAddress("test.com", 8080)) extends HttpRequestRendererFactory(userAgent, requestHeaderSizeHint = 64, NoLogging) { + def awaitAtMost: FiniteDuration = 3.seconds + def renderTo(expected: String): Matcher[HttpRequest] = equal(expected.stripMarginWithNewline("\r\n")).matcher[String] compose { request ⇒ val byteStringSource = renderToSource(RequestRenderingContext(request, Host(serverAddress))) val future = byteStringSource.limit(1000).runWith(Sink.seq).map(_.reduceLeft(_ ++ _).utf8String) - Await.result(future, 250.millis) + Await.result(future, awaitAtMost) } } diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/ResponseRendererSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/ResponseRendererSpec.scala index 421fdfb6c3..5a53d09a01 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/ResponseRendererSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/ResponseRendererSpec.scala @@ -581,6 +581,8 @@ class ResponseRendererSpec extends FreeSpec with Matchers with BeforeAndAfterAll class TestSetup(val serverHeader: Option[Server] = Some(Server("akka-http/1.0.0"))) extends HttpResponseRendererFactory(serverHeader, responseHeaderSizeHint = 64, NoLogging) { + def awaitAtMost: FiniteDuration = 3.seconds + def renderTo(expected: String): Matcher[HttpResponse] = renderTo(expected, close = false) compose (ResponseRenderingContext(_)) @@ -605,7 +607,7 @@ class ResponseRendererSpec extends FreeSpec with Matchers with BeforeAndAfterAll } catch { case NonFatal(_) ⇒ false } - Await.result(resultFuture, 250.millis).reduceLeft(_ ++ _).utf8String -> wasCompleted + Await.result(resultFuture, awaitAtMost).reduceLeft(_ ++ _).utf8String -> wasCompleted } override def currentTimeMillis() = DateTime(2011, 8, 25, 9, 10, 29).clicks // provide a stable date for testing diff --git a/akka-http-core/src/test/scala/akka/http/scaladsl/model/HttpEntitySpec.scala b/akka-http-core/src/test/scala/akka/http/scaladsl/model/HttpEntitySpec.scala index c6838706a2..c1653657a4 100755 --- a/akka-http-core/src/test/scala/akka/http/scaladsl/model/HttpEntitySpec.scala +++ b/akka-http-core/src/test/scala/akka/http/scaladsl/model/HttpEntitySpec.scala @@ -35,6 +35,8 @@ class HttpEntitySpec extends FreeSpec with MustMatchers with BeforeAndAfterAll { implicit val materializer = ActorMaterializer() override def afterAll() = system.terminate() + val awaitAtMost = 3.seconds + "HttpEntity" - { "support dataBytes" - { "Strict" in { @@ -90,7 +92,7 @@ class HttpEntitySpec extends FreeSpec with MustMatchers with BeforeAndAfterAll { "Infinite data stream" in { val neverCompleted = Promise[ByteString]() intercept[TimeoutException] { - Await.result(Default(tpe, 42, Source.fromFuture(neverCompleted.future)).toStrict(100.millis), 150.millis) + Await.result(Default(tpe, 42, Source.fromFuture(neverCompleted.future)).toStrict(100.millis), awaitAtMost) }.getMessage must be("HttpEntity.toStrict timed out after 100 milliseconds while still waiting for outstanding data") } } @@ -178,18 +180,18 @@ class HttpEntitySpec extends FreeSpec with MustMatchers with BeforeAndAfterAll { def collectBytesTo(bytes: ByteString*): Matcher[HttpEntity] = equal(bytes.toVector).matcher[Seq[ByteString]].compose { entity ⇒ val future = entity.dataBytes.limit(1000).runWith(Sink.seq) - Await.result(future, 250.millis) + Await.result(future, awaitAtMost) } def withReturnType[T](expr: T) = expr def strictifyTo(strict: Strict): Matcher[HttpEntity] = - equal(strict).matcher[Strict].compose(x ⇒ Await.result(x.toStrict(250.millis), 250.millis)) + equal(strict).matcher[Strict].compose(x ⇒ Await.result(x.toStrict(awaitAtMost), awaitAtMost)) def transformTo(strict: Strict): Matcher[HttpEntity] = equal(strict).matcher[Strict].compose { x ⇒ val transformed = x.transformDataBytes(duplicateBytesTransformer) - Await.result(transformed.toStrict(250.millis), 250.millis) + Await.result(transformed.toStrict(awaitAtMost), awaitAtMost) } def renderStrictDataAs(dataRendering: String): Matcher[Strict] =