diff --git a/akka-docs-dev/rst/java/stream-testkit.rst b/akka-docs-dev/rst/java/stream-testkit.rst index 873ab4be49..8de0cb1e93 100644 --- a/akka-docs-dev/rst/java/stream-testkit.rst +++ b/akka-docs-dev/rst/java/stream-testkit.rst @@ -19,11 +19,11 @@ Testing a custom sink can be as simple as attaching a source that emits elements .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/StreamTestKitDocTest.java#strict-collection -The same strategy can be applied for sources as well. In the next example we have a source that produces an infinite stream of elements. Such source can be tested by asserting that first arbitrary number of elements hold some condition. Here :code:`grouped` combinator and :code:`Sink.head` are very useful. +The same strategy can be applied for sources as well. In the next example we have a source that produces an infinite stream of elements. Such source can be tested by asserting that first arbitrary number of elements hold some condition. Here the :code:`grouped` combinator and :code:`Sink.head` are very useful. .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/StreamTestKitDocTest.java#grouped-infinite -When testing a flow we need to attach a source and a sink. As both stream ends are under our control, we can choose sources that tests various edge cases of the flow and sinks that eases assertions. +When testing a flow we need to attach a source and a sink. As both stream ends are under our control, we can choose sources that tests various edge cases of the flow and sinks that ease assertions. .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/StreamTestKitDocTest.java#folded-stream diff --git a/akka-docs-dev/rst/scala/code/docs/stream/StreamTestKitDocSpec.scala b/akka-docs-dev/rst/scala/code/docs/stream/StreamTestKitDocSpec.scala index d169bb38d3..60dfc8d20e 100644 --- a/akka-docs-dev/rst/scala/code/docs/stream/StreamTestKitDocSpec.scala +++ b/akka-docs-dev/rst/scala/code/docs/stream/StreamTestKitDocSpec.scala @@ -23,8 +23,7 @@ class StreamTestKitDocSpec extends AkkaSpec { val sinkUnderTest = Flow[Int].map(_ * 2).toMat(Sink.fold(0)(_ + _))(Keep.right) val future = Source(1 to 4).runWith(sinkUnderTest) - Await.ready(future, 100.millis) - val Success(result) = future.value.get + val result = Await.result(future, 100.millis) assert(result == 20) //#strict-collection } @@ -34,8 +33,7 @@ class StreamTestKitDocSpec extends AkkaSpec { val sourceUnderTest = Source.repeat(1).map(_ * 2) val future = sourceUnderTest.grouped(10).runWith(Sink.head) - Await.ready(future, 100.millis) - val Success(result) = future.value.get + val result = Await.result(future, 100.millis) assert(result == Seq.fill(10)(2)) //#grouped-infinite } @@ -45,8 +43,7 @@ class StreamTestKitDocSpec extends AkkaSpec { val flowUnderTest = Flow[Int].takeWhile(_ < 5) val future = Source(1 to 10).via(flowUnderTest).runWith(Sink.fold(Seq.empty[Int])(_ :+ _)) - Await.ready(future, 100.millis) - val Success(result) = future.value.get + val result = Await.result(future, 100.millis) assert(result == (1 to 4)) //#folded-stream } @@ -64,14 +61,15 @@ class StreamTestKitDocSpec extends AkkaSpec { "sink actor ref" in { //#sink-actorref - val sourceUnderTest = Source(0.seconds, 200.millis, ()) + case object Tick + val sourceUnderTest = Source(0.seconds, 200.millis, Tick) val probe = TestProbe() val cancellable = sourceUnderTest.to(Sink.actorRef(probe.ref, "completed")).run() - probe.expectMsg(1.second, ()) + probe.expectMsg(1.second, Tick) probe.expectNoMsg(100.millis) - probe.expectMsg(200.millis, ()) + probe.expectMsg(200.millis, Tick) cancellable.cancel() probe.expectMsg(200.millis, "completed") //#sink-actorref @@ -89,8 +87,7 @@ class StreamTestKitDocSpec extends AkkaSpec { ref ! 3 ref ! akka.actor.Status.Success("done") - Await.ready(future, 100.millis) - val Success(result) = future.value.get + val result = Await.result(future, 100.millis) assert(result == "123") //#source-actorref } diff --git a/akka-docs-dev/rst/scala/stream-testkit.rst b/akka-docs-dev/rst/scala/stream-testkit.rst index b1f6b1af60..0f642455b6 100644 --- a/akka-docs-dev/rst/scala/stream-testkit.rst +++ b/akka-docs-dev/rst/scala/stream-testkit.rst @@ -19,11 +19,11 @@ Testing a custom sink can be as simple as attaching a source that emits elements .. includecode:: code/docs/stream/StreamTestKitDocSpec.scala#strict-collection -The same strategy can be applied for sources as well. In the next example we have a source that produces an infinite stream of elements. Such source can be tested by asserting that first arbitrary number of elements hold some condition. Here :code:`grouped` combinator and :code:`Sink.head` are very useful. +The same strategy can be applied for sources as well. In the next example we have a source that produces an infinite stream of elements. Such source can be tested by asserting that first arbitrary number of elements hold some condition. Here the :code:`grouped` combinator and :code:`Sink.head` are very useful. .. includecode:: code/docs/stream/StreamTestKitDocSpec.scala#grouped-infinite -When testing a flow we need to attach a source and a sink. As both stream ends are under our control, we can choose sources that tests various edge cases of the flow and sinks that eases assertions. +When testing a flow we need to attach a source and a sink. As both stream ends are under our control, we can choose sources that tests various edge cases of the flow and sinks that ease assertions. .. includecode:: code/docs/stream/StreamTestKitDocSpec.scala#folded-stream