diff --git a/akka-docs/rst/java/code/docs/stream/StreamTestKitDocTest.java b/akka-docs/rst/java/code/docs/stream/StreamTestKitDocTest.java index 9580bbaddd..e3fa5a3694 100644 --- a/akka-docs/rst/java/code/docs/stream/StreamTestKitDocTest.java +++ b/akka-docs/rst/java/code/docs/stream/StreamTestKitDocTest.java @@ -57,7 +57,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest { final CompletionStage future = Source.from(Arrays.asList(1, 2, 3, 4)) .runWith(sinkUnderTest, mat); - final Integer result = future.toCompletableFuture().get(1, TimeUnit.SECONDS); + final Integer result = future.toCompletableFuture().get(3, TimeUnit.SECONDS); assert(result == 20); //#strict-collection } @@ -69,9 +69,9 @@ public class StreamTestKitDocTest extends AbstractJavaTest { .map(i -> i * 2); final CompletionStage> future = sourceUnderTest - .grouped(10) - .runWith(Sink.head(), mat); - final List result = future.toCompletableFuture().get(1, TimeUnit.SECONDS); + .take(10) + .runWith(Sink.seq(), mat); + final List result = future.toCompletableFuture().get(3, TimeUnit.SECONDS); assertEquals(result, Collections.nCopies(10, 2)); //#grouped-infinite } @@ -84,7 +84,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest { final CompletionStage future = Source.from(Arrays.asList(1, 2, 3, 4, 5, 6)) .via(flowUnderTest).runWith(Sink.fold(0, (agg, next) -> agg + next), mat); - final Integer result = future.toCompletableFuture().get(1, TimeUnit.SECONDS); + final Integer result = future.toCompletableFuture().get(3, TimeUnit.SECONDS); assert(result == 10); //#folded-stream } @@ -101,7 +101,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest { .grouped(2) .runWith(Sink.head(), mat); akka.pattern.PatternsCS.pipe(future, system.dispatcher()).to(probe.ref()); - probe.expectMsg(Duration.create(1, TimeUnit.SECONDS), + probe.expectMsg(Duration.create(3, TimeUnit.SECONDS), Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4)) ); //#pipeto-testprobe @@ -120,11 +120,11 @@ public class StreamTestKitDocTest extends AbstractJavaTest { final TestProbe probe = new TestProbe(system); final Cancellable cancellable = sourceUnderTest .to(Sink.actorRef(probe.ref(), Tick.COMPLETED)).run(mat); - probe.expectMsg(Duration.create(1, TimeUnit.SECONDS), Tick.TOCK); + probe.expectMsg(Duration.create(3, TimeUnit.SECONDS), Tick.TOCK); probe.expectNoMsg(Duration.create(100, TimeUnit.MILLISECONDS)); - probe.expectMsg(Duration.create(1, TimeUnit.SECONDS), Tick.TOCK); + probe.expectMsg(Duration.create(3, TimeUnit.SECONDS), Tick.TOCK); cancellable.cancel(); - probe.expectMsg(Duration.create(1, TimeUnit.SECONDS), Tick.COMPLETED); + probe.expectMsg(Duration.create(3, TimeUnit.SECONDS), Tick.COMPLETED); //#sink-actorref } @@ -193,7 +193,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest { probe.sendError(new Exception("boom")); try { - future.toCompletableFuture().get(1, TimeUnit.SECONDS); + future.toCompletableFuture().get(3, TimeUnit.SECONDS); assert false; } catch (ExecutionException ee) { final Throwable exception = ee.getCause(); diff --git a/akka-docs/rst/java/stream/stream-testkit.rst b/akka-docs/rst/java/stream/stream-testkit.rst index 6f863f0810..e604fa2529 100644 --- a/akka-docs/rst/java/stream/stream-testkit.rst +++ b/akka-docs/rst/java/stream/stream-testkit.rst @@ -30,7 +30,7 @@ sink: 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 ``grouped`` combinator and ``Sink.head`` are very useful. +condition. Here the ``take`` combinator and ``Sink.seq`` are very useful. .. includecode:: ../code/docs/stream/StreamTestKitDocTest.java#grouped-infinite diff --git a/akka-docs/rst/scala/code/docs/stream/StreamTestKitDocSpec.scala b/akka-docs/rst/scala/code/docs/stream/StreamTestKitDocSpec.scala index 65bee809e4..e139368129 100644 --- a/akka-docs/rst/scala/code/docs/stream/StreamTestKitDocSpec.scala +++ b/akka-docs/rst/scala/code/docs/stream/StreamTestKitDocSpec.scala @@ -22,7 +22,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) - val result = Await.result(future, 100.millis) + val result = Await.result(future, 3.seconds) assert(result == 20) //#strict-collection } @@ -34,8 +34,8 @@ class StreamTestKitDocSpec extends AkkaSpec { val sourceUnderTest = Source.repeat(1).map(_ * 2) - val future = sourceUnderTest.grouped(10).runWith(Sink.head) - val result = Await.result(future, 100.millis) + val future = sourceUnderTest.take(10).runWith(Sink.seq) + val result = Await.result(future, 3.seconds) assert(result == Seq.fill(10)(2)) //#grouped-infinite } @@ -45,7 +45,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])(_ :+ _)) - val result = Await.result(future, 100.millis) + val result = Await.result(future, 3.seconds) assert(result == (1 to 4)) //#folded-stream } @@ -58,8 +58,8 @@ class StreamTestKitDocSpec extends AkkaSpec { val sourceUnderTest = Source(1 to 4).grouped(2) val probe = TestProbe() - sourceUnderTest.grouped(2).runWith(Sink.head).pipeTo(probe.ref) - probe.expectMsg(100.millis, Seq(Seq(1, 2), Seq(3, 4))) + sourceUnderTest.runWith(Sink.seq).pipeTo(probe.ref) + probe.expectMsg(3.seconds, Seq(Seq(1, 2), Seq(3, 4))) //#pipeto-testprobe } @@ -73,9 +73,9 @@ class StreamTestKitDocSpec extends AkkaSpec { probe.expectMsg(1.second, Tick) probe.expectNoMsg(100.millis) - probe.expectMsg(200.millis, Tick) + probe.expectMsg(3.seconds, Tick) cancellable.cancel() - probe.expectMsg(200.millis, "completed") + probe.expectMsg(3.seconds, "completed") //#sink-actorref } @@ -91,7 +91,7 @@ class StreamTestKitDocSpec extends AkkaSpec { ref ! 3 ref ! akka.actor.Status.Success("done") - val result = Await.result(future, 100.millis) + val result = Await.result(future, 3.seconds) assert(result == "123") //#source-actorref } @@ -128,7 +128,7 @@ class StreamTestKitDocSpec extends AkkaSpec { .run() probe.sendError(new Exception("boom")) - Await.ready(future, 100.millis) + Await.ready(future, 3.seconds) val Failure(exception) = future.value.get assert(exception.getMessage == "boom") //#injecting-failure diff --git a/akka-docs/rst/scala/stream/stream-testkit.rst b/akka-docs/rst/scala/stream/stream-testkit.rst index 377315e26c..293fecf3f0 100644 --- a/akka-docs/rst/scala/stream/stream-testkit.rst +++ b/akka-docs/rst/scala/stream/stream-testkit.rst @@ -30,7 +30,7 @@ sink: 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 ``grouped`` combinator and ``Sink.head`` are very useful. +condition. Here the ``take`` combinator and ``Sink.seq`` are very useful. .. includecode:: ../code/docs/stream/StreamTestKitDocSpec.scala#grouped-infinite