System wide materializer (#27491)
Introduces a materializer started through an extension and then an implicit conversion for Scala turning an implicitly available ActorSystem into a materializer. The Java APIs has been ammended with run-methods accepting an ActorSystem.
This commit is contained in:
parent
77d1d33dbc
commit
45c826a218
196 changed files with 1148 additions and 1129 deletions
|
|
@ -55,6 +55,11 @@ import com.github.ghik.silencer.silent
|
|||
|
||||
// impl InternalRecipientRef, ask not supported
|
||||
override def provider: ActorRefProvider = throw new UnsupportedOperationException("no provider")
|
||||
|
||||
// stream materialization etc. using stub not supported
|
||||
override private[akka] def classicSystem =
|
||||
throw new UnsupportedOperationException("no untyped actor system available")
|
||||
|
||||
// impl InternalRecipientRef
|
||||
def isTerminated: Boolean = whenTerminated.isCompleted
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package akka.actor.typed
|
|||
|
||||
import java.util.concurrent.{ CompletionStage, ThreadFactory }
|
||||
|
||||
import akka.actor.ClassicActorSystemProvider
|
||||
import akka.actor.BootstrapSetup
|
||||
import akka.actor.setup.ActorSystemSetup
|
||||
import akka.actor.typed.eventstream.EventStream
|
||||
|
|
@ -17,6 +18,7 @@ import akka.util.Helpers.Requiring
|
|||
import akka.util.Timeout
|
||||
import akka.{ Done, actor => untyped }
|
||||
import com.typesafe.config.{ Config, ConfigFactory }
|
||||
|
||||
import scala.concurrent.{ ExecutionContextExecutor, Future }
|
||||
|
||||
/**
|
||||
|
|
@ -29,7 +31,8 @@ import scala.concurrent.{ ExecutionContextExecutor, Future }
|
|||
* Not for user extension.
|
||||
*/
|
||||
@DoNotInherit
|
||||
abstract class ActorSystem[-T] extends ActorRef[T] with Extensions { this: InternalRecipientRef[T] =>
|
||||
abstract class ActorSystem[-T] extends ActorRef[T] with Extensions with ClassicActorSystemProvider {
|
||||
this: InternalRecipientRef[T] =>
|
||||
|
||||
/**
|
||||
* The name of this actor system, used to distinguish multiple ones within
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ import akka.{ actor => untyped }
|
|||
|
||||
import ActorRefAdapter.sendSystemMessage
|
||||
|
||||
override private[akka] def classicSystem: untyped.ActorSystem = untypedSystem
|
||||
|
||||
// Members declared in akka.actor.typed.ActorRef
|
||||
override def tell(msg: T): Unit = {
|
||||
if (msg == null) throw InvalidMessageException("[null] is not an allowed message")
|
||||
|
|
|
|||
|
|
@ -81,4 +81,8 @@ ProblemFilters.exclude[IncompatibleMethTypeProblem]("akka.pattern.CircuitBreaker
|
|||
ProblemFilters.exclude[IncompatibleMethTypeProblem]("akka.pattern.CircuitBreaker.onHalfOpen")
|
||||
|
||||
# streamref serialization #27304
|
||||
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.actor.DynamicAccess.classIsOnClasspath")
|
||||
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.actor.DynamicAccess.classIsOnClasspath")
|
||||
|
||||
# system wide materializer #25559
|
||||
ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("akka.actor.ExtendedActorSystem.classicSystem")
|
||||
ProblemFilters.exclude[InheritedNewAbstractMethodProblem]("akka.actor.ActorSystem.classicSystem")
|
||||
|
|
@ -13,12 +13,14 @@ import akka.actor.dungeon.ChildrenContainer
|
|||
import akka.actor.setup.{ ActorSystemSetup, Setup }
|
||||
import akka.annotation.InternalApi
|
||||
import akka.ConfigurationException
|
||||
import akka.annotation.DoNotInherit
|
||||
import akka.dispatch._
|
||||
import akka.event._
|
||||
import akka.japi.Util.immutableSeq
|
||||
import akka.util.Helpers.toRootLowerCase
|
||||
import akka.util._
|
||||
import com.typesafe.config.{ Config, ConfigFactory }
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.collection.immutable
|
||||
import scala.compat.java8.FutureConverters
|
||||
|
|
@ -470,7 +472,7 @@ object ActorSystem {
|
|||
* extending [[akka.actor.ExtendedActorSystem]] instead, but beware that you
|
||||
* are completely on your own in that case!
|
||||
*/
|
||||
abstract class ActorSystem extends ActorRefFactory {
|
||||
abstract class ActorSystem extends ActorRefFactory with ClassicActorSystemProvider {
|
||||
import ActorSystem._
|
||||
|
||||
/**
|
||||
|
|
@ -674,6 +676,7 @@ abstract class ActorSystem extends ActorRefFactory {
|
|||
* actually roll your own Akka, beware that you are completely on your own in
|
||||
* that case!
|
||||
*/
|
||||
@DoNotInherit
|
||||
abstract class ExtendedActorSystem extends ActorSystem {
|
||||
|
||||
/**
|
||||
|
|
@ -916,6 +919,8 @@ private[akka] class ActorSystemImpl(
|
|||
def /(actorName: String): ActorPath = guardian.path / actorName
|
||||
def /(path: Iterable[String]): ActorPath = guardian.path / path
|
||||
|
||||
override private[akka] def classicSystem: ActorSystem = this
|
||||
|
||||
// Used for ManifestInfo.checkSameVersion
|
||||
private def allModules: List[String] =
|
||||
List(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka.actor
|
||||
|
||||
import akka.annotation.DoNotInherit
|
||||
import akka.annotation.InternalApi
|
||||
|
||||
/**
|
||||
* Glue API introduced to allow minimal user effort integration between classic and typed for example for streams.
|
||||
*
|
||||
* Not for user extension.
|
||||
*/
|
||||
@DoNotInherit
|
||||
trait ClassicActorSystemProvider {
|
||||
|
||||
/** INTERNAL API */
|
||||
@InternalApi
|
||||
private[akka] def classicSystem: ActorSystem
|
||||
}
|
||||
|
|
@ -502,3 +502,16 @@ made before finalizing the APIs. Compared to Akka 2.5.x the source incompatible
|
|||
|
||||
* `ActorSource.actorRef` relying on `PartialFunction` has been replaced in the Java API with a variant more suitable to be called by Java.
|
||||
|
||||
|
||||
## Additional changes
|
||||
|
||||
### System global Materializer provided
|
||||
|
||||
A default materializer is now provided out of the box. For the Java API just pass `system` when running streams,
|
||||
for Scala an implicit materializer is provided if there is an implicit `ActorSystem` available. This avoids leaking
|
||||
materializers and simplifies most stream use cases somewhat.
|
||||
|
||||
Having a default materializer available means that most, if not all, usages of Java `ActorMaterializer.create()`
|
||||
and Scala `implicit val materializer = ActorMaterializer()` should be removed.
|
||||
|
||||
Details about the stream materializer can be found in [Actor Materializer Lifecycle](../stream/stream-flows-and-basics.md#actor-materializer-lifecycle)
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ and `runWith()` methods defined on `Source` and `Flow` elements as well as a sma
|
|||
well-known sinks, such as @scala[`runForeach(el => ...)`]@java[`runForeach(el -> ...)`]
|
||||
(being an alias to @scala[`runWith(Sink.foreach(el => ...))`]@java[`runWith(Sink.foreach(el -> ...))`]).
|
||||
|
||||
Materialization is currently performed synchronously on the materializing thread.
|
||||
Materialization is performed synchronously on the materializing thread by an `ActorSystem` global `Materializer`.
|
||||
The actual stream processing is handled by actors started up during the streams materialization,
|
||||
which will be running on the thread pools they have been configured to run on - which defaults to the dispatcher set in
|
||||
`MaterializationSettings` while constructing the `ActorMaterializer`.
|
||||
|
|
@ -376,20 +376,25 @@ merge is performed.
|
|||
|
||||
## Actor Materializer Lifecycle
|
||||
|
||||
The `Materializer` is a component that is responsible for turning the stream blueprint into a running stream
|
||||
and emitting the "materialized value". An `ActorSystem` wide `Materializer` is provided by the Akka `Extension`
|
||||
`SystemMaterializer` by @scala[having an implicit `ActorSystem` in scope]@java[passing the `ActorSystem` to the
|
||||
various `run` methods] this way there is no need to worry about the `Materializer` unless there are special requirements.
|
||||
|
||||
The use cases that may require a custom instance of `Materializer` are:
|
||||
|
||||
* When wanting to change some specific default settings for a set of streams (FIXME we should phase this out)
|
||||
* When all streams materialized in an actor should be tied to the Actor lifecycle and stop if the Actor stops or crashes
|
||||
|
||||
Currently the `Materializer` has one concrete implementation, the `ActorMaterializer`.
|
||||
|
||||
An important aspect of working with streams and actors is understanding an `ActorMaterializer`'s life-cycle.
|
||||
The materializer is bound to the lifecycle of the `ActorRefFactory` it is created from, which in practice will
|
||||
be either an `ActorSystem` or `ActorContext` (when the materializer is created within an `Actor`).
|
||||
be either an `ActorSystem` or `ActorContext` (when the materializer is created within an `Actor`).
|
||||
|
||||
The usual way of creating an `ActorMaterializer` is to create it next to your `ActorSystem`,
|
||||
which likely is in a "main" class of your application:
|
||||
Tying it to the `ActorSystem` should be replaced with using the system materializer from Akka 2.6 and on.
|
||||
|
||||
Scala
|
||||
: @@snip [FlowDocSpec.scala](/akka-docs/src/test/scala/docs/stream/FlowDocSpec.scala) { #materializer-from-system }
|
||||
|
||||
Java
|
||||
: @@snip [FlowDocTest.java](/akka-docs/src/test/java/jdocs/stream/FlowDocTest.java) { #materializer-from-system }
|
||||
|
||||
In this case the streams run by the materializer will run until it is shut down. When the materializer is shut down
|
||||
When run by the system materializer the streams will run until the `ActorSystem` is shut down. When the materializer is shut down
|
||||
*before* the streams have run to completion, they will be terminated abruptly. This is a little different than the
|
||||
usual way to terminate streams, which is by cancelling/completing them. The stream lifecycles are bound to the materializer
|
||||
like this to prevent leaks, and in normal operations you should not rely on the mechanism and rather use `KillSwitch` or
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ Scala
|
|||
Java
|
||||
: @@snip [QuickStartDocTest.java](/akka-docs/src/test/java/jdocs/stream/QuickStartDocTest.java) { #other-imports }
|
||||
|
||||
And @scala[an object]@java[a class] to hold your code, for example:
|
||||
And @scala[an object]@java[a class] to start an Akka `ActorSystem` and hold your code @scala[. Making the `ActorSystem`
|
||||
implicit makes it available to the streams without manually passing it when running them]:
|
||||
|
||||
Scala
|
||||
: @@snip [QuickStartDocSpec.scala](/akka-docs/src/test/scala/docs/stream/QuickStartDocSpec.scala) { #main-app }
|
||||
|
|
@ -52,11 +53,12 @@ Java
|
|||
: @@snip [QuickStartDocTest.java](/akka-docs/src/test/java/jdocs/stream/QuickStartDocTest.java) { #create-source }
|
||||
|
||||
The `Source` type is parameterized with two types: the first one is the
|
||||
type of element that this source emits and the second one may signal that
|
||||
running the source produces some auxiliary value (e.g. a network source may
|
||||
type of element that this source emits and the second one, the "materialized value", allows
|
||||
running the source to produce some auxiliary value (e.g. a network source may
|
||||
provide information about the bound port or the peer’s address). Where no
|
||||
auxiliary information is produced, the type `akka.NotUsed` is used—and a
|
||||
simple range of integers surely falls into this category.
|
||||
auxiliary information is produced, the type `akka.NotUsed` is used. A
|
||||
simple range of integers falls into this category - running our stream produces
|
||||
a `NotUsed`.
|
||||
|
||||
Having created this source means that we have a description of how to emit the
|
||||
first 100 natural numbers, but this source is not yet active. In order to get
|
||||
|
|
@ -84,24 +86,6 @@ Scala
|
|||
Java
|
||||
: @@snip [QuickStartDocTest.java](/akka-docs/src/test/java/jdocs/stream/QuickStartDocTest.java) { #run-source-and-terminate }
|
||||
|
||||
You may wonder where the Actor gets created that runs the stream, and you are
|
||||
probably also asking yourself what this `materializer` means. In order to get
|
||||
this value we first need to create an Actor system:
|
||||
|
||||
Scala
|
||||
: @@snip [QuickStartDocSpec.scala](/akka-docs/src/test/scala/docs/stream/QuickStartDocSpec.scala) { #create-materializer }
|
||||
|
||||
Java
|
||||
: @@snip [QuickStartDocTest.java](/akka-docs/src/test/java/jdocs/stream/QuickStartDocTest.java) { #create-materializer }
|
||||
|
||||
There are other ways to create a materializer, e.g. from an
|
||||
`ActorContext` when using streams from within Actors. The
|
||||
`Materializer` is a factory for stream execution engines, it is the
|
||||
thing that makes streams run—you don’t need to worry about any of the details
|
||||
right now apart from that you need one for calling any of the `run` methods on
|
||||
a `Source`. @scala[The materializer is picked up implicitly if it is omitted
|
||||
from the `run` method call arguments, which we will do in the following.]
|
||||
|
||||
The nice thing about Akka Streams is that the `Source` is a
|
||||
description of what you want to run, and like an architect’s blueprint it can
|
||||
be reused, incorporated into a larger design. We may choose to transform the
|
||||
|
|
@ -129,6 +113,8 @@ whether the stream terminated normally or exceptionally.
|
|||
|
||||
### Browser-embedded example
|
||||
|
||||
FIXME: fiddle won't work until Akka 2.6 is released and fiddle updated with that [#27510](https://github.com/akka/akka/issues/27510)
|
||||
|
||||
<a name="here-is-another-example-that-you-can-edit-and-run-in-the-browser-"></a>
|
||||
Here is another example that you can edit and run in the browser:
|
||||
|
||||
|
|
@ -243,14 +229,13 @@ sections of the docs, and then come back to this quickstart to see it all pieced
|
|||
The example application we will be looking at is a simple Twitter feed stream from which we'll want to extract certain information,
|
||||
like for example finding all twitter handles of users who tweet about `#akka`.
|
||||
|
||||
In order to prepare our environment by creating an `ActorSystem` and `ActorMaterializer`,
|
||||
which will be responsible for materializing and running the streams we are about to create:
|
||||
In order to prepare our environment by creating an `ActorSystem` which will be responsible for running the streams we are about to create:
|
||||
|
||||
Scala
|
||||
: @@snip [TwitterStreamQuickstartDocSpec.scala](/akka-docs/src/test/scala/docs/stream/TwitterStreamQuickstartDocSpec.scala) { #materializer-setup }
|
||||
: @@snip [TwitterStreamQuickstartDocSpec.scala](/akka-docs/src/test/scala/docs/stream/TwitterStreamQuickstartDocSpec.scala) { #system-setup }
|
||||
|
||||
Java
|
||||
: @@snip [TwitterStreamQuickstartDocTest.java](/akka-docs/src/test/java/jdocs/stream/TwitterStreamQuickstartDocTest.java) { #materializer-setup }
|
||||
: @@snip [TwitterStreamQuickstartDocTest.java](/akka-docs/src/test/java/jdocs/stream/TwitterStreamQuickstartDocTest.java) { #system-setup }
|
||||
|
||||
The `ActorMaterializer` can optionally take `ActorMaterializerSettings` which can be used to define
|
||||
materialization properties, such as default buffer sizes (see also @ref:[Buffers for asynchronous operators](stream-rate.md#async-stream-buffers)), the dispatcher to
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import java.util.concurrent.TimeUnit;
|
|||
public class PersistenceQueryDocTest {
|
||||
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
|
||||
public
|
||||
// #advanced-journal-query-types
|
||||
|
|
@ -217,8 +216,7 @@ public class PersistenceQueryDocTest {
|
|||
readJournal.eventsByPersistenceId("user-1337", 0, Long.MAX_VALUE);
|
||||
|
||||
// materialize stream, consuming events
|
||||
ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
source.runForeach(event -> System.out.println("Event: " + event), mat);
|
||||
source.runForeach(event -> System.out.println("Event: " + event), system);
|
||||
// #basic-usage
|
||||
}
|
||||
|
||||
|
|
@ -261,7 +259,6 @@ public class PersistenceQueryDocTest {
|
|||
|
||||
void demonstrateEventsByTag() {
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
|
||||
final MyJavadslReadJournal readJournal =
|
||||
PersistenceQuery.get(system)
|
||||
|
|
@ -284,7 +281,7 @@ public class PersistenceQueryDocTest {
|
|||
acc.add(e);
|
||||
return acc;
|
||||
},
|
||||
mat);
|
||||
system);
|
||||
|
||||
// start another query, from the known offset
|
||||
Source<EventEnvelope, NotUsed> blue = readJournal.eventsByTag("blue", new Sequence(10));
|
||||
|
|
@ -293,7 +290,6 @@ public class PersistenceQueryDocTest {
|
|||
|
||||
void demonstrateMaterializedQueryValues() {
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
|
||||
final MyJavadslReadJournal readJournal =
|
||||
PersistenceQuery.get(system)
|
||||
|
|
@ -326,7 +322,7 @@ public class PersistenceQueryDocTest {
|
|||
System.out.println("Event payload: " + event.payload);
|
||||
return event.payload;
|
||||
})
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
|
||||
// #advanced-journal-query-usage
|
||||
}
|
||||
|
|
@ -339,7 +335,6 @@ public class PersistenceQueryDocTest {
|
|||
|
||||
void demonstrateWritingIntoDifferentStore() {
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
|
||||
final MyJavadslReadJournal readJournal =
|
||||
PersistenceQuery.get(system)
|
||||
|
|
@ -355,7 +350,7 @@ public class PersistenceQueryDocTest {
|
|||
.eventsByPersistenceId("user-1337", 0L, Long.MAX_VALUE)
|
||||
.map(envelope -> envelope.event())
|
||||
.grouped(20) // batch inserts into groups of 20
|
||||
.runWith(Sink.fromSubscriber(dbBatchWriter), mat); // write batches to read-side database
|
||||
.runWith(Sink.fromSubscriber(dbBatchWriter), system); // write batches to read-side database
|
||||
// #projection-into-different-store-rs
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +367,6 @@ public class PersistenceQueryDocTest {
|
|||
|
||||
void demonstrateWritingIntoDifferentStoreWithMapAsync() {
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
|
||||
final MyJavadslReadJournal readJournal =
|
||||
PersistenceQuery.get(system)
|
||||
|
|
@ -385,7 +379,7 @@ public class PersistenceQueryDocTest {
|
|||
readJournal
|
||||
.eventsByTag("bid", new Sequence(0L))
|
||||
.mapAsync(1, store::save)
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #projection-into-different-store-simple
|
||||
}
|
||||
|
||||
|
|
@ -415,7 +409,6 @@ public class PersistenceQueryDocTest {
|
|||
|
||||
void demonstrateWritingIntoDifferentStoreWithResumableProjections() throws Exception {
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
|
||||
final MyJavadslReadJournal readJournal =
|
||||
PersistenceQuery.get(system)
|
||||
|
|
@ -442,7 +435,7 @@ public class PersistenceQueryDocTest {
|
|||
return f.thenApplyAsync(in -> envelope.offset(), system.dispatcher());
|
||||
})
|
||||
.mapAsync(1, offset -> bidProjection.saveProgress(offset))
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
}
|
||||
|
||||
// #projection-into-different-store-actor-run
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import akka.persistence.query.EventEnvelope;
|
|||
import akka.persistence.query.Sequence;
|
||||
import akka.persistence.query.PersistenceQuery;
|
||||
import akka.persistence.query.journal.leveldb.javadsl.LeveldbReadJournal;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.javadsl.Source;
|
||||
|
||||
public class LeveldbPersistenceQueryDocTest {
|
||||
|
|
@ -24,8 +23,6 @@ public class LeveldbPersistenceQueryDocTest {
|
|||
|
||||
public void demonstrateReadJournal() {
|
||||
// #get-read-journal
|
||||
final ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
|
||||
LeveldbReadJournal queries =
|
||||
PersistenceQuery.get(system)
|
||||
.getReadJournalFor(LeveldbReadJournal.class, LeveldbReadJournal.Identifier());
|
||||
|
|
|
|||
|
|
@ -32,19 +32,16 @@ import static org.junit.Assert.assertArrayEquals;
|
|||
public class BidiFlowDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("FlowDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
// #codec
|
||||
|
|
@ -261,7 +258,7 @@ public class BidiFlowDocTest extends AbstractJavaTest {
|
|||
.<Message>map(id -> new Ping(id))
|
||||
.via(flow)
|
||||
.grouped(10)
|
||||
.runWith(Sink.<List<Message>>head(), mat);
|
||||
.runWith(Sink.<List<Message>>head(), system);
|
||||
assertArrayEquals(
|
||||
new Message[] {new Pong(0), new Pong(1), new Pong(2)},
|
||||
result.toCompletableFuture().get(1, TimeUnit.SECONDS).toArray(new Message[0]));
|
||||
|
|
|
|||
|
|
@ -27,19 +27,16 @@ import akka.util.ByteString;
|
|||
public class CompositionDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("CompositionDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -33,19 +33,16 @@ import static org.junit.Assert.assertEquals;
|
|||
public class FlowDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("FlowDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -54,16 +51,16 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
final Source<Integer, NotUsed> source =
|
||||
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
source.map(x -> 0); // has no effect on source, since it's immutable
|
||||
source.runWith(Sink.fold(0, (agg, next) -> agg + next), mat); // 55
|
||||
source.runWith(Sink.fold(0, (agg, next) -> agg + next), system); // 55
|
||||
|
||||
// returns new Source<Integer>, with `map()` appended
|
||||
final Source<Integer, NotUsed> zeroes = source.map(x -> 0);
|
||||
final Sink<Integer, CompletionStage<Integer>> fold =
|
||||
Sink.<Integer, Integer>fold(0, (agg, next) -> agg + next);
|
||||
zeroes.runWith(fold, mat); // 0
|
||||
zeroes.runWith(fold, system); // 0
|
||||
// #source-immutable
|
||||
|
||||
int result = zeroes.runWith(fold, mat).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
int result = zeroes.runWith(fold, system).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(0, result);
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +77,7 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
final RunnableGraph<CompletionStage<Integer>> runnable = source.toMat(sink, Keep.right());
|
||||
|
||||
// materialize the flow
|
||||
final CompletionStage<Integer> sum = runnable.run(mat);
|
||||
final CompletionStage<Integer> sum = runnable.run(system);
|
||||
// #materialization-in-steps
|
||||
|
||||
int result = sum.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
|
@ -96,7 +93,7 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
Sink.<Integer, Integer>fold(0, (aggr, next) -> aggr + next);
|
||||
|
||||
// materialize the flow, getting the Sinks materialized value
|
||||
final CompletionStage<Integer> sum = source.runWith(sink, mat);
|
||||
final CompletionStage<Integer> sum = source.runWith(sink, system);
|
||||
// #materialization-runWith
|
||||
|
||||
int result = sum.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
|
@ -113,8 +110,8 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)).toMat(sink, Keep.right());
|
||||
|
||||
// get the materialized value of the FoldSink
|
||||
final CompletionStage<Integer> sum1 = runnable.run(mat);
|
||||
final CompletionStage<Integer> sum2 = runnable.run(mat);
|
||||
final CompletionStage<Integer> sum1 = runnable.run(system);
|
||||
final CompletionStage<Integer> sum2 = runnable.run(system);
|
||||
|
||||
// sum1 and sum2 are different Futures!
|
||||
// #stream-reuse
|
||||
|
|
@ -135,7 +132,7 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
// akka.actor.Cancellable
|
||||
final Source<Object, Cancellable> timer = Source.tick(oneSecond, oneSecond, tick);
|
||||
|
||||
Sink.ignore().runWith(timer, mat);
|
||||
Sink.ignore().runWith(timer, system);
|
||||
|
||||
final Source<String, Cancellable> timerMap = timer.map(t -> "tick");
|
||||
// WRONG: returned type is not the timers Cancellable!
|
||||
|
|
@ -144,7 +141,7 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
|
||||
// #compound-source-is-not-keyed-run
|
||||
// retain the materialized map, in order to retrieve the timer's Cancellable
|
||||
final Cancellable timerCancellable = timer.to(Sink.ignore()).run(mat);
|
||||
final Cancellable timerCancellable = timer.to(Sink.ignore()).run(system);
|
||||
timerCancellable.cancel();
|
||||
// #compound-source-is-not-keyed-run
|
||||
}
|
||||
|
|
@ -239,10 +236,10 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
|
||||
// Using runWith will always give the materialized values of the stages added
|
||||
// by runWith() itself
|
||||
CompletionStage<Integer> r4 = source.via(flow).runWith(sink, mat);
|
||||
CompletableFuture<Optional<Integer>> r5 = flow.to(sink).runWith(source, mat);
|
||||
CompletionStage<Integer> r4 = source.via(flow).runWith(sink, system);
|
||||
CompletableFuture<Optional<Integer>> r5 = flow.to(sink).runWith(source, system);
|
||||
Pair<CompletableFuture<Optional<Integer>>, CompletionStage<Integer>> r6 =
|
||||
flow.runWith(source, sink, mat);
|
||||
flow.runWith(source, sink, system);
|
||||
|
||||
// Using more complex combinations
|
||||
RunnableGraph<Pair<CompletableFuture<Optional<Integer>>, Cancellable>> r7 =
|
||||
|
|
@ -280,12 +277,12 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
Source<String, ActorRef> matValuePoweredSource = Source.actorRef(100, OverflowStrategy.fail());
|
||||
|
||||
Pair<ActorRef, Source<String, NotUsed>> actorRefSourcePair =
|
||||
matValuePoweredSource.preMaterialize(mat);
|
||||
matValuePoweredSource.preMaterialize(system);
|
||||
|
||||
actorRefSourcePair.first().tell("Hello!", ActorRef.noSender());
|
||||
|
||||
// pass source around for materialization
|
||||
actorRefSourcePair.second().runWith(Sink.foreach(System.out::println), mat);
|
||||
actorRefSourcePair.second().runWith(Sink.foreach(System.out::println), system);
|
||||
// #source-prematerialization
|
||||
}
|
||||
|
||||
|
|
@ -295,15 +292,6 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
// #flow-async
|
||||
}
|
||||
|
||||
static {
|
||||
// #materializer-from-system
|
||||
ActorSystem system = ActorSystem.create("ExampleSystem");
|
||||
|
||||
// created from `system`:
|
||||
ActorMaterializer mat = ActorMaterializer.create(system);
|
||||
// #materializer-from-system
|
||||
}
|
||||
|
||||
// #materializer-from-actor-context
|
||||
final class RunWithMyself extends AbstractActor {
|
||||
|
||||
|
|
@ -336,10 +324,11 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
|
||||
// #materializer-from-system-in-actor
|
||||
final class RunForever extends AbstractActor {
|
||||
final ActorMaterializer mat;
|
||||
|
||||
RunForever(ActorMaterializer mat) {
|
||||
this.mat = mat;
|
||||
private final Materializer materializer;
|
||||
|
||||
public RunForever(Materializer materializer) {
|
||||
this.materializer = materializer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -350,7 +339,7 @@ public class FlowDocTest extends AbstractJavaTest {
|
|||
tryDone -> {
|
||||
System.out.println("Terminated stream: " + tryDone);
|
||||
}),
|
||||
mat);
|
||||
materializer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.ActorMaterializerSettings;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.Supervision;
|
||||
import akka.stream.javadsl.Flow;
|
||||
|
|
@ -48,14 +46,13 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
@Test(expected = ExecutionException.class)
|
||||
public void demonstrateFailStream() throws Exception {
|
||||
// #stop
|
||||
final Materializer mat = ActorMaterializer.create(system);
|
||||
final Source<Integer, NotUsed> source =
|
||||
Source.from(Arrays.asList(0, 1, 2, 3, 4, 5)).map(elem -> 100 / elem);
|
||||
final Sink<Integer, CompletionStage<Integer>> fold =
|
||||
Sink.<Integer, Integer>fold(0, (acc, elem) -> acc + elem);
|
||||
final CompletionStage<Integer> result = source.runWith(fold, mat);
|
||||
final CompletionStage<Integer> result = source.runWith(fold, system);
|
||||
// division by zero will fail the stream and the
|
||||
// result here will be a Future completed with Failure(ArithmeticException)
|
||||
// result here will be a CompletionStage failed with ArithmeticException
|
||||
// #stop
|
||||
|
||||
result.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
|
@ -69,15 +66,14 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
if (exc instanceof ArithmeticException) return Supervision.resume();
|
||||
else return Supervision.stop();
|
||||
};
|
||||
final Materializer mat =
|
||||
ActorMaterializer.create(
|
||||
ActorMaterializerSettings.create(system).withSupervisionStrategy(decider), system);
|
||||
final Source<Integer, NotUsed> source =
|
||||
Source.from(Arrays.asList(0, 1, 2, 3, 4, 5)).map(elem -> 100 / elem);
|
||||
Source.from(Arrays.asList(0, 1, 2, 3, 4, 5))
|
||||
.map(elem -> 100 / elem)
|
||||
.withAttributes(ActorAttributes.withSupervisionStrategy(decider));
|
||||
final Sink<Integer, CompletionStage<Integer>> fold = Sink.fold(0, (acc, elem) -> acc + elem);
|
||||
final CompletionStage<Integer> result = source.runWith(fold, mat);
|
||||
final CompletionStage<Integer> result = source.runWith(fold, system);
|
||||
// the element causing division by zero will be dropped
|
||||
// result here will be a Future completed with Success(228)
|
||||
// result here will be a CompletionStage completed with 228
|
||||
// #resume
|
||||
|
||||
assertEquals(Integer.valueOf(228), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
|
|
@ -86,7 +82,6 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
@Test
|
||||
public void demonstrateResumeSectionStream() throws Exception {
|
||||
// #resume-section
|
||||
final Materializer mat = ActorMaterializer.create(system);
|
||||
final Function<Throwable, Supervision.Directive> decider =
|
||||
exc -> {
|
||||
if (exc instanceof ArithmeticException) return Supervision.resume();
|
||||
|
|
@ -100,9 +95,9 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
final Source<Integer, NotUsed> source = Source.from(Arrays.asList(0, 1, 2, 3, 4, 5)).via(flow);
|
||||
final Sink<Integer, CompletionStage<Integer>> fold =
|
||||
Sink.<Integer, Integer>fold(0, (acc, elem) -> acc + elem);
|
||||
final CompletionStage<Integer> result = source.runWith(fold, mat);
|
||||
final CompletionStage<Integer> result = source.runWith(fold, system);
|
||||
// the elements causing division by zero will be dropped
|
||||
// result here will be a Future completed with Success(150)
|
||||
// result here will be a Future completed with 150
|
||||
// #resume-section
|
||||
|
||||
assertEquals(Integer.valueOf(150), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
|
|
@ -111,7 +106,6 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
@Test
|
||||
public void demonstrateRestartSectionStream() throws Exception {
|
||||
// #restart-section
|
||||
final Materializer mat = ActorMaterializer.create(system);
|
||||
final Function<Throwable, Supervision.Directive> decider =
|
||||
exc -> {
|
||||
if (exc instanceof IllegalArgumentException) return Supervision.restart();
|
||||
|
|
@ -128,10 +122,10 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
.withAttributes(ActorAttributes.withSupervisionStrategy(decider));
|
||||
final Source<Integer, NotUsed> source = Source.from(Arrays.asList(1, 3, -1, 5, 7)).via(flow);
|
||||
final CompletionStage<List<Integer>> result =
|
||||
source.grouped(1000).runWith(Sink.<List<Integer>>head(), mat);
|
||||
source.grouped(1000).runWith(Sink.<List<Integer>>head(), system);
|
||||
// the negative element cause the scan stage to be restarted,
|
||||
// i.e. start from 0 again
|
||||
// result here will be a Future completed with Success(List(0, 1, 4, 0, 5, 12))
|
||||
// result here will be a Future completed with List(0, 1, 4, 0, 5, 12)
|
||||
// #restart-section
|
||||
|
||||
assertEquals(
|
||||
|
|
@ -141,7 +135,6 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
@Test
|
||||
public void demonstrateRecover() {
|
||||
// #recover
|
||||
final Materializer mat = ActorMaterializer.create(system);
|
||||
Source.from(Arrays.asList(0, 1, 2, 3, 4, 5, 6))
|
||||
.map(
|
||||
n -> {
|
||||
|
|
@ -149,7 +142,7 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
else throw new RuntimeException("Boom!");
|
||||
})
|
||||
.recover(new PFBuilder().match(RuntimeException.class, ex -> "stream truncated").build())
|
||||
.runForeach(System.out::println, mat);
|
||||
.runForeach(System.out::println, system);
|
||||
// #recover
|
||||
|
||||
/*
|
||||
|
|
@ -168,7 +161,6 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
@Test
|
||||
public void demonstrateRecoverWithRetries() {
|
||||
// #recoverWithRetries
|
||||
final Materializer mat = ActorMaterializer.create(system);
|
||||
Source<String, NotUsed> planB = Source.from(Arrays.asList("five", "six", "seven", "eight"));
|
||||
|
||||
Source.from(Arrays.asList(0, 1, 2, 3, 4, 5, 6))
|
||||
|
|
@ -180,7 +172,7 @@ public class FlowErrorDocTest extends AbstractJavaTest {
|
|||
.recoverWithRetries(
|
||||
1, // max attempts
|
||||
new PFBuilder().match(RuntimeException.class, ex -> planB).build())
|
||||
.runForeach(System.out::println, mat);
|
||||
.runForeach(System.out::println, system);
|
||||
// #recoverWithRetries
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -19,19 +19,16 @@ import akka.stream.javadsl.*;
|
|||
public class FlowParallelismDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("FlowParallellismDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
static class ScoopOfBatter {}
|
||||
|
|
|
|||
|
|
@ -21,19 +21,16 @@ import akka.stream.scaladsl.MergePreferred.MergePreferredShape;
|
|||
public class GraphCyclesDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("GraphCyclesDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
static final SilenceSystemOut.System System = SilenceSystemOut.get();
|
||||
|
|
|
|||
|
|
@ -36,19 +36,16 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class GraphStageDocTest extends AbstractJavaTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("GraphStageDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
// #simple-source
|
||||
|
|
@ -139,11 +136,12 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
Source<Integer, NotUsed> mySource = Source.fromGraph(sourceGraph);
|
||||
|
||||
// Returns 55
|
||||
CompletionStage<Integer> result1 = mySource.take(10).runFold(0, (sum, next) -> sum + next, mat);
|
||||
CompletionStage<Integer> result1 =
|
||||
mySource.take(10).runFold(0, (sum, next) -> sum + next, system);
|
||||
|
||||
// The source is reusable. This returns 5050
|
||||
CompletionStage<Integer> result2 =
|
||||
mySource.take(100).runFold(0, (sum, next) -> sum + next, mat);
|
||||
mySource.take(100).runFold(0, (sum, next) -> sum + next, system);
|
||||
// #simple-source-usage
|
||||
|
||||
assertEquals(result1.toCompletableFuture().get(3, TimeUnit.SECONDS), (Integer) 55);
|
||||
|
|
@ -156,7 +154,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
|
||||
Sink<Integer, NotUsed> mySink = Sink.fromGraph(sinkGraph);
|
||||
|
||||
Source.from(Arrays.asList(1, 2, 3)).runWith(mySink, mat);
|
||||
Source.from(Arrays.asList(1, 2, 3)).runWith(mySink, system);
|
||||
}
|
||||
|
||||
// #one-to-one
|
||||
|
|
@ -221,7 +219,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
CompletionStage<Integer> result =
|
||||
Source.from(Arrays.asList("one", "two", "three"))
|
||||
.via(stringLength)
|
||||
.runFold(0, (sum, n) -> sum + n, mat);
|
||||
.runFold(0, (sum, n) -> sum + n, system);
|
||||
|
||||
assertEquals(new Integer(11), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -286,7 +284,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
CompletionStage<Integer> result =
|
||||
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6))
|
||||
.via(evenFilter)
|
||||
.runFold(0, (elem, sum) -> sum + elem, mat);
|
||||
.runFold(0, (elem, sum) -> sum + elem, system);
|
||||
|
||||
assertEquals(new Integer(12), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -356,7 +354,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
Flow.fromGraph(new Duplicator<Integer>());
|
||||
|
||||
CompletionStage<Integer> result =
|
||||
Source.from(Arrays.asList(1, 2, 3)).via(duplicator).runFold(0, (n, sum) -> n + sum, mat);
|
||||
Source.from(Arrays.asList(1, 2, 3)).via(duplicator).runFold(0, (n, sum) -> n + sum, system);
|
||||
|
||||
assertEquals(new Integer(12), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -412,7 +410,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
Flow.fromGraph(new Duplicator2<Integer>());
|
||||
|
||||
CompletionStage<Integer> result =
|
||||
Source.from(Arrays.asList(1, 2, 3)).via(duplicator).runFold(0, (n, sum) -> n + sum, mat);
|
||||
Source.from(Arrays.asList(1, 2, 3)).via(duplicator).runFold(0, (n, sum) -> n + sum, system);
|
||||
|
||||
assertEquals(new Integer(12), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -428,7 +426,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
.via(new Filter<Integer>((n) -> n % 2 == 0))
|
||||
.via(new Duplicator<Integer>())
|
||||
.via(new Map<Integer, Integer>((n) -> n / 2))
|
||||
.runWith(sink, mat);
|
||||
.runWith(sink, system);
|
||||
|
||||
// #graph-operator-chain
|
||||
|
||||
|
|
@ -509,7 +507,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
Graph<FlowShape<Integer, Integer>, NotUsed> killSwitch =
|
||||
Flow.fromGraph(new KillSwitch<>(switchF));
|
||||
|
||||
Source.fromPublisher(in).via(killSwitch).to(Sink.fromSubscriber(out)).run(mat);
|
||||
Source.fromPublisher(in).via(killSwitch).to(Sink.fromSubscriber(out)).run(system);
|
||||
|
||||
out.request(1);
|
||||
in.sendNext(1);
|
||||
|
|
@ -588,7 +586,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
Source.from(Arrays.asList(1, 2, 3))
|
||||
.via(new TimedGate<>(2))
|
||||
.takeWithin(java.time.Duration.ofMillis(250))
|
||||
.runFold(0, (n, sum) -> n + sum, mat);
|
||||
.runFold(0, (n, sum) -> n + sum, system);
|
||||
|
||||
assertEquals(new Integer(1), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -659,7 +657,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
.viaMat(new FirstValue(), Keep.right())
|
||||
.to(Sink.ignore());
|
||||
|
||||
CompletionStage<Integer> result = flow.run(mat);
|
||||
CompletionStage<Integer> result = flow.run(system);
|
||||
|
||||
assertEquals(new Integer(1), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -751,7 +749,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
CompletionStage<Integer> result1 =
|
||||
Source.from(Arrays.asList(1, 2, 3))
|
||||
.via(new TwoBuffer<>())
|
||||
.runFold(0, (acc, n) -> acc + n, mat);
|
||||
.runFold(0, (acc, n) -> acc + n, system);
|
||||
|
||||
assertEquals(new Integer(6), result1.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
|
||||
|
|
@ -760,7 +758,7 @@ public class GraphStageDocTest extends AbstractJavaTest {
|
|||
RunnableGraph<NotUsed> flow2 =
|
||||
Source.fromPublisher(publisher).via(new TwoBuffer<>()).to(Sink.fromSubscriber(subscriber));
|
||||
|
||||
flow2.run(mat);
|
||||
flow2.run(system);
|
||||
|
||||
Subscription sub = subscriber.expectSubscription();
|
||||
// this happens even though the subscriber has not signalled any demand
|
||||
|
|
|
|||
|
|
@ -26,19 +26,16 @@ import java.util.function.ToLongBiFunction;
|
|||
public class HubDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer materializer;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("GraphDSLDocTest");
|
||||
materializer = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
materializer = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -55,10 +52,10 @@ public class HubDocTest extends AbstractJavaTest {
|
|||
// now have access to feed elements into it. This Sink can be materialized
|
||||
// any number of times, and every element that enters the Sink will
|
||||
// be consumed by our consumer.
|
||||
Sink<String, NotUsed> toConsumer = runnableGraph.run(materializer);
|
||||
Sink<String, NotUsed> toConsumer = runnableGraph.run(system);
|
||||
|
||||
Source.single("Hello!").runWith(toConsumer, materializer);
|
||||
Source.single("Hub!").runWith(toConsumer, materializer);
|
||||
Source.single("Hello!").runWith(toConsumer, system);
|
||||
Source.single("Hub!").runWith(toConsumer, system);
|
||||
// #merge-hub
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +96,7 @@ public class HubDocTest extends AbstractJavaTest {
|
|||
Pair<Sink<String, NotUsed>, Source<String, NotUsed>> sinkAndSource =
|
||||
MergeHub.of(String.class, 16)
|
||||
.toMat(BroadcastHub.of(String.class, 256), Keep.both())
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
|
||||
Sink<String, NotUsed> sink = sinkAndSource.first();
|
||||
Source<String, NotUsed> source = sinkAndSource.second();
|
||||
|
|
@ -109,7 +106,7 @@ public class HubDocTest extends AbstractJavaTest {
|
|||
// Ensure that the Broadcast output is dropped if there are no listening parties.
|
||||
// If this dropping Sink is not attached, then the broadcast hub will not drop any
|
||||
// elements itself when there are no subscribers, backpressuring the producer instead.
|
||||
source.runWith(Sink.ignore(), materializer);
|
||||
source.runWith(Sink.ignore(), system);
|
||||
// #pub-sub-2
|
||||
|
||||
// #pub-sub-3
|
||||
|
|
@ -127,7 +124,7 @@ public class HubDocTest extends AbstractJavaTest {
|
|||
Source.repeat("Hello World!")
|
||||
.viaMat(busFlow, Keep.right())
|
||||
.to(Sink.foreach(System.out::println))
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
|
||||
// Shut down externally
|
||||
killSwitch.shutdown();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
private static final SilenceSystemOut.System System = SilenceSystemOut.get();
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
static ActorRef ref;
|
||||
|
||||
@BeforeClass
|
||||
|
|
@ -61,7 +60,6 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
+ "akka.actor.default-mailbox.mailbox-type = akka.dispatch.UnboundedMailbox\n");
|
||||
|
||||
system = ActorSystem.create("ActorPublisherDocTest", config);
|
||||
mat = ActorMaterializer.create(system);
|
||||
ref = system.actorOf(Props.create(Translator.class));
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +67,6 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
ref = null;
|
||||
}
|
||||
|
||||
|
|
@ -397,7 +394,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
.ask(5, ref, String.class, askTimeout)
|
||||
// continue processing of the replies from the actor
|
||||
.map(elem -> elem.toLowerCase())
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #ask
|
||||
}
|
||||
|
||||
|
|
@ -418,7 +415,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
new StreamCompleted(),
|
||||
ex -> new StreamFailure(ex));
|
||||
|
||||
words.map(el -> el.toLowerCase()).runWith(sink, mat);
|
||||
words.map(el -> el.toLowerCase()).runWith(sink, system);
|
||||
|
||||
probe.expectMsg("Stream initialized");
|
||||
probe.expectMsg("hello");
|
||||
|
|
@ -457,7 +454,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
4, address -> emailServer.send(new Email(address, "Akka", "I like your tweet")))
|
||||
.to(Sink.ignore());
|
||||
|
||||
sendEmails.run(mat);
|
||||
sendEmails.run(system);
|
||||
// #send-emails
|
||||
|
||||
probe.expectMsg("rolandkuhn@somewhere.com");
|
||||
|
|
@ -519,7 +516,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
4, address -> emailServer.send(new Email(address, "Akka", "I like your tweet")))
|
||||
.to(Sink.ignore());
|
||||
|
||||
sendEmails.run(mat);
|
||||
sendEmails.run(system);
|
||||
// #external-service-mapAsyncUnordered
|
||||
}
|
||||
};
|
||||
|
|
@ -555,7 +552,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
blockingEc))
|
||||
.to(Sink.ignore());
|
||||
|
||||
sendTextMessages.run(mat);
|
||||
sendTextMessages.run(system);
|
||||
// #blocking-mapAsync
|
||||
|
||||
final List<Object> got = receiveN(7);
|
||||
|
|
@ -597,7 +594,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
.withAttributes(ActorAttributes.dispatcher("blocking-dispatcher"));
|
||||
final RunnableGraph<?> sendTextMessages = phoneNumbers.via(send).to(Sink.ignore());
|
||||
|
||||
sendTextMessages.run(mat);
|
||||
sendTextMessages.run(system);
|
||||
// #blocking-map
|
||||
|
||||
probe.expectMsg(String.valueOf("rolandkuhn".hashCode()));
|
||||
|
|
@ -630,7 +627,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
.to(Sink.ignore());
|
||||
// #save-tweets
|
||||
|
||||
saveTweets.run(mat);
|
||||
saveTweets.run(system);
|
||||
|
||||
probe.expectMsg("rolandkuhn");
|
||||
probe.expectMsg("patriknw");
|
||||
|
|
@ -677,7 +674,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
return elem;
|
||||
})
|
||||
.mapAsync(4, service::convert)
|
||||
.runForeach(elem -> System.out.println("after: " + elem), mat);
|
||||
.runForeach(elem -> System.out.println("after: " + elem), system);
|
||||
// #sometimes-slow-mapAsync
|
||||
|
||||
probe.expectMsg("after: A");
|
||||
|
|
@ -716,10 +713,6 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
final Executor blockingEc = system.dispatchers().lookup("blocking-dispatcher");
|
||||
final SometimesSlowService service = new SometimesSlowService(blockingEc);
|
||||
|
||||
final ActorMaterializer mat =
|
||||
ActorMaterializer.create(
|
||||
ActorMaterializerSettings.create(system).withInputBuffer(4, 4), system);
|
||||
|
||||
Source.from(Arrays.asList("a", "B", "C", "D", "e", "F", "g", "H", "i", "J"))
|
||||
.map(
|
||||
elem -> {
|
||||
|
|
@ -727,7 +720,9 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
return elem;
|
||||
})
|
||||
.mapAsyncUnordered(4, service::convert)
|
||||
.runForeach(elem -> System.out.println("after: " + elem), mat);
|
||||
.to(Sink.foreach(elem -> System.out.println("after: " + elem)))
|
||||
.withAttributes(Attributes.inputBuffer(4, 4))
|
||||
.run(system);
|
||||
// #sometimes-slow-mapAsyncUnordered
|
||||
|
||||
final List<Object> got = receiveN(10);
|
||||
|
|
@ -760,11 +755,11 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
.throttle(elementsToProcess, Duration.ofSeconds(3))
|
||||
.map(x -> x * x)
|
||||
.to(Sink.foreach(x -> System.out.println("got: " + x)))
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
Source<Integer, NotUsed> source = Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
|
||||
source.map(x -> sourceQueue.offer(x)).runWith(Sink.ignore(), mat);
|
||||
source.map(x -> sourceQueue.offer(x)).runWith(Sink.ignore(), system);
|
||||
|
||||
// #source-queue
|
||||
}
|
||||
|
|
@ -782,7 +777,10 @@ public class IntegrationDocTest extends AbstractJavaTest {
|
|||
Source.actorRef(
|
||||
bufferSize, OverflowStrategy.dropHead()); // note: backpressure is not supported
|
||||
ActorRef actorRef =
|
||||
source.map(x -> x * x).to(Sink.foreach(x -> System.out.println("got: " + x))).run(mat);
|
||||
source
|
||||
.map(x -> x * x)
|
||||
.to(Sink.foreach(x -> System.out.println("got: " + x)))
|
||||
.run(system);
|
||||
|
||||
actorRef.tell(1, ActorRef.noSender());
|
||||
actorRef.tell(2, ActorRef.noSender());
|
||||
|
|
|
|||
|
|
@ -29,19 +29,16 @@ import static org.junit.Assert.assertEquals;
|
|||
class KillSwitchDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("GraphDSLDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -58,7 +55,7 @@ class KillSwitchDocTest extends AbstractJavaTest {
|
|||
countingSrc
|
||||
.viaMat(KillSwitches.single(), Keep.right())
|
||||
.toMat(lastSnk, Keep.both())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
final UniqueKillSwitch killSwitch = stream.first();
|
||||
final CompletionStage<Integer> completionStage = stream.second();
|
||||
|
|
@ -82,7 +79,7 @@ class KillSwitchDocTest extends AbstractJavaTest {
|
|||
countingSrc
|
||||
.viaMat(KillSwitches.single(), Keep.right())
|
||||
.toMat(lastSnk, Keep.both())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
final UniqueKillSwitch killSwitch = stream.first();
|
||||
final CompletionStage<Integer> completionStage = stream.second();
|
||||
|
|
@ -105,13 +102,16 @@ class KillSwitchDocTest extends AbstractJavaTest {
|
|||
final SharedKillSwitch killSwitch = KillSwitches.shared("my-kill-switch");
|
||||
|
||||
final CompletionStage<Integer> completionStage =
|
||||
countingSrc.viaMat(killSwitch.flow(), Keep.right()).toMat(lastSnk, Keep.right()).run(mat);
|
||||
countingSrc
|
||||
.viaMat(killSwitch.flow(), Keep.right())
|
||||
.toMat(lastSnk, Keep.right())
|
||||
.run(system);
|
||||
final CompletionStage<Integer> completionStageDelayed =
|
||||
countingSrc
|
||||
.delay(Duration.ofSeconds(1), DelayOverflowStrategy.backpressure())
|
||||
.viaMat(killSwitch.flow(), Keep.right())
|
||||
.toMat(lastSnk, Keep.right())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
doSomethingElse();
|
||||
killSwitch.shutdown();
|
||||
|
|
@ -134,9 +134,15 @@ class KillSwitchDocTest extends AbstractJavaTest {
|
|||
final SharedKillSwitch killSwitch = KillSwitches.shared("my-kill-switch");
|
||||
|
||||
final CompletionStage<Integer> completionStage1 =
|
||||
countingSrc.viaMat(killSwitch.flow(), Keep.right()).toMat(lastSnk, Keep.right()).run(mat);
|
||||
countingSrc
|
||||
.viaMat(killSwitch.flow(), Keep.right())
|
||||
.toMat(lastSnk, Keep.right())
|
||||
.run(system);
|
||||
final CompletionStage<Integer> completionStage2 =
|
||||
countingSrc.viaMat(killSwitch.flow(), Keep.right()).toMat(lastSnk, Keep.right()).run(mat);
|
||||
countingSrc
|
||||
.viaMat(killSwitch.flow(), Keep.right())
|
||||
.toMat(lastSnk, Keep.right())
|
||||
.run(system);
|
||||
|
||||
final Exception error = new Exception("boom!");
|
||||
killSwitch.abort(error);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@
|
|||
|
||||
package jdocs.stream;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
|
||||
// #main-app
|
||||
public class Main {
|
||||
public static void main(String[] argv) {
|
||||
final ActorSystem system = ActorSystem.create("QuickStart");
|
||||
// Code here
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,17 +34,14 @@ public class QuickStartDocTest extends AbstractJavaTest {
|
|||
|
||||
@Test
|
||||
public void demonstrateSource() throws InterruptedException, ExecutionException {
|
||||
// #create-materializer
|
||||
final ActorSystem system = ActorSystem.create("QuickStart");
|
||||
final Materializer materializer = ActorMaterializer.create(system);
|
||||
// #create-materializer
|
||||
|
||||
// #create-source
|
||||
final Source<Integer, NotUsed> source = Source.range(1, 100);
|
||||
// #create-source
|
||||
|
||||
// #run-source
|
||||
source.runForeach(i -> System.out.println(i), materializer);
|
||||
source.runForeach(i -> System.out.println(i), system);
|
||||
// #run-source
|
||||
|
||||
// #transform-source
|
||||
|
|
@ -54,11 +51,11 @@ public class QuickStartDocTest extends AbstractJavaTest {
|
|||
final CompletionStage<IOResult> result =
|
||||
factorials
|
||||
.map(num -> ByteString.fromString(num.toString() + "\n"))
|
||||
.runWith(FileIO.toPath(Paths.get("factorials.txt")), materializer);
|
||||
.runWith(FileIO.toPath(Paths.get("factorials.txt")), system);
|
||||
// #transform-source
|
||||
|
||||
// #use-transformed-sink
|
||||
factorials.map(BigInteger::toString).runWith(lineSink("factorial2.txt"), materializer);
|
||||
factorials.map(BigInteger::toString).runWith(lineSink("factorial2.txt"), system);
|
||||
// #use-transformed-sink
|
||||
|
||||
// #add-streams
|
||||
|
|
@ -68,11 +65,11 @@ public class QuickStartDocTest extends AbstractJavaTest {
|
|||
// #add-streams
|
||||
.take(2)
|
||||
// #add-streams
|
||||
.runForeach(s -> System.out.println(s), materializer);
|
||||
.runForeach(s -> System.out.println(s), system);
|
||||
// #add-streams
|
||||
|
||||
// #run-source-and-terminate
|
||||
final CompletionStage<Done> done = source.runForeach(i -> System.out.println(i), materializer);
|
||||
final CompletionStage<Done> done = source.runForeach(i -> System.out.println(i), system);
|
||||
|
||||
done.thenRun(() -> system.terminate());
|
||||
// #run-source-and-terminate
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ import akka.NotUsed;
|
|||
import akka.actor.ActorSystem;
|
||||
import akka.japi.Pair;
|
||||
import akka.japi.tuple.Tuple3;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Flow;
|
||||
import akka.stream.javadsl.Keep;
|
||||
import akka.stream.javadsl.Sink;
|
||||
|
|
@ -42,19 +40,16 @@ import static org.junit.Assert.assertEquals;
|
|||
public class RateTransformationDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RateTransformationDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
final Random r = new Random();
|
||||
|
|
@ -84,7 +79,7 @@ public class RateTransformationDocTest extends AbstractJavaTest {
|
|||
.map(i -> r.nextGaussian())
|
||||
.via(statsFlow)
|
||||
.grouped(10)
|
||||
.runWith(Sink.head(), mat);
|
||||
.runWith(Sink.head(), system);
|
||||
|
||||
fut.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
|
@ -110,7 +105,7 @@ public class RateTransformationDocTest extends AbstractJavaTest {
|
|||
final CompletionStage<Double> fut =
|
||||
Source.from(new ArrayList<Double>(Collections.nCopies(1000, 1.0)))
|
||||
.via(sampleFlow)
|
||||
.runWith(Sink.fold(0.0, (agg, next) -> agg + next), mat);
|
||||
.runWith(Sink.fold(0.0, (agg, next) -> agg + next), system);
|
||||
|
||||
final Double count = fut.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
|
@ -127,7 +122,7 @@ public class RateTransformationDocTest extends AbstractJavaTest {
|
|||
.via(lastFlow)
|
||||
.grouped(10)
|
||||
.toMat(Sink.head(), Keep.both())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
final TestPublisher.Probe<Double> probe = probeFut.first();
|
||||
final CompletionStage<List<Double>> fut = probeFut.second();
|
||||
|
|
@ -150,7 +145,7 @@ public class RateTransformationDocTest extends AbstractJavaTest {
|
|||
.via(lastFlow)
|
||||
.grouped(10)
|
||||
.toMat(Sink.head(), Keep.right())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
final List<Double> extrapolated = fut.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
assertEquals(extrapolated.size(), 10);
|
||||
|
|
@ -187,7 +182,7 @@ public class RateTransformationDocTest extends AbstractJavaTest {
|
|||
TestSource.<Double>probe(system)
|
||||
.via(realDriftFlow)
|
||||
.toMat(TestSink.<Pair<Double, Integer>>probe(system), Keep.both())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
final TestPublisher.Probe<Double> pub = pubSub.first();
|
||||
final TestSubscriber.Probe<Pair<Double, Integer>> sub = pubSub.second();
|
||||
|
|
@ -225,7 +220,7 @@ public class RateTransformationDocTest extends AbstractJavaTest {
|
|||
TestSource.<Double>probe(system)
|
||||
.via(realDriftFlow)
|
||||
.toMat(TestSink.<Pair<Double, Integer>>probe(system), Keep.both())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
final TestPublisher.Probe<Double> pub = pubSub.first();
|
||||
final TestSubscriber.Probe<Pair<Double, Integer>> sub = pubSub.second();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import akka.NotUsed;
|
|||
import akka.actor.ActorRef;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.japi.function.Creator;
|
||||
import akka.stream.*;
|
||||
import akka.stream.javadsl.*;
|
||||
import akka.testkit.TestProbe;
|
||||
import jdocs.AbstractJavaTest;
|
||||
|
|
@ -34,14 +33,12 @@ import static jdocs.stream.TwitterStreamQuickstartDocTest.Model.AKKA;
|
|||
public class ReactiveStreamsDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
static TestProbe storageProbe;
|
||||
static TestProbe alertProbe;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("ReactiveStreamsDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
storageProbe = new TestProbe(system);
|
||||
alertProbe = new TestProbe(system);
|
||||
}
|
||||
|
|
@ -50,7 +47,6 @@ public class ReactiveStreamsDocTest extends AbstractJavaTest {
|
|||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
storageProbe = null;
|
||||
alertProbe = null;
|
||||
}
|
||||
|
|
@ -86,7 +82,7 @@ public class ReactiveStreamsDocTest extends AbstractJavaTest {
|
|||
@Override
|
||||
public Publisher<Tweet> tweets() {
|
||||
return TwitterStreamQuickstartDocTest.Model.tweets.runWith(
|
||||
Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), mat);
|
||||
Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), system);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -155,7 +151,7 @@ public class ReactiveStreamsDocTest extends AbstractJavaTest {
|
|||
|
||||
{
|
||||
// #flow-publisher-subscriber
|
||||
final Processor<Tweet, Author> processor = authors.toProcessor().run(mat);
|
||||
final Processor<Tweet, Author> processor = authors.toProcessor().run(system);
|
||||
|
||||
rs.tweets().subscribe(processor);
|
||||
processor.subscribe(rs.storage());
|
||||
|
|
@ -176,7 +172,7 @@ public class ReactiveStreamsDocTest extends AbstractJavaTest {
|
|||
final Publisher<Author> authorPublisher =
|
||||
Source.fromPublisher(rs.tweets())
|
||||
.via(authors)
|
||||
.runWith(Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), mat);
|
||||
.runWith(Sink.asPublisher(AsPublisher.WITHOUT_FANOUT), system);
|
||||
|
||||
authorPublisher.subscribe(rs.storage());
|
||||
// #source-publisher
|
||||
|
|
@ -196,7 +192,7 @@ public class ReactiveStreamsDocTest extends AbstractJavaTest {
|
|||
final Publisher<Author> authorPublisher =
|
||||
Source.fromPublisher(rs.tweets())
|
||||
.via(authors)
|
||||
.runWith(Sink.asPublisher(AsPublisher.WITH_FANOUT), mat);
|
||||
.runWith(Sink.asPublisher(AsPublisher.WITH_FANOUT), system);
|
||||
|
||||
authorPublisher.subscribe(rs.storage());
|
||||
authorPublisher.subscribe(rs.alert());
|
||||
|
|
@ -217,7 +213,7 @@ public class ReactiveStreamsDocTest extends AbstractJavaTest {
|
|||
final Subscriber<Author> storage = rs.storage();
|
||||
|
||||
final Subscriber<Tweet> tweetSubscriber =
|
||||
authors.to(Sink.fromSubscriber(storage)).runWith(Source.asSubscriber(), mat);
|
||||
authors.to(Sink.fromSubscriber(storage)).runWith(Source.asSubscriber(), system);
|
||||
|
||||
rs.tweets().subscribe(tweetSubscriber);
|
||||
// #sink-subscriber
|
||||
|
|
@ -236,7 +232,7 @@ public class ReactiveStreamsDocTest extends AbstractJavaTest {
|
|||
final Creator<Processor<Integer, Integer>> factory =
|
||||
new Creator<Processor<Integer, Integer>>() {
|
||||
public Processor<Integer, Integer> create() {
|
||||
return Flow.of(Integer.class).toProcessor().run(mat);
|
||||
return Flow.of(Integer.class).toProcessor().run(system);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ package jdocs.stream;
|
|||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.japi.function.Function;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Source;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import jdocs.AbstractJavaTest;
|
||||
|
|
@ -20,12 +18,10 @@ import java.util.concurrent.CompletionStage;
|
|||
|
||||
public class SinkRecipeDocTest extends AbstractJavaTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("SinkRecipeDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -38,7 +34,7 @@ public class SinkRecipeDocTest extends AbstractJavaTest {
|
|||
|
||||
final Source<Integer, NotUsed> numberSource = Source.range(1, 100);
|
||||
|
||||
numberSource.runWith(Sink.foreachAsync(10, asyncProcessing), mat);
|
||||
numberSource.runWith(Sink.foreachAsync(10, asyncProcessing), system);
|
||||
// #forseachAsync-processing
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,19 +23,16 @@ public class StreamBuffersRateDocTest extends AbstractJavaTest {
|
|||
static class Job {}
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("StreamBuffersDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
final SilenceSystemOut.System System = SilenceSystemOut.get();
|
||||
|
|
@ -62,7 +59,7 @@ public class StreamBuffersRateDocTest extends AbstractJavaTest {
|
|||
return i;
|
||||
})
|
||||
.async()
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #pipelining
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +106,7 @@ public class StreamBuffersRateDocTest extends AbstractJavaTest {
|
|||
b.from(zipper.out()).to(b.add(Sink.foreach(elem -> System.out.println(elem))));
|
||||
return ClosedShape.getInstance();
|
||||
}))
|
||||
.run(mat);
|
||||
.run(system);
|
||||
// #buffering-abstraction-leak
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,19 +28,16 @@ import static org.junit.Assert.assertEquals;
|
|||
public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("StreamPartialGraphDSLDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -78,7 +75,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
|
|||
return ClosedShape.getInstance();
|
||||
}));
|
||||
|
||||
final CompletionStage<Integer> max = g.run(mat);
|
||||
final CompletionStage<Integer> max = g.run(system);
|
||||
// #simple-partial-graph-dsl
|
||||
assertEquals(Integer.valueOf(3), max.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -119,7 +116,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
|
|||
}));
|
||||
|
||||
final CompletionStage<Pair<Integer, Integer>> firstPair =
|
||||
pairs.runWith(Sink.<Pair<Integer, Integer>>head(), mat);
|
||||
pairs.runWith(Sink.<Pair<Integer, Integer>>head(), system);
|
||||
// #source-from-partial-graph-dsl
|
||||
assertEquals(new Pair<>(0, 1), firstPair.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -146,7 +143,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
|
|||
// #flow-from-partial-graph-dsl
|
||||
final CompletionStage<Pair<Integer, String>> matSink =
|
||||
// #flow-from-partial-graph-dsl
|
||||
Source.single(1).via(pairs).runWith(Sink.<Pair<Integer, String>>head(), mat);
|
||||
Source.single(1).via(pairs).runWith(Sink.<Pair<Integer, String>>head(), system);
|
||||
// #flow-from-partial-graph-dsl
|
||||
|
||||
assertEquals(new Pair<>(1, "1"), matSink.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
|
|
@ -163,7 +160,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
|
|||
// #source-combine
|
||||
final CompletionStage<Integer> result =
|
||||
// #source-combine
|
||||
sources.runWith(Sink.<Integer, Integer>fold(0, (a, b) -> a + b), mat);
|
||||
sources.runWith(Sink.<Integer, Integer>fold(0, (a, b) -> a + b), system);
|
||||
// #source-combine
|
||||
|
||||
assertEquals(Integer.valueOf(3), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
|
|
@ -184,7 +181,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
|
|||
Sink<Integer, NotUsed> sinks =
|
||||
Sink.combine(sendRemotely, localProcessing, new ArrayList<>(), a -> Broadcast.create(a));
|
||||
|
||||
Source.<Integer>from(Arrays.asList(new Integer[] {0, 1, 2})).runWith(sinks, mat);
|
||||
Source.<Integer>from(Arrays.asList(new Integer[] {0, 1, 2})).runWith(sinks, system);
|
||||
// #sink-combine
|
||||
probe.expectMsgEquals(0);
|
||||
probe.expectMsgEquals(1);
|
||||
|
|
|
|||
|
|
@ -29,19 +29,16 @@ import akka.stream.testkit.javadsl.*;
|
|||
public class StreamTestKitDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("StreamTestKitDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -53,7 +50,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
.toMat(Sink.fold(0, (agg, next) -> agg + next), Keep.right());
|
||||
|
||||
final CompletionStage<Integer> future =
|
||||
Source.from(Arrays.asList(1, 2, 3, 4)).runWith(sinkUnderTest, mat);
|
||||
Source.from(Arrays.asList(1, 2, 3, 4)).runWith(sinkUnderTest, system);
|
||||
final Integer result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assert (result == 20);
|
||||
// #strict-collection
|
||||
|
|
@ -64,7 +61,8 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
// #grouped-infinite
|
||||
final Source<Integer, NotUsed> sourceUnderTest = Source.repeat(1).map(i -> i * 2);
|
||||
|
||||
final CompletionStage<List<Integer>> future = sourceUnderTest.take(10).runWith(Sink.seq(), mat);
|
||||
final CompletionStage<List<Integer>> future =
|
||||
sourceUnderTest.take(10).runWith(Sink.seq(), system);
|
||||
final List<Integer> result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(result, Collections.nCopies(10, 2));
|
||||
// #grouped-infinite
|
||||
|
|
@ -79,7 +77,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
final CompletionStage<Integer> future =
|
||||
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6))
|
||||
.via(flowUnderTest)
|
||||
.runWith(Sink.fold(0, (agg, next) -> agg + next), mat);
|
||||
.runWith(Sink.fold(0, (agg, next) -> agg + next), system);
|
||||
final Integer result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assert (result == 10);
|
||||
// #folded-stream
|
||||
|
|
@ -93,7 +91,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
|
||||
final TestKit probe = new TestKit(system);
|
||||
final CompletionStage<List<List<Integer>>> future =
|
||||
sourceUnderTest.grouped(2).runWith(Sink.head(), mat);
|
||||
sourceUnderTest.grouped(2).runWith(Sink.head(), system);
|
||||
akka.pattern.Patterns.pipe(future, system.dispatcher()).to(probe.getRef());
|
||||
probe.expectMsg(Duration.ofSeconds(3), Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4)));
|
||||
// #pipeto-testprobe
|
||||
|
|
@ -112,7 +110,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
|
||||
final TestKit probe = new TestKit(system);
|
||||
final Cancellable cancellable =
|
||||
sourceUnderTest.to(Sink.actorRef(probe.getRef(), Tick.COMPLETED)).run(mat);
|
||||
sourceUnderTest.to(Sink.actorRef(probe.getRef(), Tick.COMPLETED)).run(system);
|
||||
probe.expectMsg(Duration.ofSeconds(3), Tick.TOCK);
|
||||
probe.expectNoMessage(Duration.ofMillis(100));
|
||||
probe.expectMsg(Duration.ofSeconds(3), Tick.TOCK);
|
||||
|
|
@ -132,7 +130,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
final Pair<ActorRef, CompletionStage<String>> refAndCompletionStage =
|
||||
Source.<Integer>actorRef(8, OverflowStrategy.fail())
|
||||
.toMat(sinkUnderTest, Keep.both())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
final ActorRef ref = refAndCompletionStage.first();
|
||||
final CompletionStage<String> future = refAndCompletionStage.second();
|
||||
|
||||
|
|
@ -153,7 +151,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
Source.from(Arrays.asList(1, 2, 3, 4)).filter(elem -> elem % 2 == 0).map(elem -> elem * 2);
|
||||
|
||||
sourceUnderTest
|
||||
.runWith(TestSink.probe(system), mat)
|
||||
.runWith(TestSink.probe(system), system)
|
||||
.request(2)
|
||||
.expectNext(4, 8)
|
||||
.expectComplete();
|
||||
|
|
@ -167,7 +165,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
|
||||
TestSource.<Integer>probe(system)
|
||||
.toMat(sinkUnderTest, Keep.left())
|
||||
.run(mat)
|
||||
.run(system)
|
||||
.expectCancellation();
|
||||
// #test-source-probe
|
||||
}
|
||||
|
|
@ -178,7 +176,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
final Sink<Integer, CompletionStage<Integer>> sinkUnderTest = Sink.head();
|
||||
|
||||
final Pair<TestPublisher.Probe<Integer>, CompletionStage<Integer>> probeAndCompletionStage =
|
||||
TestSource.<Integer>probe(system).toMat(sinkUnderTest, Keep.both()).run(mat);
|
||||
TestSource.<Integer>probe(system).toMat(sinkUnderTest, Keep.both()).run(system);
|
||||
final TestPublisher.Probe<Integer> probe = probeAndCompletionStage.first();
|
||||
final CompletionStage<Integer> future = probeAndCompletionStage.second();
|
||||
probe.sendError(new Exception("boom"));
|
||||
|
|
@ -211,7 +209,7 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
|
|||
TestSource.<Integer>probe(system)
|
||||
.via(flowUnderTest)
|
||||
.toMat(TestSink.<Integer>probe(system), Keep.both())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
final TestPublisher.Probe<Integer> pub = pubAndSub.first();
|
||||
final TestSubscriber.Probe<Integer> sub = pubAndSub.second();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,19 +22,16 @@ import java.util.List;
|
|||
public class SubstreamDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("FlowDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -47,26 +44,26 @@ public class SubstreamDocTest extends AbstractJavaTest {
|
|||
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
|
||||
.groupBy(3, elem -> elem % 3)
|
||||
.to(Sink.ignore())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
// #groupBy2
|
||||
|
||||
// #groupBy3
|
||||
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
|
||||
.groupBy(3, elem -> elem % 3)
|
||||
.mergeSubstreams()
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #groupBy3
|
||||
|
||||
// #groupBy4
|
||||
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
|
||||
.groupBy(3, elem -> elem % 3)
|
||||
.mergeSubstreamsWithParallelism(2)
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// concatSubstreams is equivalent to mergeSubstreamsWithParallelism(1)
|
||||
Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
|
||||
.groupBy(3, elem -> elem % 3)
|
||||
.concatSubstreams()
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #groupBy4
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +86,7 @@ public class SubstreamDocTest extends AbstractJavaTest {
|
|||
.map(x -> 1)
|
||||
.reduce((x, y) -> x + y)
|
||||
.to(Sink.foreach(x -> System.out.println(x)))
|
||||
.run(mat);
|
||||
.run(system);
|
||||
// #wordCount
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
|
|
@ -99,13 +96,13 @@ public class SubstreamDocTest extends AbstractJavaTest {
|
|||
// #flatMapConcat
|
||||
Source.from(Arrays.asList(1, 2))
|
||||
.flatMapConcat(i -> Source.from(Arrays.asList(i, i, i)))
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #flatMapConcat
|
||||
|
||||
// #flatMapMerge
|
||||
Source.from(Arrays.asList(1, 2))
|
||||
.flatMapMerge(2, i -> Source.from(Arrays.asList(i, i, i)))
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #flatMapMerge
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,19 +41,15 @@ public class TwitterStreamQuickstartDocTest extends AbstractJavaTest {
|
|||
|
||||
static ActorSystem system;
|
||||
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("TwitterStreamQuickstartDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
abstract static class Model {
|
||||
|
|
@ -201,11 +197,10 @@ public class TwitterStreamQuickstartDocTest extends AbstractJavaTest {
|
|||
|
||||
abstract static class Example1 {
|
||||
// #first-sample
|
||||
// #materializer-setup
|
||||
// #system-setup
|
||||
final ActorSystem system = ActorSystem.create("reactive-tweets");
|
||||
final Materializer mat = ActorMaterializer.create(system);
|
||||
// #first-sample
|
||||
// #materializer-setup
|
||||
// #system-setup
|
||||
}
|
||||
|
||||
static class Example2 {
|
||||
|
|
@ -263,12 +258,12 @@ public class TwitterStreamQuickstartDocTest extends AbstractJavaTest {
|
|||
// #first-sample
|
||||
|
||||
// #authors-foreachsink-println
|
||||
authors.runWith(Sink.foreach(a -> System.out.println(a)), mat);
|
||||
authors.runWith(Sink.foreach(a -> System.out.println(a)), system);
|
||||
// #first-sample
|
||||
// #authors-foreachsink-println
|
||||
|
||||
// #authors-foreach-println
|
||||
authors.runForeach(a -> System.out.println(a), mat);
|
||||
authors.runForeach(a -> System.out.println(a), system);
|
||||
// #authors-foreach-println
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +305,7 @@ public class TwitterStreamQuickstartDocTest extends AbstractJavaTest {
|
|||
b.from(bcast).via(toTags).to(hashtags);
|
||||
return ClosedShape.getInstance();
|
||||
}))
|
||||
.run(mat);
|
||||
.run(system);
|
||||
// #graph-dsl-broadcast
|
||||
}
|
||||
|
||||
|
|
@ -329,7 +324,7 @@ public class TwitterStreamQuickstartDocTest extends AbstractJavaTest {
|
|||
tweets
|
||||
.buffer(10, OverflowStrategy.dropHead())
|
||||
.map(t -> slowComputation(t))
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #tweets-slow-consumption-dropHead
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +337,7 @@ public class TwitterStreamQuickstartDocTest extends AbstractJavaTest {
|
|||
final RunnableGraph<CompletionStage<Integer>> counter =
|
||||
tweets.map(t -> 1).toMat(sumSink, Keep.right());
|
||||
|
||||
final CompletionStage<Integer> sum = counter.run(mat);
|
||||
final CompletionStage<Integer> sum = counter.run(system);
|
||||
|
||||
sum.thenAcceptAsync(
|
||||
c -> System.out.println("Total tweets processed: " + c), system.dispatcher());
|
||||
|
|
@ -350,7 +345,7 @@ public class TwitterStreamQuickstartDocTest extends AbstractJavaTest {
|
|||
|
||||
new Object() {
|
||||
// #tweets-fold-count-oneline
|
||||
final CompletionStage<Integer> sum = tweets.map(t -> 1).runWith(sumSink, mat);
|
||||
final CompletionStage<Integer> sum = tweets.map(t -> 1).runWith(sumSink, system);
|
||||
// #tweets-fold-count-oneline
|
||||
};
|
||||
}
|
||||
|
|
@ -370,9 +365,9 @@ public class TwitterStreamQuickstartDocTest extends AbstractJavaTest {
|
|||
.toMat(sumSink, Keep.right());
|
||||
|
||||
// materialize the stream once in the morning
|
||||
final CompletionStage<Integer> morningTweetsCount = counterRunnableGraph.run(mat);
|
||||
final CompletionStage<Integer> morningTweetsCount = counterRunnableGraph.run(system);
|
||||
// and once in the evening, reusing the blueprint
|
||||
final CompletionStage<Integer> eveningTweetsCount = counterRunnableGraph.run(mat);
|
||||
final CompletionStage<Integer> eveningTweetsCount = counterRunnableGraph.run(system);
|
||||
// #tweets-runnable-flow-materialized-twice
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,19 +31,15 @@ public class StreamFileDocTest extends AbstractJavaTest {
|
|||
|
||||
static ActorSystem system;
|
||||
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("StreamFileDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
final SilenceSystemOut.System System = SilenceSystemOut.get();
|
||||
|
|
@ -70,7 +66,7 @@ public class StreamFileDocTest extends AbstractJavaTest {
|
|||
Sink<ByteString, CompletionStage<Done>> printlnSink =
|
||||
Sink.<ByteString>foreach(chunk -> System.out.println(chunk.utf8String()));
|
||||
|
||||
CompletionStage<IOResult> ioResult = FileIO.fromPath(file).to(printlnSink).run(mat);
|
||||
CompletionStage<IOResult> ioResult = FileIO.fromPath(file).to(printlnSink).run(system);
|
||||
// #file-source
|
||||
} finally {
|
||||
Files.delete(file);
|
||||
|
|
@ -102,7 +98,7 @@ public class StreamFileDocTest extends AbstractJavaTest {
|
|||
Source<String, NotUsed> textSource = Source.single("Hello Akka Stream!");
|
||||
|
||||
CompletionStage<IOResult> ioResult =
|
||||
textSource.map(ByteString::fromString).runWith(fileSink, mat);
|
||||
textSource.map(ByteString::fromString).runWith(fileSink, system);
|
||||
// #file-sink
|
||||
} finally {
|
||||
Files.delete(file);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,8 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.stream.*;
|
||||
import akka.stream.javadsl.*;
|
||||
import akka.stream.javadsl.Tcp.*;
|
||||
import akka.stream.stage.*;
|
||||
import akka.testkit.SocketUtil;
|
||||
import akka.testkit.TestProbe;
|
||||
import akka.util.ByteString;
|
||||
|
|
@ -31,19 +29,16 @@ import akka.util.ByteString;
|
|||
public class StreamTcpDocTest extends AbstractJavaTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("StreamTcpDocTest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
final SilenceSystemOut.System System = SilenceSystemOut.get();
|
||||
|
|
@ -88,9 +83,9 @@ public class StreamTcpDocTest extends AbstractJavaTest {
|
|||
.map(s -> s + "!!!\n")
|
||||
.map(ByteString::fromString);
|
||||
|
||||
connection.handleWith(echo, mat);
|
||||
connection.handleWith(echo, system);
|
||||
},
|
||||
mat);
|
||||
system);
|
||||
// #echo-server-simple-handle
|
||||
}
|
||||
}
|
||||
|
|
@ -141,9 +136,9 @@ public class StreamTcpDocTest extends AbstractJavaTest {
|
|||
.map(s -> s + "\n")
|
||||
.map(ByteString::fromString);
|
||||
|
||||
connection.handleWith(serverLogic, mat);
|
||||
connection.handleWith(serverLogic, system);
|
||||
}))
|
||||
.run(mat);
|
||||
.run(system);
|
||||
// #welcome-banner-chat-server
|
||||
|
||||
// make sure server is bound before we do anything else
|
||||
|
|
@ -179,7 +174,7 @@ public class StreamTcpDocTest extends AbstractJavaTest {
|
|||
.map(elem -> readLine("> "))
|
||||
.via(replParser);
|
||||
|
||||
CompletionStage<OutgoingConnection> connectionCS = connection.join(repl).run(mat);
|
||||
CompletionStage<OutgoingConnection> connectionCS = connection.join(repl).run(system);
|
||||
// #repl-client
|
||||
|
||||
// make sure it got connected (or fails the test)
|
||||
|
|
|
|||
|
|
@ -32,20 +32,17 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class RecipeAdhocSourceTest extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
Duration duration200mills = Duration.ofMillis(200);
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeAdhocSource");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
// #adhoc-source
|
||||
|
|
@ -93,7 +90,7 @@ public class RecipeAdhocSourceTest extends RecipeTest {
|
|||
TestSubscriber.Probe<String> probe =
|
||||
adhocSource(Source.repeat("a"), duration200mills, 3)
|
||||
.toMat(TestSink.probe(system), Keep.right())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
probe.requestNext("a");
|
||||
}
|
||||
};
|
||||
|
|
@ -113,7 +110,7 @@ public class RecipeAdhocSourceTest extends RecipeTest {
|
|||
duration200mills,
|
||||
3)
|
||||
.toMat(TestSink.probe(system), Keep.right())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
probe.requestNext("a");
|
||||
Thread.sleep(300);
|
||||
|
|
@ -136,7 +133,7 @@ public class RecipeAdhocSourceTest extends RecipeTest {
|
|||
duration200mills,
|
||||
3)
|
||||
.toMat(TestSink.probe(system), Keep.right())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
probe.requestNext("a");
|
||||
Thread.sleep(100);
|
||||
|
|
@ -174,7 +171,7 @@ public class RecipeAdhocSourceTest extends RecipeTest {
|
|||
duration200mills,
|
||||
3)
|
||||
.toMat(TestSink.probe(system), Keep.right())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
probe.requestNext("a");
|
||||
assertEquals(1, startedCount.get());
|
||||
|
|
@ -204,7 +201,7 @@ public class RecipeAdhocSourceTest extends RecipeTest {
|
|||
duration200mills,
|
||||
3)
|
||||
.toMat(TestSink.probe(system), Keep.right())
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
probe.requestNext("a");
|
||||
assertEquals(1, startedCount.get());
|
||||
|
|
|
|||
|
|
@ -30,19 +30,16 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
public class RecipeByteStrings extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeByteStrings");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
final Source<ByteString, NotUsed> rawBytes =
|
||||
|
|
@ -142,7 +139,7 @@ public class RecipeByteStrings extends RecipeTest {
|
|||
// #bytestring-chunker2
|
||||
|
||||
CompletionStage<List<ByteString>> chunksFuture =
|
||||
chunksStream.limit(10).runWith(Sink.seq(), mat);
|
||||
chunksStream.limit(10).runWith(Sink.seq(), system);
|
||||
|
||||
List<ByteString> chunks = chunksFuture.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -242,7 +239,7 @@ public class RecipeByteStrings extends RecipeTest {
|
|||
bytes1
|
||||
.via(limiter)
|
||||
.limit(10)
|
||||
.runWith(Sink.seq(), mat)
|
||||
.runWith(Sink.seq(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
ByteString acc = emptyByteString();
|
||||
|
|
@ -256,7 +253,7 @@ public class RecipeByteStrings extends RecipeTest {
|
|||
bytes2
|
||||
.via(limiter)
|
||||
.limit(10)
|
||||
.runWith(Sink.seq(), mat)
|
||||
.runWith(Sink.seq(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
} catch (ExecutionException ex) {
|
||||
|
|
@ -287,7 +284,7 @@ public class RecipeByteStrings extends RecipeTest {
|
|||
List<ByteString> got =
|
||||
compacted
|
||||
.limit(10)
|
||||
.runWith(Sink.seq(), mat)
|
||||
.runWith(Sink.seq(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ package jdocs.stream.javadsl.cookbook;
|
|||
|
||||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Compression;
|
||||
import akka.stream.javadsl.Source;
|
||||
import akka.testkit.javadsl.TestKit;
|
||||
|
|
@ -23,19 +21,16 @@ import java.util.concurrent.TimeUnit;
|
|||
public class RecipeDecompress extends RecipeTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeDecompress");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -52,7 +47,7 @@ public class RecipeDecompress extends RecipeTest {
|
|||
|
||||
ByteString decompressedData =
|
||||
decompressedStream
|
||||
.runFold(emptyByteString(), ByteString::concat, mat)
|
||||
.runFold(emptyByteString(), ByteString::concat, system)
|
||||
.toCompletableFuture()
|
||||
.get(1, TimeUnit.SECONDS);
|
||||
String decompressedString = decompressedData.utf8String();
|
||||
|
|
|
|||
|
|
@ -24,19 +24,16 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class RecipeDigest extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeDigest");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
// #calculating-digest
|
||||
|
|
@ -111,7 +108,7 @@ public class RecipeDigest extends RecipeTest {
|
|||
// #calculating-digest2
|
||||
|
||||
ByteString got =
|
||||
digest.runWith(Sink.head(), mat).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
digest.runWith(Sink.head(), system).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
||||
assertEquals(
|
||||
ByteString.fromInts(
|
||||
|
|
|
|||
|
|
@ -20,19 +20,16 @@ import java.util.concurrent.CompletionStage;
|
|||
|
||||
public class RecipeDroppyBroadcast extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeDroppyBroadcast");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ package jdocs.stream.javadsl.cookbook;
|
|||
|
||||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.Source;
|
||||
import akka.testkit.javadsl.TestKit;
|
||||
|
|
@ -23,19 +21,16 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class RecipeFlattenList extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeFlattenList");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -56,7 +51,7 @@ public class RecipeFlattenList extends RecipeTest {
|
|||
List<Message> got =
|
||||
flattened
|
||||
.limit(10)
|
||||
.runWith(Sink.seq(), mat)
|
||||
.runWith(Sink.seq(), system)
|
||||
.toCompletableFuture()
|
||||
.get(1, TimeUnit.SECONDS);
|
||||
assertEquals(got.get(0), new Message("1"));
|
||||
|
|
|
|||
|
|
@ -24,19 +24,16 @@ import static junit.framework.TestCase.assertTrue;
|
|||
|
||||
public class RecipeGlobalRateLimit extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeGlobalRateLimit");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
public
|
||||
|
|
@ -229,7 +226,7 @@ public class RecipeGlobalRateLimit extends RecipeTest {
|
|||
builder.from(merge).to(s);
|
||||
return ClosedShape.getInstance();
|
||||
}))
|
||||
.run(mat);
|
||||
.run(system);
|
||||
|
||||
probe.expectSubscription().request(1000);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import akka.stream.testkit.TestSubscriber;
|
|||
import akka.stream.testkit.javadsl.TestSink;
|
||||
import akka.stream.testkit.javadsl.TestSource;
|
||||
import akka.testkit.javadsl.TestKit;
|
||||
import akka.util.ByteString;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
|
@ -26,19 +25,16 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class RecipeHold extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeHold");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
// #hold-version-1
|
||||
|
|
@ -151,7 +147,7 @@ public class RecipeHold extends RecipeTest {
|
|||
final Sink<Integer, TestSubscriber.Probe<Integer>> sink = TestSink.probe(system);
|
||||
|
||||
Pair<TestPublisher.Probe<Integer>, TestSubscriber.Probe<Integer>> pubSub =
|
||||
source.via(new HoldWithInitial<>(0)).toMat(sink, Keep.both()).run(mat);
|
||||
source.via(new HoldWithInitial<>(0)).toMat(sink, Keep.both()).run(system);
|
||||
TestPublisher.Probe<Integer> pub = pubSub.first();
|
||||
TestSubscriber.Probe<Integer> sub = pubSub.second();
|
||||
|
||||
|
|
@ -179,7 +175,7 @@ public class RecipeHold extends RecipeTest {
|
|||
final Sink<Integer, TestSubscriber.Probe<Integer>> sink = TestSink.probe(system);
|
||||
|
||||
Pair<TestPublisher.Probe<Integer>, TestSubscriber.Probe<Integer>> pubSub =
|
||||
source.via(new HoldWithWait<>()).toMat(sink, Keep.both()).run(mat);
|
||||
source.via(new HoldWithWait<>()).toMat(sink, Keep.both()).run(system);
|
||||
TestPublisher.Probe<Integer> pub = pubSub.first();
|
||||
TestSubscriber.Probe<Integer> sub = pubSub.second();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ package jdocs.stream.javadsl.cookbook;
|
|||
|
||||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Flow;
|
||||
import akka.testkit.javadsl.TestKit;
|
||||
import akka.util.ByteString;
|
||||
|
|
@ -19,19 +17,16 @@ import java.time.Duration;
|
|||
|
||||
public class RecipeKeepAlive extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeKeepAlive");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
class Tick {}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@ import akka.NotUsed;
|
|||
import akka.actor.ActorSystem;
|
||||
import akka.event.Logging;
|
||||
import akka.event.LoggingAdapter;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Attributes;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.Source;
|
||||
import akka.testkit.DebugFilter;
|
||||
|
|
@ -26,7 +24,6 @@ import java.util.Arrays;
|
|||
|
||||
public class RecipeLoggingElements extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
|
|
@ -35,14 +32,12 @@ public class RecipeLoggingElements extends RecipeTest {
|
|||
"RecipeLoggingElements",
|
||||
ConfigFactory.parseString(
|
||||
"akka.loglevel=DEBUG\nakka.loggers = [akka.testkit.TestEventListener]"));
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -95,7 +90,7 @@ public class RecipeLoggingElements extends RecipeTest {
|
|||
.intercept(
|
||||
new AbstractFunction0<Object>() {
|
||||
public Void apply() {
|
||||
mySource.log("custom", adapter).runWith(Sink.ignore(), mat);
|
||||
mySource.log("custom", adapter).runWith(Sink.ignore(), system);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
|
@ -112,7 +107,7 @@ public class RecipeLoggingElements extends RecipeTest {
|
|||
Source.from(Arrays.asList(-1, 0, 1))
|
||||
.map(x -> 1 / x) // throwing ArithmeticException: / by zero
|
||||
.log("error logging")
|
||||
.runWith(Sink.ignore(), mat);
|
||||
.runWith(Sink.ignore(), system);
|
||||
// #log-error
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,19 +23,16 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class RecipeManualTrigger extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeManualTrigger");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
class Trigger {}
|
||||
|
|
@ -75,7 +72,7 @@ public class RecipeManualTrigger extends RecipeTest {
|
|||
}));
|
||||
// #manually-triggered-stream
|
||||
|
||||
Pair<TestPublisher.Probe<Trigger>, TestSubscriber.Probe<Message>> pubSub = g.run(mat);
|
||||
Pair<TestPublisher.Probe<Trigger>, TestSubscriber.Probe<Message>> pubSub = g.run(system);
|
||||
TestPublisher.Probe<Trigger> pub = pubSub.first();
|
||||
TestSubscriber.Probe<Message> sub = pubSub.second();
|
||||
|
||||
|
|
@ -130,7 +127,7 @@ public class RecipeManualTrigger extends RecipeTest {
|
|||
}));
|
||||
// #manually-triggered-stream-zipwith
|
||||
|
||||
Pair<TestPublisher.Probe<Trigger>, TestSubscriber.Probe<Message>> pubSub = g.run(mat);
|
||||
Pair<TestPublisher.Probe<Trigger>, TestSubscriber.Probe<Message>> pubSub = g.run(system);
|
||||
TestPublisher.Probe<Trigger> pub = pubSub.first();
|
||||
TestSubscriber.Probe<Message> sub = pubSub.second();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ package jdocs.stream.javadsl.cookbook;
|
|||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.japi.Pair;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Flow;
|
||||
import akka.stream.javadsl.Keep;
|
||||
import akka.stream.javadsl.Sink;
|
||||
|
|
@ -28,19 +26,16 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class RecipeMissedTicks extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeMissedTicks");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -70,7 +65,7 @@ public class RecipeMissedTicks extends RecipeTest {
|
|||
});
|
||||
|
||||
Pair<TestPublisher.Probe<Tick>, TestSubscriber.Probe<Integer>> pubSub =
|
||||
tickStream.via(realMissedTicks).toMat(sink, Keep.both()).run(mat);
|
||||
tickStream.via(realMissedTicks).toMat(sink, Keep.both()).run(system);
|
||||
TestPublisher.Probe<Tick> pub = pubSub.first();
|
||||
TestSubscriber.Probe<Integer> sub = pubSub.second();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ import akka.NotUsed;
|
|||
import akka.actor.ActorSystem;
|
||||
import akka.japi.Function;
|
||||
import akka.japi.Pair;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.Source;
|
||||
import akka.stream.javadsl.SubSource;
|
||||
|
|
@ -29,19 +27,16 @@ import static junit.framework.TestCase.assertTrue;
|
|||
|
||||
public class RecipeMultiGroupByTest extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeMultiGroupBy");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
static class Topic {
|
||||
|
|
@ -142,7 +137,7 @@ public class RecipeMultiGroupByTest extends RecipeTest {
|
|||
"]");
|
||||
})
|
||||
.grouped(10)
|
||||
.runWith(Sink.head(), mat);
|
||||
.runWith(Sink.head(), system);
|
||||
|
||||
List<String> got = result.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertTrue(got.contains("1[1: a, 1: b, all: c, all: d, 1: e]"));
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ package jdocs.stream.javadsl.cookbook;
|
|||
|
||||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Framing;
|
||||
import akka.stream.javadsl.FramingTruncation;
|
||||
import akka.stream.javadsl.Sink;
|
||||
|
|
@ -24,19 +22,16 @@ import java.util.concurrent.TimeUnit;
|
|||
public class RecipeParseLines extends RecipeTest {
|
||||
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeParseLines");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -56,6 +51,6 @@ public class RecipeParseLines extends RecipeTest {
|
|||
.via(Framing.delimiter(ByteString.fromString("\r\n"), 100, FramingTruncation.ALLOW))
|
||||
.map(b -> b.utf8String());
|
||||
// #parse-lines
|
||||
lines.limit(10).runWith(Sink.seq(), mat).toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
lines.limit(10).runWith(Sink.seq(), system).toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import akka.actor.ActorSystem;
|
|||
import akka.japi.Pair;
|
||||
import akka.japi.function.Function;
|
||||
import akka.japi.function.Function2;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Flow;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.Source;
|
||||
|
|
@ -30,19 +28,16 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class RecipeReduceByKeyTest extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeReduceByKey");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -68,7 +63,7 @@ public class RecipeReduceByKeyTest extends RecipeTest {
|
|||
// #word-count
|
||||
|
||||
final CompletionStage<List<Pair<String, Integer>>> f =
|
||||
counts.grouped(10).runWith(Sink.head(), mat);
|
||||
counts.grouped(10).runWith(Sink.head(), system);
|
||||
final Set<Pair<String, Integer>> result =
|
||||
f.toCompletableFuture().get(3, TimeUnit.SECONDS).stream().collect(Collectors.toSet());
|
||||
final Set<Pair<String, Integer>> expected = new HashSet<>();
|
||||
|
|
@ -117,7 +112,7 @@ public class RecipeReduceByKeyTest extends RecipeTest {
|
|||
|
||||
// #reduce-by-key-general2
|
||||
final CompletionStage<List<Pair<String, Integer>>> f =
|
||||
counts.grouped(10).runWith(Sink.head(), mat);
|
||||
counts.grouped(10).runWith(Sink.head(), system);
|
||||
final Set<Pair<String, Integer>> result =
|
||||
f.toCompletableFuture().get(3, TimeUnit.SECONDS).stream().collect(Collectors.toSet());
|
||||
final Set<Pair<String, Integer>> expected = new HashSet<>();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ package jdocs.stream.javadsl.cookbook;
|
|||
|
||||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.Source;
|
||||
import akka.testkit.javadsl.TestKit;
|
||||
|
|
@ -22,19 +20,16 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class RecipeSeq extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeLoggingElements");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -44,7 +39,7 @@ public class RecipeSeq extends RecipeTest {
|
|||
final Source<String, NotUsed> mySource = Source.from(Arrays.asList("1", "2", "3"));
|
||||
// #draining-to-list-unsafe
|
||||
// Dangerous: might produce a collection with 2 billion elements!
|
||||
final CompletionStage<List<String>> strings = mySource.runWith(Sink.seq(), mat);
|
||||
final CompletionStage<List<String>> strings = mySource.runWith(Sink.seq(), system);
|
||||
// #draining-to-list-unsafe
|
||||
|
||||
strings.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
|
@ -63,7 +58,7 @@ public class RecipeSeq extends RecipeTest {
|
|||
// OK. Future will fail with a `StreamLimitReachedException`
|
||||
// if the number of incoming elements is larger than max
|
||||
final CompletionStage<List<String>> strings =
|
||||
mySource.limit(MAX_ALLOWED_SIZE).runWith(Sink.seq(), mat);
|
||||
mySource.limit(MAX_ALLOWED_SIZE).runWith(Sink.seq(), system);
|
||||
// #draining-to-list-safe
|
||||
|
||||
strings.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
|
|
@ -81,7 +76,7 @@ public class RecipeSeq extends RecipeTest {
|
|||
|
||||
// OK. Collect up until max-th elements only, then cancel upstream
|
||||
final CompletionStage<List<String>> strings =
|
||||
mySource.take(MAX_ALLOWED_SIZE).runWith(Sink.seq(), mat);
|
||||
mySource.take(MAX_ALLOWED_SIZE).runWith(Sink.seq(), system);
|
||||
// #draining-to-list-safe
|
||||
|
||||
strings.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ package jdocs.stream.javadsl.cookbook;
|
|||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.japi.Pair;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Flow;
|
||||
import akka.stream.testkit.TestPublisher;
|
||||
import akka.stream.testkit.TestSubscriber;
|
||||
|
|
@ -26,19 +24,16 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class RecipeSimpleDrop extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeSimpleDrop");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -63,7 +58,7 @@ public class RecipeSimpleDrop extends RecipeTest {
|
|||
TestSource.<Message>probe(system)
|
||||
.via(realDroppyStream)
|
||||
.toMat(TestSink.probe(system), (pub, sub) -> new Pair<>(pub, sub))
|
||||
.run(mat);
|
||||
.run(system);
|
||||
final TestPublisher.Probe<Message> pub = pubSub.first();
|
||||
final TestSubscriber.Probe<Message> sub = pubSub.second();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ package jdocs.stream.javadsl.cookbook;
|
|||
|
||||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.Source;
|
||||
import akka.testkit.javadsl.TestKit;
|
||||
|
|
@ -23,7 +21,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class RecipeSourceFromFunction extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
|
|
@ -32,14 +29,12 @@ public class RecipeSourceFromFunction extends RecipeTest {
|
|||
"RecipeSourceFromFunction",
|
||||
ConfigFactory.parseString(
|
||||
"akka.loglevel=DEBUG\nakka.loggers = [akka.testkit.TestEventListener]"));
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -56,7 +51,11 @@ public class RecipeSourceFromFunction extends RecipeTest {
|
|||
// #source-from-function
|
||||
|
||||
final List<String> result =
|
||||
source.take(2).runWith(Sink.seq(), mat).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
source
|
||||
.take(2)
|
||||
.runWith(Sink.seq(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
Assert.assertEquals(2, result.size());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,19 +23,16 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
public class RecipeWorkerPool extends RecipeTest {
|
||||
static ActorSystem system;
|
||||
static Materializer mat;
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
system = ActorSystem.create("RecipeWorkerPool");
|
||||
mat = ActorMaterializer.create(system);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() {
|
||||
TestKit.shutdownActorSystem(system);
|
||||
system = null;
|
||||
mat = null;
|
||||
}
|
||||
|
||||
// #worker-pool
|
||||
|
|
@ -75,7 +72,7 @@ public class RecipeWorkerPool extends RecipeTest {
|
|||
|
||||
FiniteDuration timeout = FiniteDuration.create(200, TimeUnit.MILLISECONDS);
|
||||
CompletionStage<List<String>> future =
|
||||
processedJobs.map(m -> m.msg).limit(10).runWith(Sink.seq(), mat);
|
||||
processedJobs.map(m -> m.msg).limit(10).runWith(Sink.seq(), system);
|
||||
List<String> got = future.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
assertTrue(got.contains("1 done"));
|
||||
assertTrue(got.contains("2 done"));
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ package jdocs.stream.operators;
|
|||
import akka.NotUsed;
|
||||
import akka.actor.ActorSystem;
|
||||
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.Source;
|
||||
// #takeLast-operator-example
|
||||
|
|
@ -22,13 +20,12 @@ import java.util.concurrent.TimeoutException;
|
|||
public class SinkDocExamples {
|
||||
|
||||
private static final ActorSystem system = ActorSystem.create("SourceFromExample");
|
||||
private static final Materializer materializer = ActorMaterializer.create(system);
|
||||
|
||||
static void reduceExample() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
|
||||
// #reduce-operator-example
|
||||
Source<Integer, NotUsed> ints = Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
CompletionStage<Integer> sum = ints.runWith(Sink.reduce((a, b) -> a + b), materializer);
|
||||
CompletionStage<Integer> sum = ints.runWith(Sink.reduce((a, b) -> a + b), system);
|
||||
sum.thenAccept(System.out::println);
|
||||
// 55
|
||||
// #reduce-operator-example
|
||||
|
|
@ -48,7 +45,7 @@ public class SinkDocExamples {
|
|||
|
||||
Source<Pair, NotUsed> studentSource = Source.from(sortedStudents);
|
||||
|
||||
CompletionStage<List<Pair>> topThree = studentSource.runWith(Sink.takeLast(3), materializer);
|
||||
CompletionStage<List<Pair>> topThree = studentSource.runWith(Sink.takeLast(3), system);
|
||||
|
||||
topThree.thenAccept(
|
||||
result -> {
|
||||
|
|
@ -70,7 +67,7 @@ public class SinkDocExamples {
|
|||
static void lastExample() throws InterruptedException, ExecutionException, TimeoutException {
|
||||
// #last-operator-example
|
||||
Source<Integer, NotUsed> source = Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
CompletionStage<Integer> result = source.runWith(Sink.last(), materializer);
|
||||
CompletionStage<Integer> result = source.runWith(Sink.last(), system);
|
||||
result.thenAccept(System.out::println);
|
||||
// 10
|
||||
// #last-operator-example
|
||||
|
|
@ -80,7 +77,7 @@ public class SinkDocExamples {
|
|||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
// #lastOption-operator-example
|
||||
Source<Integer, NotUsed> source = Source.empty();
|
||||
CompletionStage<Optional<Integer>> result = source.runWith(Sink.lastOption(), materializer);
|
||||
CompletionStage<Optional<Integer>> result = source.runWith(Sink.lastOption(), system);
|
||||
result.thenAccept(System.out::println);
|
||||
// Optional.empty
|
||||
// #lastOption-operator-example
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ import akka.NotUsed;
|
|||
import akka.actor.ActorSystem;
|
||||
import akka.actor.testkit.typed.javadsl.ManualTime;
|
||||
import akka.actor.testkit.typed.javadsl.TestKitJunitResource;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.javadsl.Source;
|
||||
// #range-imports
|
||||
|
||||
|
|
@ -35,23 +33,21 @@ public class SourceDocExamples {
|
|||
public static void fromExample() {
|
||||
// #source-from-example
|
||||
final ActorSystem system = ActorSystem.create("SourceFromExample");
|
||||
final Materializer materializer = ActorMaterializer.create(system);
|
||||
|
||||
Source<Integer, NotUsed> ints = Source.from(Arrays.asList(0, 1, 2, 3, 4, 5));
|
||||
ints.runForeach(System.out::println, materializer);
|
||||
ints.runForeach(System.out::println, system);
|
||||
|
||||
String text =
|
||||
"Perfection is finally attained not when there is no longer more to add,"
|
||||
+ "but when there is no longer anything to take away.";
|
||||
Source<String, NotUsed> words = Source.from(Arrays.asList(text.split("\\s")));
|
||||
words.runForeach(System.out::println, materializer);
|
||||
words.runForeach(System.out::println, system);
|
||||
// #source-from-example
|
||||
}
|
||||
|
||||
static void rangeExample() {
|
||||
|
||||
final ActorSystem system = ActorSystem.create("Source");
|
||||
final Materializer materializer = ActorMaterializer.create(system);
|
||||
|
||||
// #range
|
||||
|
||||
|
|
@ -69,7 +65,7 @@ public class SourceDocExamples {
|
|||
// #range
|
||||
|
||||
// #run-range
|
||||
source.runForeach(i -> System.out.println(i), materializer);
|
||||
source.runForeach(i -> System.out.println(i), system);
|
||||
// #run-range
|
||||
}
|
||||
|
||||
|
|
@ -77,12 +73,11 @@ public class SourceDocExamples {
|
|||
// #actor-ref
|
||||
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final Materializer materializer = ActorMaterializer.create(system);
|
||||
|
||||
int bufferSize = 100;
|
||||
Source<Object, ActorRef> source = Source.actorRef(bufferSize, OverflowStrategy.dropHead());
|
||||
|
||||
ActorRef actorRef = source.to(Sink.foreach(System.out::println)).run(materializer);
|
||||
ActorRef actorRef = source.to(Sink.foreach(System.out::println)).run(system);
|
||||
actorRef.tell("hello", ActorRef.noSender());
|
||||
actorRef.tell("hello", ActorRef.noSender());
|
||||
|
||||
|
|
@ -96,11 +91,10 @@ public class SourceDocExamples {
|
|||
|
||||
// #actor-ref-with-ack
|
||||
final ActorSystem system = ActorSystem.create();
|
||||
final Materializer materializer = ActorMaterializer.create(system);
|
||||
|
||||
Source<Object, ActorRef> source = Source.actorRefWithAck("ack");
|
||||
|
||||
ActorRef actorRef = source.to(Sink.foreach(System.out::println)).run(materializer);
|
||||
ActorRef actorRef = source.to(Sink.foreach(System.out::println)).run(system);
|
||||
probe.send(actorRef, "hello");
|
||||
probe.expectMsg("ack");
|
||||
probe.send(actorRef, "hello");
|
||||
|
|
|
|||
|
|
@ -5,16 +5,10 @@
|
|||
package docs.persistence.query
|
||||
|
||||
import akka.NotUsed
|
||||
import akka.persistence.journal.{ EventAdapter, EventSeq }
|
||||
import akka.testkit.AkkaSpec
|
||||
import akka.persistence.query.{ EventEnvelope, PersistenceQuery, Sequence }
|
||||
import akka.persistence.query.scaladsl._
|
||||
import akka.persistence.query.journal.leveldb.scaladsl.LeveldbReadJournal
|
||||
import akka.persistence.journal.Tagged
|
||||
import akka.stream.scaladsl.Source
|
||||
import akka.stream.ActorMaterializer
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
||||
object LeveldbPersistenceQueryDocSpec {
|
||||
//#tagger
|
||||
|
|
@ -54,7 +48,6 @@ class LeveldbPersistenceQueryDocSpec(config: String) extends AkkaSpec(config) {
|
|||
|
||||
"demonstrate EventsByPersistenceId" in {
|
||||
//#EventsByPersistenceId
|
||||
implicit val mat = ActorMaterializer()(system)
|
||||
val queries = PersistenceQuery(system).readJournalFor[LeveldbReadJournal](LeveldbReadJournal.Identifier)
|
||||
|
||||
val src: Source[EventEnvelope, NotUsed] =
|
||||
|
|
@ -66,7 +59,6 @@ class LeveldbPersistenceQueryDocSpec(config: String) extends AkkaSpec(config) {
|
|||
|
||||
"demonstrate AllPersistenceIds" in {
|
||||
//#AllPersistenceIds
|
||||
implicit val mat = ActorMaterializer()(system)
|
||||
val queries = PersistenceQuery(system).readJournalFor[LeveldbReadJournal](LeveldbReadJournal.Identifier)
|
||||
|
||||
val src: Source[String, NotUsed] = queries.persistenceIds()
|
||||
|
|
@ -75,7 +67,6 @@ class LeveldbPersistenceQueryDocSpec(config: String) extends AkkaSpec(config) {
|
|||
|
||||
"demonstrate EventsByTag" in {
|
||||
//#EventsByTag
|
||||
implicit val mat = ActorMaterializer()(system)
|
||||
val queries = PersistenceQuery(system).readJournalFor[LeveldbReadJournal](LeveldbReadJournal.Identifier)
|
||||
|
||||
val src: Source[EventEnvelope, NotUsed] =
|
||||
|
|
|
|||
|
|
@ -6,14 +6,11 @@ package docs.persistence.query
|
|||
|
||||
import akka.NotUsed
|
||||
import akka.actor._
|
||||
import akka.persistence.{ PersistentActor, Recovery }
|
||||
import akka.persistence.query._
|
||||
import akka.stream.{ ActorMaterializer, FlowShape }
|
||||
import akka.stream.scaladsl.{ Flow, Sink, Source }
|
||||
import akka.stream.javadsl
|
||||
import akka.testkit.AkkaSpec
|
||||
import akka.util.Timeout
|
||||
import docs.persistence.query.PersistenceQueryDocSpec.TheOneWhoWritesToQueryJournal
|
||||
import org.reactivestreams.Subscriber
|
||||
|
||||
import scala.collection.immutable
|
||||
|
|
@ -151,7 +148,6 @@ object PersistenceQueryDocSpec {
|
|||
|
||||
//#projection-into-different-store-rs
|
||||
implicit val system = ActorSystem()
|
||||
implicit val mat = ActorMaterializer()
|
||||
|
||||
val readJournal =
|
||||
PersistenceQuery(system).readJournalFor[MyScaladslReadJournal](JournalId)
|
||||
|
|
@ -202,8 +198,6 @@ class PersistenceQueryDocSpec(s: String) extends AkkaSpec(s) {
|
|||
""")
|
||||
}
|
||||
|
||||
implicit val mat = ActorMaterializer()
|
||||
|
||||
class BasicUsage {
|
||||
//#basic-usage
|
||||
// obtain read journal by plugin id
|
||||
|
|
@ -215,7 +209,6 @@ class PersistenceQueryDocSpec(s: String) extends AkkaSpec(s) {
|
|||
readJournal.eventsByPersistenceId("user-1337", 0, Long.MaxValue)
|
||||
|
||||
// materialize stream, consuming events
|
||||
implicit val mat = ActorMaterializer()
|
||||
source.runForeach { event =>
|
||||
println("Event: " + event)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,8 +148,6 @@ object BidiFlowDocSpec {
|
|||
class BidiFlowDocSpec extends AkkaSpec {
|
||||
import BidiFlowDocSpec._
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"A BidiFlow" must {
|
||||
|
||||
"compose" in {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import scala.concurrent.{ Future, Promise }
|
|||
class CompositionDocSpec extends AkkaSpec {
|
||||
|
||||
implicit val ec = system.dispatcher
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"nonnested flow" in {
|
||||
//#non-nested-flow
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
package docs.stream
|
||||
|
||||
import akka.{ Done, NotUsed }
|
||||
import akka.NotUsed
|
||||
import akka.actor.{ Actor, ActorSystem, Cancellable }
|
||||
import akka.stream.{ ActorMaterializer, ClosedShape, FlowShape, Materializer, OverflowStrategy }
|
||||
import akka.stream.ActorMaterializer
|
||||
import akka.stream.Materializer
|
||||
import akka.stream.{ ClosedShape, FlowShape, OverflowStrategy }
|
||||
import akka.stream.scaladsl._
|
||||
import akka.testkit.AkkaSpec
|
||||
import docs.CompileOnlySpec
|
||||
|
|
@ -18,12 +20,6 @@ class FlowDocSpec extends AkkaSpec with CompileOnlySpec {
|
|||
|
||||
implicit val ec = system.dispatcher
|
||||
|
||||
//#imports
|
||||
import akka.stream.ActorMaterializer
|
||||
//#imports
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"source is immutable" in {
|
||||
//#source-immutable
|
||||
val source = Source(1 to 10)
|
||||
|
|
@ -247,14 +243,6 @@ class FlowDocSpec extends AkkaSpec with CompileOnlySpec {
|
|||
|
||||
object FlowDocSpec {
|
||||
|
||||
{
|
||||
//#materializer-from-system
|
||||
implicit val system = ActorSystem("ExampleSystem")
|
||||
|
||||
implicit val mat = ActorMaterializer() // created from `system`
|
||||
//#materializer-from-system
|
||||
}
|
||||
|
||||
//#materializer-from-actor-context
|
||||
final class RunWithMyself extends Actor {
|
||||
implicit val mat = ActorMaterializer()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ class FlowErrorDocSpec extends AkkaSpec {
|
|||
|
||||
"demonstrate fail stream" in {
|
||||
//#stop
|
||||
implicit val materializer = ActorMaterializer()
|
||||
val source = Source(0 to 5).map(100 / _)
|
||||
val result = source.runWith(Sink.fold(0)(_ + _))
|
||||
// division by zero will fail the stream and the
|
||||
|
|
@ -48,7 +47,6 @@ class FlowErrorDocSpec extends AkkaSpec {
|
|||
|
||||
"demonstrate resume section" in {
|
||||
//#resume-section
|
||||
implicit val materializer = ActorMaterializer()
|
||||
val decider: Supervision.Decider = {
|
||||
case _: ArithmeticException => Supervision.Resume
|
||||
case _ => Supervision.Stop
|
||||
|
|
@ -69,7 +67,6 @@ class FlowErrorDocSpec extends AkkaSpec {
|
|||
|
||||
"demonstrate restart section" in {
|
||||
//#restart-section
|
||||
implicit val materializer = ActorMaterializer()
|
||||
val decider: Supervision.Decider = {
|
||||
case _: IllegalArgumentException => Supervision.Restart
|
||||
case _ => Supervision.Stop
|
||||
|
|
@ -91,7 +88,6 @@ class FlowErrorDocSpec extends AkkaSpec {
|
|||
}
|
||||
|
||||
"demonstrate recover" in {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
//#recover
|
||||
Source(0 to 6)
|
||||
.map(n =>
|
||||
|
|
@ -117,7 +113,6 @@ stream truncated
|
|||
}
|
||||
|
||||
"demonstrate recoverWithRetries" in {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
//#recoverWithRetries
|
||||
val planB = Source(List("five", "six", "seven", "eight"))
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import akka.stream.ActorMaterializer
|
|||
import akka.stream.scaladsl._
|
||||
import akka.testkit.AkkaSpec
|
||||
import docs.CompileOnlySpec
|
||||
import scala.concurrent.Future
|
||||
|
||||
class FlowStreamRefsDocSpec extends AkkaSpec with CompileOnlySpec {
|
||||
|
||||
|
|
@ -91,7 +90,6 @@ class FlowStreamRefsDocSpec extends AkkaSpec with CompileOnlySpec {
|
|||
|
||||
//#offer-sink
|
||||
|
||||
implicit val mat = ActorMaterializer()
|
||||
def localMetrics(): Source[String, NotUsed] = Source.single("")
|
||||
|
||||
//#offer-sink-use
|
||||
|
|
@ -106,8 +104,6 @@ class FlowStreamRefsDocSpec extends AkkaSpec with CompileOnlySpec {
|
|||
}
|
||||
|
||||
"show how to configure timeouts with attrs" in compileOnlySpec {
|
||||
|
||||
implicit val mat: ActorMaterializer = null
|
||||
//#attr-sub-timeout
|
||||
// configure the timeout for source
|
||||
import scala.concurrent.duration._
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ import akka.testkit.AkkaSpec
|
|||
|
||||
class GraphCyclesSpec extends AkkaSpec {
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"Cycle demonstration" must {
|
||||
val source = Source.fromIterator(() => Iterator.from(0))
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ class GraphDSLDocSpec extends AkkaSpec {
|
|||
|
||||
implicit val ec = system.dispatcher
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"build simple graph" in {
|
||||
//format: OFF
|
||||
//#simple-graph-dsl
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ import scala.collection.immutable.Iterable
|
|||
|
||||
class GraphStageDocSpec extends AkkaSpec {
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"Demonstrate creation of GraphStage boilerplate" in {
|
||||
//#boilerplate-example
|
||||
import akka.stream.SourceShape
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import akka.testkit.{ AkkaSpec, EventFilter }
|
|||
|
||||
class GraphStageLoggingDocSpec extends AkkaSpec("akka.loglevel = DEBUG") {
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
implicit val ec = system.dispatcher
|
||||
|
||||
//#operator-with-logging
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
package docs.stream
|
||||
|
||||
import akka.NotUsed
|
||||
import akka.stream.{ ActorMaterializer, KillSwitches, UniqueKillSwitch }
|
||||
import akka.stream.{ KillSwitches, UniqueKillSwitch }
|
||||
import akka.stream.scaladsl._
|
||||
import akka.testkit.AkkaSpec
|
||||
import docs.CompileOnlySpec
|
||||
|
|
@ -14,7 +14,6 @@ import scala.concurrent.duration._
|
|||
import akka.stream.ThrottleMode
|
||||
|
||||
class HubsDocSpec extends AkkaSpec with CompileOnlySpec {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"Hubs" must {
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import akka.stream._
|
|||
|
||||
import scala.concurrent.Future
|
||||
import akka.testkit.TestProbe
|
||||
import akka.actor.{ Actor, ActorLogging, ActorRef, Props, Status }
|
||||
import akka.actor.{ Actor, ActorLogging, ActorRef, Props }
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import akka.util.Timeout
|
||||
|
||||
|
|
@ -21,9 +21,6 @@ import scala.concurrent.ExecutionContext
|
|||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
import akka.stream.scaladsl.Flow
|
||||
import akka.Done
|
||||
import akka.actor.Status.Status
|
||||
import akka.stream.QueueOfferResult.{ Dropped, Enqueued }
|
||||
|
||||
object IntegrationDocSpec {
|
||||
import TwitterStreamQuickstartDocSpec._
|
||||
|
|
@ -137,7 +134,6 @@ class IntegrationDocSpec extends AkkaSpec(IntegrationDocSpec.config) {
|
|||
import TwitterStreamQuickstartDocSpec._
|
||||
import IntegrationDocSpec._
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
val ref: ActorRef = system.actorOf(Props[Translator])
|
||||
|
||||
"ask" in {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
package docs.stream
|
||||
|
||||
import akka.stream.scaladsl._
|
||||
import akka.stream.{ ActorMaterializer, DelayOverflowStrategy, KillSwitches }
|
||||
import akka.stream.{ DelayOverflowStrategy, KillSwitches }
|
||||
import akka.testkit.AkkaSpec
|
||||
import docs.CompileOnlySpec
|
||||
|
||||
|
|
@ -14,8 +14,6 @@ import scala.concurrent.duration._
|
|||
|
||||
class KillSwitchDocSpec extends AkkaSpec with CompileOnlySpec {
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"Unique kill switch" must {
|
||||
|
||||
"control graph completion with shutdown" in compileOnlySpec {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.scalatest.concurrent._
|
|||
|
||||
//#main-app
|
||||
object Main extends App {
|
||||
implicit val system = ActorSystem("QuickStart")
|
||||
// Code here
|
||||
}
|
||||
//#main-app
|
||||
|
|
@ -33,17 +34,14 @@ class QuickStartDocSpec extends WordSpec with BeforeAndAfterAll with ScalaFuture
|
|||
def println(any: Any) = () // silence printing stuff
|
||||
|
||||
"demonstrate Source" in {
|
||||
//#create-materializer
|
||||
implicit val system = ActorSystem("QuickStart")
|
||||
implicit val materializer = ActorMaterializer()
|
||||
//#create-materializer
|
||||
|
||||
//#create-source
|
||||
val source: Source[Int, NotUsed] = Source(1 to 100)
|
||||
//#create-source
|
||||
|
||||
//#run-source
|
||||
source.runForeach(i => println(i))(materializer)
|
||||
source.runForeach(i => println(i))
|
||||
//#run-source
|
||||
|
||||
//#transform-source
|
||||
|
|
@ -68,7 +66,7 @@ class QuickStartDocSpec extends WordSpec with BeforeAndAfterAll with ScalaFuture
|
|||
//#add-streams
|
||||
|
||||
//#run-source-and-terminate
|
||||
val done: Future[Done] = source.runForeach(i => println(i))(materializer)
|
||||
val done: Future[Done] = source.runForeach(i => println(i))
|
||||
|
||||
implicit val ec = system.dispatcher
|
||||
done.onComplete(_ => system.terminate())
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
package docs.stream
|
||||
|
||||
import akka.stream._
|
||||
import akka.stream.scaladsl._
|
||||
import akka.stream.testkit.scaladsl._
|
||||
|
||||
|
|
@ -18,8 +17,6 @@ import scala.concurrent.Await
|
|||
|
||||
class RateTransformationDocSpec extends AkkaSpec {
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"conflate should summarize" in {
|
||||
//#conflate-summarize
|
||||
val statsFlow = Flow[Double].conflateWithSeed(immutable.Seq(_))(_ :+ _).map { s =>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
package docs.stream
|
||||
|
||||
import akka.NotUsed
|
||||
import akka.stream.ActorMaterializer
|
||||
import akka.stream.scaladsl.{ Flow, Sink, Source }
|
||||
import akka.stream.testkit._
|
||||
import org.reactivestreams.Processor
|
||||
|
|
@ -14,8 +13,6 @@ import akka.testkit.AkkaSpec
|
|||
class ReactiveStreamsDocSpec extends AkkaSpec {
|
||||
import TwitterStreamQuickstartDocSpec._
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
//#imports
|
||||
import org.reactivestreams.Publisher
|
||||
import org.reactivestreams.Subscriber
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
package docs.stream
|
||||
|
||||
import akka.NotUsed
|
||||
import akka.stream.{ ActorMaterializer, KillSwitches }
|
||||
import akka.stream.KillSwitches
|
||||
import akka.stream.scaladsl._
|
||||
import akka.testkit.AkkaSpec
|
||||
import docs.CompileOnlySpec
|
||||
|
|
@ -14,7 +14,6 @@ import scala.concurrent.duration._
|
|||
import scala.concurrent._
|
||||
|
||||
class RestartDocSpec extends AkkaSpec with CompileOnlySpec {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
import system.dispatcher
|
||||
|
||||
// Mock akka-http interfaces
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import akka.stream.scaladsl._
|
|||
import akka.testkit.AkkaSpec
|
||||
|
||||
class StreamBuffersRateSpec extends AkkaSpec {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"Demonstrate pipelining" in {
|
||||
def println(s: Any) = ()
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ class StreamPartialGraphDSLDocSpec extends AkkaSpec {
|
|||
|
||||
implicit val ec = system.dispatcher
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"build with open ports" in {
|
||||
//#simple-partial-graph-dsl
|
||||
val pickMaxOfThree = GraphDSL.create() { implicit b =>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package docs.stream
|
|||
|
||||
import akka.stream._
|
||||
import akka.stream.scaladsl._
|
||||
import akka.stream.testkit._
|
||||
import akka.stream.testkit.scaladsl._
|
||||
import scala.util._
|
||||
import scala.concurrent.duration._
|
||||
|
|
@ -16,8 +15,6 @@ import akka.pattern
|
|||
|
||||
class StreamTestKitDocSpec extends AkkaSpec {
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"strict collection" in {
|
||||
//#strict-collection
|
||||
val sinkUnderTest = Flow[Int].map(_ * 2).toMat(Sink.fold(0)(_ + _))(Keep.right)
|
||||
|
|
|
|||
|
|
@ -5,11 +5,10 @@
|
|||
package docs.stream
|
||||
|
||||
import akka.stream.scaladsl.{ Sink, Source }
|
||||
import akka.stream.{ ActorMaterializer, SubstreamCancelStrategy }
|
||||
import akka.stream.{ SubstreamCancelStrategy }
|
||||
import akka.testkit.AkkaSpec
|
||||
|
||||
class SubstreamDocSpec extends AkkaSpec {
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"generate substreams by groupBy" in {
|
||||
//#groupBy1
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package docs.stream
|
|||
|
||||
import akka.{ Done, NotUsed }
|
||||
import akka.actor.ActorSystem
|
||||
import akka.stream.{ ActorMaterializer, ClosedShape, OverflowStrategy }
|
||||
import akka.stream.{ ClosedShape, OverflowStrategy }
|
||||
import akka.stream.scaladsl._
|
||||
import scala.concurrent.Await
|
||||
import scala.concurrent.Future
|
||||
|
|
@ -79,17 +79,14 @@ class TwitterStreamQuickstartDocSpec extends AkkaSpec {
|
|||
trait Example1 {
|
||||
//#fiddle_code
|
||||
//#first-sample
|
||||
//#materializer-setup
|
||||
//#system-setup
|
||||
implicit val system = ActorSystem("reactive-tweets")
|
||||
implicit val materializer = ActorMaterializer()
|
||||
//#materializer-setup
|
||||
//#system-setup
|
||||
//#first-sample
|
||||
|
||||
//#fiddle_code
|
||||
}
|
||||
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
"filter and map" in {
|
||||
//#first-sample
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@
|
|||
|
||||
package docs.stream.cookbook
|
||||
|
||||
import akka.stream.ActorMaterializer
|
||||
import akka.testkit.AkkaSpec
|
||||
|
||||
trait RecipeSpec extends AkkaSpec {
|
||||
|
||||
implicit val m = ActorMaterializer()
|
||||
type Message = String
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import scala.concurrent.Future
|
|||
class StreamFileDocSpec extends AkkaSpec(UnboundedMailboxConfig) {
|
||||
|
||||
implicit val ec = system.dispatcher
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
// silence sysout
|
||||
def println(s: String) = ()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package docs.stream.io
|
|||
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
import akka.stream._
|
||||
import akka.stream.scaladsl.Tcp._
|
||||
import akka.stream.scaladsl._
|
||||
import akka.testkit.AkkaSpec
|
||||
|
|
@ -19,7 +18,6 @@ import akka.testkit.SocketUtil
|
|||
class StreamTcpDocSpec extends AkkaSpec {
|
||||
|
||||
implicit val ec = system.dispatcher
|
||||
implicit val materializer = ActorMaterializer()
|
||||
|
||||
// silence sysout
|
||||
def println(s: String) = ()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
package docs.stream.operators
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import akka.stream.ActorMaterializer
|
||||
import akka.testkit.TestProbe
|
||||
|
||||
object SourceOperators {
|
||||
|
|
@ -21,7 +20,6 @@ object SourceOperators {
|
|||
import scala.concurrent.Future
|
||||
|
||||
implicit val system: ActorSystem = ActorSystem()
|
||||
implicit val materializer: ActorMaterializer = ActorMaterializer()
|
||||
|
||||
val source: Source[Int, NotUsed] = Source.fromFuture(Future.successful(10))
|
||||
val sink: Sink[Int, Future[Done]] = Sink.foreach((i: Int) => println(i))
|
||||
|
|
@ -40,7 +38,6 @@ object SourceOperators {
|
|||
import akka.stream.scaladsl._
|
||||
|
||||
implicit val system: ActorSystem = ActorSystem()
|
||||
implicit val materializer: ActorMaterializer = ActorMaterializer()
|
||||
val bufferSize = 100
|
||||
|
||||
val source: Source[Any, ActorRef] = Source.actorRef[Any](bufferSize, OverflowStrategy.dropHead)
|
||||
|
|
@ -63,7 +60,6 @@ object SourceOperators {
|
|||
import akka.stream.scaladsl._
|
||||
|
||||
implicit val system: ActorSystem = ActorSystem()
|
||||
implicit val materializer: ActorMaterializer = ActorMaterializer()
|
||||
val probe = TestProbe()
|
||||
|
||||
val source: Source[Any, ActorRef] = Source.actorRefWithAck[Any]("ack")
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ object Scan {
|
|||
import akka.stream.ActorMaterializer
|
||||
|
||||
implicit val system: ActorSystem = ActorSystem()
|
||||
implicit val materializer: ActorMaterializer = ActorMaterializer()
|
||||
|
||||
//#scan
|
||||
val source = Source(1 to 5)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import scala.annotation.tailrec
|
|||
import scala.concurrent.duration._
|
||||
import java.util.concurrent.ThreadLocalRandom
|
||||
|
||||
import akka.stream.SystemMaterializer
|
||||
|
||||
trait ScriptedTest extends Matchers {
|
||||
|
||||
class ScriptException(msg: String) extends RuntimeException(msg)
|
||||
|
|
@ -228,6 +230,10 @@ trait ScriptedTest extends Matchers {
|
|||
|
||||
}
|
||||
|
||||
def runScript[In, Out, M](script: Script[In, Out])(op: Flow[In, In, NotUsed] => Flow[In, Out, M])(
|
||||
implicit system: ActorSystem): Unit =
|
||||
runScript(script, SystemMaterializer(system).materializer.settings)(op)(system)
|
||||
|
||||
def runScript[In, Out, M](
|
||||
script: Script[In, Out],
|
||||
settings: ActorMaterializerSettings,
|
||||
|
|
|
|||
|
|
@ -4,33 +4,14 @@
|
|||
|
||||
package akka.stream;
|
||||
|
||||
import akka.stream.testkit.javadsl.StreamTestKit;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.scalatest.junit.JUnitSuite;
|
||||
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.testkit.AkkaJUnitActorSystemResource;
|
||||
import org.scalatest.junit.JUnitSuite;
|
||||
|
||||
public abstract class StreamTest extends JUnitSuite {
|
||||
protected final ActorSystem system;
|
||||
private final ActorMaterializerSettings settings;
|
||||
|
||||
protected ActorMaterializer materializer;
|
||||
|
||||
protected StreamTest(AkkaJUnitActorSystemResource actorSystemResource) {
|
||||
system = actorSystemResource.getSystem();
|
||||
settings = ActorMaterializerSettings.create(system);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
materializer = ActorMaterializer.create(settings, system);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
StreamTestKit.assertAllStagesStopped(materializer);
|
||||
materializer.shutdown();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class InputStreamSinkTest extends StreamTest {
|
|||
|
||||
final Sink<ByteString, InputStream> sink = StreamConverters.asInputStream(timeout);
|
||||
final List<ByteString> list = Collections.singletonList(ByteString.fromString("a"));
|
||||
final InputStream stream = Source.from(list).runWith(sink, materializer);
|
||||
final InputStream stream = Source.from(list).runWith(sink, system);
|
||||
|
||||
byte[] a = new byte[1];
|
||||
stream.read(a);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class OutputStreamSinkTest extends StreamTest {
|
|||
};
|
||||
final CompletionStage<IOResult> resultFuture =
|
||||
Source.single(ByteString.fromString("123456"))
|
||||
.runWith(StreamConverters.fromOutputStream(() -> os), materializer);
|
||||
.runWith(StreamConverters.fromOutputStream(() -> os), system);
|
||||
try {
|
||||
resultFuture.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
Assert.fail("expected IOIncompleteException");
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class OutputStreamSourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
}))
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
|
||||
s.write("a".getBytes());
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ public class SinkAsJavaSourceTest extends StreamTest {
|
|||
public void mustBeAbleToUseAsJavaStream() throws Exception {
|
||||
final List<Integer> list = Arrays.asList(1, 2, 3);
|
||||
final Sink<Integer, Stream<Integer>> streamSink = StreamConverters.asJavaStream();
|
||||
java.util.stream.Stream<Integer> javaStream =
|
||||
Source.from(list).runWith(streamSink, materializer);
|
||||
java.util.stream.Stream<Integer> javaStream = Source.from(list).runWith(streamSink, system);
|
||||
assertEquals(list, javaStream.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public class FlowTest extends StreamTest {
|
|||
});
|
||||
|
||||
ints.via(flow1.via(flow2))
|
||||
.runFold("", (acc, elem) -> acc + elem, materializer)
|
||||
.runFold("", (acc, elem) -> acc + elem, system)
|
||||
.thenAccept(elem -> probe.getRef().tell(elem, ActorRef.noSender()));
|
||||
|
||||
probe.expectMsgEquals("de");
|
||||
|
|
@ -118,8 +118,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgEquals(2);
|
||||
probe.expectMsgEquals(3);
|
||||
|
|
@ -144,7 +143,7 @@ public class FlowTest extends StreamTest {
|
|||
});
|
||||
|
||||
ints.via(flow)
|
||||
.runFold("", (acc, elem) -> acc + elem, materializer)
|
||||
.runFold("", (acc, elem) -> acc + elem, system)
|
||||
.thenAccept(elem -> probe.getRef().tell(elem, ActorRef.noSender()));
|
||||
|
||||
probe.expectMsgEquals("2334445555");
|
||||
|
|
@ -159,8 +158,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgEquals("[");
|
||||
probe.expectMsgEquals("0");
|
||||
|
|
@ -183,8 +181,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
Source.single(">> ")
|
||||
.concat(source.via(flow))
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgEquals(">> ");
|
||||
probe.expectMsgEquals("0");
|
||||
|
|
@ -213,8 +210,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgEquals(0);
|
||||
probe.expectMsgEquals(1);
|
||||
|
|
@ -281,8 +277,7 @@ public class FlowTest extends StreamTest {
|
|||
Source.from(input)
|
||||
.via(flow)
|
||||
.runForeach(
|
||||
(Procedure<Integer>) elem -> probe.getRef().tell(elem, ActorRef.noSender()),
|
||||
materializer);
|
||||
(Procedure<Integer>) elem -> probe.getRef().tell(elem, ActorRef.noSender()), system);
|
||||
|
||||
probe.expectMsgEquals(0);
|
||||
probe.expectMsgEquals(0);
|
||||
|
|
@ -312,7 +307,7 @@ public class FlowTest extends StreamTest {
|
|||
.mergeSubstreams();
|
||||
|
||||
final CompletionStage<List<List<String>>> future =
|
||||
Source.from(input).via(flow).limit(10).runWith(Sink.<List<String>>seq(), materializer);
|
||||
Source.from(input).via(flow).limit(10).runWith(Sink.<List<String>>seq(), system);
|
||||
final Object[] result = future.toCompletableFuture().get(1, TimeUnit.SECONDS).toArray();
|
||||
Arrays.sort(
|
||||
result,
|
||||
|
|
@ -347,7 +342,7 @@ public class FlowTest extends StreamTest {
|
|||
.concatSubstreams();
|
||||
|
||||
final CompletionStage<List<List<String>>> future =
|
||||
Source.from(input).via(flow).limit(10).runWith(Sink.<List<String>>seq(), materializer);
|
||||
Source.from(input).via(flow).limit(10).runWith(Sink.<List<String>>seq(), system);
|
||||
final List<List<String>> result = future.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
|
||||
assertEquals(
|
||||
|
|
@ -371,7 +366,7 @@ public class FlowTest extends StreamTest {
|
|||
.concatSubstreams();
|
||||
|
||||
final CompletionStage<List<List<String>>> future =
|
||||
Source.from(input).via(flow).limit(10).runWith(Sink.<List<String>>seq(), materializer);
|
||||
Source.from(input).via(flow).limit(10).runWith(Sink.<List<String>>seq(), system);
|
||||
final List<List<String>> result = future.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
|
||||
assertEquals(
|
||||
|
|
@ -445,9 +440,9 @@ public class FlowTest extends StreamTest {
|
|||
}));
|
||||
|
||||
// collecting
|
||||
final Publisher<String> pub = source.runWith(publisher, materializer);
|
||||
final Publisher<String> pub = source.runWith(publisher, system);
|
||||
final CompletionStage<List<String>> all =
|
||||
Source.fromPublisher(pub).limit(100).runWith(Sink.<String>seq(), materializer);
|
||||
Source.fromPublisher(pub).limit(100).runWith(Sink.<String>seq(), system);
|
||||
|
||||
final List<String> result = all.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(
|
||||
|
|
@ -498,9 +493,9 @@ public class FlowTest extends StreamTest {
|
|||
final Source<String, CompletionStage<NotUsed>> source = Source.fromSourceCompletionStage(stage);
|
||||
|
||||
// collecting
|
||||
final Publisher<String> pub = source.runWith(publisher, materializer);
|
||||
final Publisher<String> pub = source.runWith(publisher, system);
|
||||
final CompletionStage<List<String>> all =
|
||||
Source.fromPublisher(pub).limit(100).runWith(Sink.<String>seq(), materializer);
|
||||
Source.fromPublisher(pub).limit(100).runWith(Sink.<String>seq(), system);
|
||||
|
||||
final List<String> result = all.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(
|
||||
|
|
@ -538,7 +533,7 @@ public class FlowTest extends StreamTest {
|
|||
return ClosedShape.getInstance();
|
||||
}
|
||||
}))
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
|
||||
List<Object> output = probe.receiveN(3);
|
||||
List<Pair<String, Integer>> expected =
|
||||
|
|
@ -567,7 +562,7 @@ public class FlowTest extends StreamTest {
|
|||
});
|
||||
Flow<String, Pair<String, Integer>, NotUsed> fl =
|
||||
Flow.<String>create().zipAll(src2, "MISSING", -1);
|
||||
src1.via(fl).runWith(sink, materializer);
|
||||
src1.via(fl).runWith(sink, system);
|
||||
|
||||
List<Object> output = probe.receiveN(4);
|
||||
List<Pair<String, Integer>> expected =
|
||||
|
|
@ -595,7 +590,7 @@ public class FlowTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
List<Object> output = probe.receiveN(6);
|
||||
assertEquals(Arrays.asList("A", "B", "C", "D", "E", "F"), output);
|
||||
|
|
@ -617,7 +612,7 @@ public class FlowTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
List<Object> output = probe.receiveN(6);
|
||||
assertEquals(Arrays.asList("A", "B", "C", "D", "E", "F"), output);
|
||||
|
|
@ -632,13 +627,13 @@ public class FlowTest extends StreamTest {
|
|||
CompletionStage<Pair<List<Integer>, Source<Integer, NotUsed>>> future =
|
||||
Source.from(input)
|
||||
.via(flow)
|
||||
.runWith(Sink.<Pair<List<Integer>, Source<Integer, NotUsed>>>head(), materializer);
|
||||
.runWith(Sink.<Pair<List<Integer>, Source<Integer, NotUsed>>>head(), system);
|
||||
Pair<List<Integer>, Source<Integer, NotUsed>> result =
|
||||
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(Arrays.asList(1, 2, 3), result.first());
|
||||
|
||||
CompletionStage<List<Integer>> tailFuture =
|
||||
result.second().limit(4).runWith(Sink.<Integer>seq(), materializer);
|
||||
result.second().limit(4).runWith(Sink.<Integer>seq(), system);
|
||||
List<Integer> tailResult = tailFuture.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(Arrays.asList(4, 5, 6), tailResult);
|
||||
}
|
||||
|
|
@ -658,7 +653,7 @@ public class FlowTest extends StreamTest {
|
|||
.flatMapConcat(ConstantFun.<Source<Integer, NotUsed>>javaIdentityFunction())
|
||||
.grouped(6);
|
||||
CompletionStage<List<Integer>> future =
|
||||
Source.from(mainInputs).via(flow).runWith(Sink.<List<Integer>>head(), materializer);
|
||||
Source.from(mainInputs).via(flow).runWith(Sink.<List<Integer>>head(), system);
|
||||
|
||||
List<Integer> result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -684,7 +679,7 @@ public class FlowTest extends StreamTest {
|
|||
.flatMapMerge(3, ConstantFun.<Source<Integer, NotUsed>>javaIdentityFunction())
|
||||
.grouped(60);
|
||||
CompletionStage<List<Integer>> future =
|
||||
Source.from(mainInputs).via(flow).runWith(Sink.<List<Integer>>head(), materializer);
|
||||
Source.from(mainInputs).via(flow).runWith(Sink.<List<Integer>>head(), system);
|
||||
|
||||
List<Integer> result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
final Set<Integer> set = new HashSet<Integer>();
|
||||
|
|
@ -706,7 +701,7 @@ public class FlowTest extends StreamTest {
|
|||
final Flow<String, List<String>, NotUsed> flow =
|
||||
Flow.of(String.class).buffer(2, OverflowStrategy.backpressure()).grouped(4);
|
||||
final CompletionStage<List<String>> future =
|
||||
Source.from(input).via(flow).runWith(Sink.<List<String>>head(), materializer);
|
||||
Source.from(input).via(flow).runWith(Sink.<List<String>>head(), system);
|
||||
|
||||
List<String> result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(input, result);
|
||||
|
|
@ -716,7 +711,7 @@ public class FlowTest extends StreamTest {
|
|||
public void mustBeAbleToUseWatchTermination() throws Exception {
|
||||
final List<String> input = Arrays.asList("A", "B", "C");
|
||||
CompletionStage<Done> future =
|
||||
Source.from(input).watchTermination(Keep.right()).to(Sink.ignore()).run(materializer);
|
||||
Source.from(input).watchTermination(Keep.right()).to(Sink.ignore()).run(system);
|
||||
|
||||
assertEquals(done(), future.toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -741,14 +736,14 @@ public class FlowTest extends StreamTest {
|
|||
}
|
||||
});
|
||||
CompletionStage<String> future =
|
||||
Source.from(input).via(flow).runFold("", (aggr, in) -> aggr + in, materializer);
|
||||
Source.from(input).via(flow).runFold("", (aggr, in) -> aggr + in, system);
|
||||
String result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("ABC", result);
|
||||
|
||||
final Flow<String, String, NotUsed> flow2 = Flow.of(String.class).conflate((a, b) -> a + b);
|
||||
|
||||
CompletionStage<String> future2 =
|
||||
Source.from(input).via(flow2).runFold("", (a, b) -> a + b, materializer);
|
||||
Source.from(input).via(flow2).runFold("", (a, b) -> a + b, system);
|
||||
String result2 = future2.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("ABC", result2);
|
||||
}
|
||||
|
|
@ -774,7 +769,7 @@ public class FlowTest extends StreamTest {
|
|||
}
|
||||
});
|
||||
CompletionStage<String> future =
|
||||
Source.from(input).via(flow).runFold("", (aggr, in) -> aggr + in, materializer);
|
||||
Source.from(input).via(flow).runFold("", (aggr, in) -> aggr + in, system);
|
||||
String result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("ABC", result);
|
||||
}
|
||||
|
|
@ -806,7 +801,7 @@ public class FlowTest extends StreamTest {
|
|||
}
|
||||
});
|
||||
CompletionStage<String> future =
|
||||
Source.from(input).via(flow).runFold("", (aggr, in) -> aggr + in, materializer);
|
||||
Source.from(input).via(flow).runFold("", (aggr, in) -> aggr + in, system);
|
||||
String result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("ABC", result);
|
||||
}
|
||||
|
|
@ -818,7 +813,7 @@ public class FlowTest extends StreamTest {
|
|||
final Flow<String, String, NotUsed> flow =
|
||||
Flow.of(String.class).expand(in -> Stream.iterate(in, i -> i).iterator());
|
||||
final Sink<String, CompletionStage<String>> sink = Sink.<String>head();
|
||||
CompletionStage<String> future = Source.from(input).via(flow).runWith(sink, materializer);
|
||||
CompletionStage<String> future = Source.from(input).via(flow).runWith(sink, system);
|
||||
String result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("A", result);
|
||||
}
|
||||
|
|
@ -838,7 +833,7 @@ public class FlowTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
probe.expectMsgEquals("A");
|
||||
probe.expectMsgEquals("B");
|
||||
probe.expectMsgEquals("C");
|
||||
|
|
@ -852,7 +847,7 @@ public class FlowTest extends StreamTest {
|
|||
List<Void> result =
|
||||
Source.from(input)
|
||||
.via(flow)
|
||||
.runWith(Sink.seq(), materializer)
|
||||
.runWith(Sink.seq(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -867,7 +862,7 @@ public class FlowTest extends StreamTest {
|
|||
|
||||
Source.from(input)
|
||||
.via(Flow.of(FlowSpec.Fruit.class).collectType(FlowSpec.Apple.class))
|
||||
.runForeach((apple) -> probe.getRef().tell(apple, ActorRef.noSender()), materializer);
|
||||
.runForeach((apple) -> probe.getRef().tell(apple, ActorRef.noSender()), system);
|
||||
probe.expectMsgAnyClassOf(FlowSpec.Apple.class);
|
||||
}
|
||||
|
||||
|
|
@ -896,8 +891,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
final PublisherProbeSubscription<Integer> s = publisherProbe.expectSubscription();
|
||||
|
||||
|
|
@ -929,8 +923,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
final PublisherProbeSubscription<Integer> s = publisherProbe.expectSubscription();
|
||||
|
||||
|
|
@ -969,8 +962,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
final PublisherProbeSubscription<Integer> s = publisherProbe.expectSubscription();
|
||||
|
||||
|
|
@ -1004,8 +996,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
final PublisherProbeSubscription<Integer> s = publisherProbe.expectSubscription();
|
||||
|
||||
|
|
@ -1041,8 +1032,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
final PublisherProbeSubscription<Integer> s = publisherProbe.expectSubscription();
|
||||
|
||||
|
|
@ -1076,8 +1066,7 @@ public class FlowTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
source
|
||||
.via(flow)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
final PublisherProbeSubscription<Integer> s = publisherProbe.expectSubscription();
|
||||
|
||||
|
|
@ -1108,7 +1097,7 @@ public class FlowTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
}),
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgAllOf("A", "B", "C");
|
||||
}
|
||||
|
|
@ -1130,7 +1119,7 @@ public class FlowTest extends StreamTest {
|
|||
}
|
||||
})));
|
||||
|
||||
Source.from(input).to(sink).run(materializer);
|
||||
Source.from(input).to(sink).run(system);
|
||||
probe.expectMsgAllOf("A", "B", "C");
|
||||
}
|
||||
|
||||
|
|
@ -1154,7 +1143,7 @@ public class FlowTest extends StreamTest {
|
|||
|
||||
final TestKit probe = new TestKit(system);
|
||||
Source<String, ActorRef> source = Source.actorRef(1, OverflowStrategy.dropNew());
|
||||
final ActorRef actor = source.toMat(sink, Keep.<ActorRef, NotUsed>left()).run(materializer);
|
||||
final ActorRef actor = source.toMat(sink, Keep.<ActorRef, NotUsed>left()).run(system);
|
||||
probe.watch(actor);
|
||||
probe.expectTerminated(actor);
|
||||
}
|
||||
|
|
@ -1181,7 +1170,7 @@ public class FlowTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgEquals("A-D");
|
||||
probe.expectMsgEquals("B-E");
|
||||
|
|
@ -1202,7 +1191,7 @@ public class FlowTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgEquals(new Pair<String, String>("A", "D"));
|
||||
probe.expectMsgEquals(new Pair<String, String>("B", "E"));
|
||||
|
|
@ -1223,7 +1212,7 @@ public class FlowTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgAllOf("A", "B", "C", "D", "E", "F");
|
||||
}
|
||||
|
|
@ -1234,7 +1223,7 @@ public class FlowTest extends StreamTest {
|
|||
try {
|
||||
Source.<Integer>maybe()
|
||||
.via(Flow.of(Integer.class).initialTimeout(Duration.ofSeconds(1)))
|
||||
.runWith(Sink.<Integer>head(), materializer)
|
||||
.runWith(Sink.<Integer>head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
|
|
@ -1252,7 +1241,7 @@ public class FlowTest extends StreamTest {
|
|||
try {
|
||||
Source.<Integer>maybe()
|
||||
.via(Flow.of(Integer.class).completionTimeout(Duration.ofSeconds(1)))
|
||||
.runWith(Sink.<Integer>head(), materializer)
|
||||
.runWith(Sink.<Integer>head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
|
|
@ -1270,7 +1259,7 @@ public class FlowTest extends StreamTest {
|
|||
try {
|
||||
Source.<Integer>maybe()
|
||||
.via(Flow.of(Integer.class).idleTimeout(Duration.ofSeconds(1)))
|
||||
.runWith(Sink.<Integer>head(), materializer)
|
||||
.runWith(Sink.<Integer>head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
|
|
@ -1289,7 +1278,7 @@ public class FlowTest extends StreamTest {
|
|||
.via(
|
||||
Flow.of(Integer.class).keepAlive(Duration.ofSeconds(1), (Creator<Integer>) () -> 0))
|
||||
.takeWithin(Duration.ofMillis(1500))
|
||||
.runWith(Sink.<Integer>head(), materializer)
|
||||
.runWith(Sink.<Integer>head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -1301,7 +1290,7 @@ public class FlowTest extends StreamTest {
|
|||
List<Integer> out =
|
||||
Source.range(0, 2)
|
||||
.via(Flow.fromFunction((Integer x) -> x + 1))
|
||||
.runWith(Sink.seq(), materializer)
|
||||
.runWith(Sink.seq(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -1341,7 +1330,7 @@ public class FlowTest extends StreamTest {
|
|||
Integer result =
|
||||
Source.range(1, 10)
|
||||
.via(Flow.lazyInitAsync(() -> future))
|
||||
.runWith(Sink.<Integer>head(), materializer)
|
||||
.runWith(Sink.<Integer>head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class FlowThrottleTest extends StreamTest {
|
|||
.throttle(1, java.time.Duration.ofDays(1), 1, ThrottleMode.enforcing());
|
||||
|
||||
CompletionStage<List<Integer>> result1 =
|
||||
Source.single(1).via(sharedThrottle).via(sharedThrottle).runWith(Sink.seq(), materializer);
|
||||
Source.single(1).via(sharedThrottle).via(sharedThrottle).runWith(Sink.seq(), system);
|
||||
|
||||
// If there is accidental shared state then we would not be able to pass through the single
|
||||
// element
|
||||
|
|
@ -44,7 +44,7 @@ public class FlowThrottleTest extends StreamTest {
|
|||
|
||||
// It works with a new stream, too
|
||||
CompletionStage<List<Integer>> result2 =
|
||||
Source.single(1).via(sharedThrottle).via(sharedThrottle).runWith(Sink.seq(), materializer);
|
||||
Source.single(1).via(sharedThrottle).via(sharedThrottle).runWith(Sink.seq(), system);
|
||||
|
||||
assertEquals(
|
||||
result2.toCompletableFuture().get(3, TimeUnit.SECONDS), Collections.singletonList(1));
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class FlowWithContextTest extends StreamTest {
|
|||
final CompletionStage<List<Pair<Integer, String>>> result =
|
||||
Source.single(new Pair<>(1, "context"))
|
||||
.via(flow.map(n -> n + 1).mapContext(ctx -> ctx + "-mapped"))
|
||||
.runWith(Sink.seq(), materializer);
|
||||
.runWith(Sink.seq(), system);
|
||||
final List<Pair<Integer, String>> pairs = result.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(1, pairs.size());
|
||||
assertEquals(Integer.valueOf(2), pairs.get(0).first());
|
||||
|
|
@ -54,9 +54,7 @@ public class FlowWithContextTest extends StreamTest {
|
|||
final FlowWithContext<Integer, NotUsed, String, NotUsed, NotUsed> flow3 = flow1.via(flow2);
|
||||
|
||||
final CompletionStage<List<Pair<String, NotUsed>>> result =
|
||||
Source.single(new Pair<>(1, notUsed()))
|
||||
.via(flow3.asFlow())
|
||||
.runWith(Sink.seq(), materializer);
|
||||
Source.single(new Pair<>(1, notUsed())).via(flow3.asFlow()).runWith(Sink.seq(), system);
|
||||
|
||||
List<Pair<String, NotUsed>> pairs = result.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@ public class FramingTest extends StreamTest {
|
|||
in.via(
|
||||
Framing.delimiter(
|
||||
ByteString.fromString(","), Integer.MAX_VALUE, FramingTruncation.ALLOW))
|
||||
.runWith(Sink.ignore(), materializer);
|
||||
.runWith(Sink.ignore(), system);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,8 +67,7 @@ public class GraphDslTest extends StreamTest {
|
|||
return ClosedShape.getInstance();
|
||||
}));
|
||||
// #simple-graph-dsl
|
||||
final List<String> list =
|
||||
result.run(materializer).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
final List<String> list = result.run(system).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
final String[] res = list.toArray(new String[] {});
|
||||
Arrays.sort(res, null);
|
||||
assertArrayEquals(
|
||||
|
|
@ -128,7 +127,7 @@ public class GraphDslTest extends StreamTest {
|
|||
return ClosedShape.getInstance();
|
||||
}));
|
||||
// #graph-dsl-reusing-a-flow
|
||||
final Pair<CompletionStage<Integer>, CompletionStage<Integer>> pair = g.run(materializer);
|
||||
final Pair<CompletionStage<Integer>, CompletionStage<Integer>> pair = g.run(system);
|
||||
assertEquals(Integer.valueOf(2), pair.first().toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
assertEquals(Integer.valueOf(2), pair.second().toCompletableFuture().get(3, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -209,7 +208,7 @@ public class GraphDslTest extends StreamTest {
|
|||
|
||||
return ClosedShape.getInstance();
|
||||
}));
|
||||
List<CompletionStage<String>> result = g.run(materializer);
|
||||
List<CompletionStage<String>> result = g.run(system);
|
||||
// #graph-from-list
|
||||
|
||||
assertEquals(3, result.size());
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class JsonFramingTest extends StreamTest {
|
|||
acc.add(entry.utf8String());
|
||||
return acc;
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
// #using-json-framing
|
||||
|
||||
List<String> frames = result.toCompletableFuture().get(5, TimeUnit.SECONDS);
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ public class KillSwitchTest extends StreamTest {
|
|||
Source.fromPublisher(upstream)
|
||||
.viaMat(killSwitch.flow(), Keep.right())
|
||||
.to(Sink.fromSubscriber(downstream))
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
|
||||
final CompletionStage<Done> completionStage =
|
||||
Source.single(1).via(killSwitch.flow()).runWith(Sink.ignore(), materializer);
|
||||
Source.single(1).via(killSwitch.flow()).runWith(Sink.ignore(), system);
|
||||
|
||||
downstream.request(1);
|
||||
upstream.sendNext(1);
|
||||
|
|
@ -66,7 +66,7 @@ public class KillSwitchTest extends StreamTest {
|
|||
|
||||
Source.fromPublisher(upstream)
|
||||
.viaMat(killSwitch.flow(), Keep.right())
|
||||
.runWith(Sink.fromSubscriber(downstream), materializer);
|
||||
.runWith(Sink.fromSubscriber(downstream), system);
|
||||
|
||||
downstream.request(1);
|
||||
upstream.sendNext(1);
|
||||
|
|
@ -92,7 +92,7 @@ public class KillSwitchTest extends StreamTest {
|
|||
Source.fromPublisher(upstream)
|
||||
.viaMat(killSwitchFlow, Keep.right())
|
||||
.to(Sink.fromSubscriber(downstream))
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
|
||||
downstream.request(1);
|
||||
upstream.sendNext(1);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package akka.stream.javadsl;
|
|||
|
||||
import akka.NotUsed;
|
||||
import akka.stream.StreamTest;
|
||||
import akka.stream.SystemMaterializer;
|
||||
import akka.testkit.AkkaJUnitActorSystemResource;
|
||||
import akka.testkit.AkkaSpec;
|
||||
import org.junit.ClassRule;
|
||||
|
|
@ -26,7 +27,8 @@ public class RunnableGraphTest extends StreamTest {
|
|||
public void beAbleToConvertFromJavaToScala() {
|
||||
final RunnableGraph<NotUsed> javaRunnable = Source.empty().to(Sink.ignore());
|
||||
final akka.stream.scaladsl.RunnableGraph<NotUsed> scalaRunnable = javaRunnable.asScala();
|
||||
assertEquals(NotUsed.getInstance(), scalaRunnable.run(materializer));
|
||||
assertEquals(
|
||||
NotUsed.getInstance(), scalaRunnable.run(SystemMaterializer.get(system).materializer()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -34,6 +36,6 @@ public class RunnableGraphTest extends StreamTest {
|
|||
final akka.stream.scaladsl.RunnableGraph<NotUsed> scalaRunnable =
|
||||
akka.stream.scaladsl.Source.empty().to(akka.stream.scaladsl.Sink.ignore());
|
||||
final RunnableGraph<NotUsed> javaRunnable = scalaRunnable.asJava();
|
||||
assertEquals(NotUsed.getInstance(), javaRunnable.run(materializer));
|
||||
assertEquals(NotUsed.getInstance(), javaRunnable.run(system));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class SetupTest extends StreamTest {
|
|||
|
||||
assertEquals(
|
||||
Pair.create(false, false),
|
||||
source.runWith(Sink.head(), materializer).toCompletableFuture().get(5, TimeUnit.SECONDS));
|
||||
source.runWith(Sink.head(), system).toCompletableFuture().get(5, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -51,7 +51,7 @@ public class SetupTest extends StreamTest {
|
|||
Pair.create(false, false),
|
||||
Source.empty()
|
||||
.via(flow)
|
||||
.runWith(Sink.head(), materializer)
|
||||
.runWith(Sink.head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(5, TimeUnit.SECONDS));
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ public class SetupTest extends StreamTest {
|
|||
assertEquals(
|
||||
Pair.create(false, false),
|
||||
Source.empty()
|
||||
.runWith(sink, materializer)
|
||||
.runWith(sink, system)
|
||||
.thenCompose(c -> c)
|
||||
.toCompletableFuture()
|
||||
.get(5, TimeUnit.SECONDS));
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ public class SinkTest extends StreamTest {
|
|||
final Sink<Object, Publisher<Object>> pubSink = Sink.asPublisher(AsPublisher.WITH_FANOUT);
|
||||
@SuppressWarnings("unused")
|
||||
final Publisher<Object> publisher =
|
||||
Source.from(new ArrayList<Object>()).runWith(pubSink, materializer);
|
||||
Source.from(new ArrayList<Object>()).runWith(pubSink, system);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustBeAbleToUseFuture() throws Exception {
|
||||
final Sink<Integer, CompletionStage<Integer>> futSink = Sink.head();
|
||||
final List<Integer> list = Collections.singletonList(1);
|
||||
final CompletionStage<Integer> future = Source.from(list).runWith(futSink, materializer);
|
||||
final CompletionStage<Integer> future = Source.from(list).runWith(futSink, system);
|
||||
assert future.toCompletableFuture().get(1, TimeUnit.SECONDS).equals(1);
|
||||
}
|
||||
|
||||
|
|
@ -57,14 +57,14 @@ public class SinkTest extends StreamTest {
|
|||
Sink<Integer, CompletionStage<Integer>> foldSink = Sink.fold(0, (arg1, arg2) -> arg1 + arg2);
|
||||
@SuppressWarnings("unused")
|
||||
CompletionStage<Integer> integerFuture =
|
||||
Source.from(new ArrayList<Integer>()).runWith(foldSink, materializer);
|
||||
Source.from(new ArrayList<Integer>()).runWith(foldSink, system);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustBeAbleToUseActorRefSink() throws Exception {
|
||||
final TestKit probe = new TestKit(system);
|
||||
final Sink<Integer, ?> actorRefSink = Sink.actorRef(probe.getRef(), "done");
|
||||
Source.from(Arrays.asList(1, 2, 3)).runWith(actorRefSink, materializer);
|
||||
Source.from(Arrays.asList(1, 2, 3)).runWith(actorRefSink, system);
|
||||
probe.expectMsgEquals(1);
|
||||
probe.expectMsgEquals(2);
|
||||
probe.expectMsgEquals(3);
|
||||
|
|
@ -76,7 +76,7 @@ public class SinkTest extends StreamTest {
|
|||
final List<Integer> list = Arrays.asList(1, 2, 3);
|
||||
final Sink<Integer, CompletionStage<List<Integer>>> collectorSink =
|
||||
StreamConverters.javaCollector(Collectors::toList);
|
||||
CompletionStage<List<Integer>> result = Source.from(list).runWith(collectorSink, materializer);
|
||||
CompletionStage<List<Integer>> result = Source.from(list).runWith(collectorSink, system);
|
||||
assertEquals(list, result.toCompletableFuture().get(1, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ public class SinkTest extends StreamTest {
|
|||
}
|
||||
});
|
||||
|
||||
Source.from(Arrays.asList(0, 1)).runWith(sink, materializer);
|
||||
Source.from(Arrays.asList(0, 1)).runWith(sink, system);
|
||||
|
||||
probe1.expectMsgEquals(0);
|
||||
probe2.expectMsgEquals(0);
|
||||
|
|
@ -115,7 +115,7 @@ public class SinkTest extends StreamTest {
|
|||
List<Integer> out =
|
||||
Source.range(0, 2)
|
||||
.toMat(Sink.<Integer>seq().contramap(x -> x + 1), Keep.right())
|
||||
.run(materializer)
|
||||
.run(system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -125,13 +125,13 @@ public class SinkTest extends StreamTest {
|
|||
@Test
|
||||
public void mustBeAbleToUsePreMaterialize() throws Exception {
|
||||
Pair<CompletionStage<String>, Sink<String, NotUsed>> pair =
|
||||
Sink.<String>head().preMaterialize(materializer);
|
||||
Sink.<String>head().preMaterialize(system);
|
||||
|
||||
CompletableFuture<String> future = pair.first().toCompletableFuture();
|
||||
assertEquals(false, future.isDone()); // not yet, only once actually source attached
|
||||
|
||||
String element = "element";
|
||||
Source.single(element).runWith(pair.second(), materializer);
|
||||
Source.single(element).runWith(pair.second(), system);
|
||||
|
||||
String got = future.get(3, TimeUnit.SECONDS); // should complete nicely
|
||||
assertEquals(element, got);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class SourceTest extends StreamTest {
|
|||
.mapConcat(elem -> elem)
|
||||
.groupedWithin(100, Duration.ofMillis(50))
|
||||
.mapConcat(elem -> elem)
|
||||
.runFold("", (acc, elem) -> acc + elem, materializer)
|
||||
.runFold("", (acc, elem) -> acc + elem, system)
|
||||
.thenAccept(elem -> probe.getRef().tell(elem, ActorRef.noSender()));
|
||||
|
||||
probe.expectMsgEquals("de");
|
||||
|
|
@ -97,7 +97,7 @@ public class SourceTest extends StreamTest {
|
|||
Source<String, NotUsed> ints = Source.from(input);
|
||||
|
||||
final CompletionStage<Done> completion =
|
||||
ints.runForeach(elem -> probe.getRef().tell(elem, ActorRef.noSender()), materializer);
|
||||
ints.runForeach(elem -> probe.getRef().tell(elem, ActorRef.noSender()), system);
|
||||
|
||||
completion.thenAccept(elem -> probe.getRef().tell(String.valueOf(elem), ActorRef.noSender()));
|
||||
|
||||
|
|
@ -161,8 +161,7 @@ public class SourceTest extends StreamTest {
|
|||
}
|
||||
})
|
||||
.runForeach(
|
||||
(Procedure<Integer>) elem -> probe.getRef().tell(elem, ActorRef.noSender()),
|
||||
materializer);
|
||||
(Procedure<Integer>) elem -> probe.getRef().tell(elem, ActorRef.noSender()), system);
|
||||
|
||||
probe.expectMsgEquals(0);
|
||||
probe.expectMsgEquals(0);
|
||||
|
|
@ -192,7 +191,7 @@ public class SourceTest extends StreamTest {
|
|||
.mergeSubstreams();
|
||||
|
||||
final CompletionStage<List<List<String>>> future =
|
||||
source.grouped(10).runWith(Sink.<List<List<String>>>head(), materializer);
|
||||
source.grouped(10).runWith(Sink.<List<List<String>>>head(), system);
|
||||
final Object[] result = future.toCompletableFuture().get(1, TimeUnit.SECONDS).toArray();
|
||||
Arrays.sort(
|
||||
result,
|
||||
|
|
@ -227,7 +226,7 @@ public class SourceTest extends StreamTest {
|
|||
.concatSubstreams();
|
||||
|
||||
final CompletionStage<List<List<String>>> future =
|
||||
source.grouped(10).runWith(Sink.<List<List<String>>>head(), materializer);
|
||||
source.grouped(10).runWith(Sink.<List<List<String>>>head(), system);
|
||||
final List<List<String>> result = future.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
|
||||
assertEquals(
|
||||
|
|
@ -251,7 +250,7 @@ public class SourceTest extends StreamTest {
|
|||
.concatSubstreams();
|
||||
|
||||
final CompletionStage<List<List<String>>> future =
|
||||
source.grouped(10).runWith(Sink.<List<List<String>>>head(), materializer);
|
||||
source.grouped(10).runWith(Sink.<List<List<String>>>head(), system);
|
||||
final List<List<String>> result = future.toCompletableFuture().get(1, TimeUnit.SECONDS);
|
||||
|
||||
assertEquals(
|
||||
|
|
@ -276,7 +275,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
List<Object> output = probe.receiveN(6);
|
||||
assertEquals(Arrays.asList("A", "B", "C", "D", "E", "F"), output);
|
||||
|
|
@ -298,7 +297,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
List<Object> output = probe.receiveN(6);
|
||||
assertEquals(Arrays.asList("A", "B", "C", "D", "E", "F"), output);
|
||||
|
|
@ -322,7 +321,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
List<Object> output = probe.receiveN(5);
|
||||
assertEquals(Arrays.asList(4, 3, 2, 1, 0), output);
|
||||
|
|
@ -343,7 +342,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(param.get(), ActorRef.noSender());
|
||||
}
|
||||
}),
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgClass(Done.class);
|
||||
}
|
||||
|
|
@ -358,7 +357,7 @@ public class SourceTest extends StreamTest {
|
|||
in -> {
|
||||
throw new RuntimeException("simulated err");
|
||||
})
|
||||
.runWith(Sink.<String>head(), materializer)
|
||||
.runWith(Sink.<String>head(), system)
|
||||
.whenComplete(
|
||||
(s, ex) -> {
|
||||
if (ex == null) {
|
||||
|
|
@ -375,7 +374,7 @@ public class SourceTest extends StreamTest {
|
|||
public void mustBeAbleToUseToFuture() throws Exception {
|
||||
final TestKit probe = new TestKit(system);
|
||||
final Iterable<String> input = Arrays.asList("A", "B", "C");
|
||||
CompletionStage<String> future = Source.from(input).runWith(Sink.<String>head(), materializer);
|
||||
CompletionStage<String> future = Source.from(input).runWith(Sink.<String>head(), system);
|
||||
String result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("A", result);
|
||||
}
|
||||
|
|
@ -383,7 +382,7 @@ public class SourceTest extends StreamTest {
|
|||
@Test
|
||||
public void mustBeAbleToUseSingle() throws Exception {
|
||||
// #source-single
|
||||
CompletionStage<List<String>> future = Source.single("A").runWith(Sink.seq(), materializer);
|
||||
CompletionStage<List<String>> future = Source.single("A").runWith(Sink.seq(), system);
|
||||
CompletableFuture<List<String>> completableFuture = future.toCompletableFuture();
|
||||
completableFuture.thenAccept(result -> System.out.printf("collected elements: %s\n", result));
|
||||
// result list will contain exactly one element "A"
|
||||
|
|
@ -402,13 +401,13 @@ public class SourceTest extends StreamTest {
|
|||
CompletionStage<Pair<List<Integer>, Source<Integer, NotUsed>>> future =
|
||||
Source.from(input)
|
||||
.prefixAndTail(3)
|
||||
.runWith(Sink.<Pair<List<Integer>, Source<Integer, NotUsed>>>head(), materializer);
|
||||
.runWith(Sink.<Pair<List<Integer>, Source<Integer, NotUsed>>>head(), system);
|
||||
Pair<List<Integer>, Source<Integer, NotUsed>> result =
|
||||
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(Arrays.asList(1, 2, 3), result.first());
|
||||
|
||||
CompletionStage<List<Integer>> tailFuture =
|
||||
result.second().limit(4).runWith(Sink.<Integer>seq(), materializer);
|
||||
result.second().limit(4).runWith(Sink.<Integer>seq(), system);
|
||||
List<Integer> tailResult = tailFuture.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(Arrays.asList(4, 5, 6), tailResult);
|
||||
}
|
||||
|
|
@ -428,7 +427,7 @@ public class SourceTest extends StreamTest {
|
|||
.<Integer, NotUsed>flatMapConcat(
|
||||
ConstantFun.<Source<Integer, NotUsed>>javaIdentityFunction())
|
||||
.grouped(6)
|
||||
.runWith(Sink.<List<Integer>>head(), materializer);
|
||||
.runWith(Sink.<List<Integer>>head(), system);
|
||||
|
||||
List<Integer> result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -453,7 +452,7 @@ public class SourceTest extends StreamTest {
|
|||
Source.from(mainInputs)
|
||||
.flatMapMerge(3, ConstantFun.<Source<Integer, NotUsed>>javaIdentityFunction())
|
||||
.grouped(60)
|
||||
.runWith(Sink.<List<Integer>>head(), materializer);
|
||||
.runWith(Sink.<List<Integer>>head(), system);
|
||||
|
||||
List<Integer> result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
final Set<Integer> set = new HashSet<Integer>();
|
||||
|
|
@ -476,7 +475,7 @@ public class SourceTest extends StreamTest {
|
|||
Source.from(input)
|
||||
.buffer(2, OverflowStrategy.backpressure())
|
||||
.grouped(4)
|
||||
.runWith(Sink.<List<String>>head(), materializer);
|
||||
.runWith(Sink.<List<String>>head(), system);
|
||||
|
||||
List<String> result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(input, result);
|
||||
|
|
@ -489,7 +488,7 @@ public class SourceTest extends StreamTest {
|
|||
CompletionStage<String> future =
|
||||
Source.from(input)
|
||||
.conflateWithSeed(s -> s, (aggr, in) -> aggr + in)
|
||||
.runFold("", (aggr, in) -> aggr + in, materializer);
|
||||
.runFold("", (aggr, in) -> aggr + in, system);
|
||||
String result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("ABC", result);
|
||||
|
||||
|
|
@ -498,7 +497,7 @@ public class SourceTest extends StreamTest {
|
|||
CompletionStage<String> future2 =
|
||||
Source.from(input)
|
||||
.conflate((String a, String b) -> a + b)
|
||||
.runFold("", (a, b) -> a + b, materializer);
|
||||
.runFold("", (a, b) -> a + b, system);
|
||||
String result2 = future2.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("ABC", result2);
|
||||
}
|
||||
|
|
@ -510,7 +509,7 @@ public class SourceTest extends StreamTest {
|
|||
CompletionStage<String> future =
|
||||
Source.from(input)
|
||||
.expand(in -> Stream.iterate(in, i -> i).iterator())
|
||||
.runWith(Sink.<String>head(), materializer);
|
||||
.runWith(Sink.<String>head(), system);
|
||||
String result = future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("A", result);
|
||||
}
|
||||
|
|
@ -530,7 +529,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
}))
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
probe.expectNoMessage(Duration.ofMillis(600));
|
||||
probe.expectMsgEquals("tick");
|
||||
probe.expectNoMessage(Duration.ofMillis(200));
|
||||
|
|
@ -552,7 +551,7 @@ public class SourceTest extends StreamTest {
|
|||
final Iterable<String> input = Arrays.asList("a", "b", "c");
|
||||
Source.from(input)
|
||||
.mapAsync(4, elem -> CompletableFuture.completedFuture(elem.toUpperCase()))
|
||||
.runForeach(elem -> probe.getRef().tell(elem, ActorRef.noSender()), materializer);
|
||||
.runForeach(elem -> probe.getRef().tell(elem, ActorRef.noSender()), system);
|
||||
probe.expectMsgEquals("A");
|
||||
probe.expectMsgEquals("B");
|
||||
probe.expectMsgEquals("C");
|
||||
|
|
@ -571,16 +570,16 @@ public class SourceTest extends StreamTest {
|
|||
(elem) -> {
|
||||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
probe.expectMsgAnyClassOf(FlowSpec.Apple.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mustWorkFromFuture() throws Exception {
|
||||
final Iterable<String> input = Arrays.asList("A", "B", "C");
|
||||
CompletionStage<String> future1 = Source.from(input).runWith(Sink.<String>head(), materializer);
|
||||
CompletionStage<String> future1 = Source.from(input).runWith(Sink.<String>head(), system);
|
||||
CompletionStage<String> future2 =
|
||||
Source.fromCompletionStage(future1).runWith(Sink.<String>head(), materializer);
|
||||
Source.fromCompletionStage(future1).runWith(Sink.<String>head(), system);
|
||||
String result = future2.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals("A", result);
|
||||
}
|
||||
|
|
@ -589,7 +588,7 @@ public class SourceTest extends StreamTest {
|
|||
public void mustWorkFromFutureVoid() throws Exception {
|
||||
CompletionStage<Void> future = CompletableFuture.completedFuture(null);
|
||||
CompletionStage<List<Void>> future2 =
|
||||
Source.fromCompletionStage(future).runWith(Sink.seq(), materializer);
|
||||
Source.fromCompletionStage(future).runWith(Sink.seq(), system);
|
||||
List<Void> result = future2.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(0, result.size());
|
||||
}
|
||||
|
|
@ -597,7 +596,7 @@ public class SourceTest extends StreamTest {
|
|||
@Test
|
||||
public void mustWorkFromRange() throws Exception {
|
||||
CompletionStage<List<Integer>> f =
|
||||
Source.range(0, 10).grouped(20).runWith(Sink.<List<Integer>>head(), materializer);
|
||||
Source.range(0, 10).grouped(20).runWith(Sink.<List<Integer>>head(), system);
|
||||
final List<Integer> result = f.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(11, result.size());
|
||||
Integer counter = 0;
|
||||
|
|
@ -607,7 +606,7 @@ public class SourceTest extends StreamTest {
|
|||
@Test
|
||||
public void mustWorkFromRangeWithStep() throws Exception {
|
||||
CompletionStage<List<Integer>> f =
|
||||
Source.range(0, 10, 2).grouped(20).runWith(Sink.<List<Integer>>head(), materializer);
|
||||
Source.range(0, 10, 2).grouped(20).runWith(Sink.<List<Integer>>head(), system);
|
||||
final List<Integer> result = f.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(6, result.size());
|
||||
Integer counter = 0;
|
||||
|
|
@ -620,7 +619,7 @@ public class SourceTest extends StreamTest {
|
|||
@Test
|
||||
public void mustRepeat() throws Exception {
|
||||
final CompletionStage<List<Integer>> f =
|
||||
Source.repeat(42).grouped(10000).runWith(Sink.<List<Integer>>head(), materializer);
|
||||
Source.repeat(42).grouped(10000).runWith(Sink.<List<Integer>>head(), system);
|
||||
final List<Integer> result = f.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
assertEquals(result.size(), 10000);
|
||||
for (Integer i : result) assertEquals(i, (Integer) 42);
|
||||
|
|
@ -629,8 +628,7 @@ public class SourceTest extends StreamTest {
|
|||
@Test
|
||||
public void mustBeAbleToUseQueue() throws Exception {
|
||||
final Pair<SourceQueueWithComplete<String>, CompletionStage<List<String>>> x =
|
||||
Flow.of(String.class)
|
||||
.runWith(Source.queue(2, OverflowStrategy.fail()), Sink.seq(), materializer);
|
||||
Flow.of(String.class).runWith(Source.queue(2, OverflowStrategy.fail()), Sink.seq(), system);
|
||||
final SourceQueueWithComplete<String> source = x.first();
|
||||
final CompletionStage<List<String>> result = x.second();
|
||||
source.offer("hello");
|
||||
|
|
@ -653,7 +651,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
}))
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
ref.tell(1, ActorRef.noSender());
|
||||
probe.expectMsgEquals(1);
|
||||
ref.tell(2, ActorRef.noSender());
|
||||
|
|
@ -677,7 +675,7 @@ public class SourceTest extends StreamTest {
|
|||
};
|
||||
});
|
||||
|
||||
ints.runFold("", (acc, elem) -> acc + elem, materializer)
|
||||
ints.runFold("", (acc, elem) -> acc + elem, system)
|
||||
.thenAccept(elem -> probe.getRef().tell(elem, ActorRef.noSender()));
|
||||
|
||||
probe.expectMsgEquals("2334445555");
|
||||
|
|
@ -691,7 +689,7 @@ public class SourceTest extends StreamTest {
|
|||
|
||||
final CompletionStage<Done> future =
|
||||
source.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgEquals("[");
|
||||
probe.expectMsgEquals("0");
|
||||
|
|
@ -714,8 +712,7 @@ public class SourceTest extends StreamTest {
|
|||
final CompletionStage<Done> future =
|
||||
Source.single(">> ")
|
||||
.concat(source)
|
||||
.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
.runWith(Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgEquals(">> ");
|
||||
probe.expectMsgEquals("0");
|
||||
|
|
@ -742,7 +739,7 @@ public class SourceTest extends StreamTest {
|
|||
|
||||
final CompletionStage<Done> future =
|
||||
source.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgEquals(2);
|
||||
probe.expectMsgEquals(3);
|
||||
|
|
@ -763,7 +760,7 @@ public class SourceTest extends StreamTest {
|
|||
|
||||
final CompletionStage<Done> future =
|
||||
source.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgEquals(0);
|
||||
probe.expectMsgEquals(1);
|
||||
|
|
@ -790,7 +787,7 @@ public class SourceTest extends StreamTest {
|
|||
|
||||
final CompletionStage<Done> future =
|
||||
source.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
final PublisherProbeSubscription<Integer> s = publisherProbe.expectSubscription();
|
||||
s.sendNext(0);
|
||||
probe.expectMsgEquals(0);
|
||||
|
|
@ -815,7 +812,7 @@ public class SourceTest extends StreamTest {
|
|||
|
||||
final CompletionStage<Done> future =
|
||||
source.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgAllOf(0, 1, 2, 3);
|
||||
|
||||
|
|
@ -842,7 +839,7 @@ public class SourceTest extends StreamTest {
|
|||
combined
|
||||
.toMat(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), Keep.left())
|
||||
.run(materializer);
|
||||
.run(system);
|
||||
|
||||
queue.offer(0);
|
||||
queue.offer(1);
|
||||
|
|
@ -866,7 +863,7 @@ public class SourceTest extends StreamTest {
|
|||
|
||||
final CompletionStage<Done> future =
|
||||
source.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgAllOf(Arrays.asList(0, 2), Arrays.asList(1, 3));
|
||||
|
||||
|
|
@ -886,7 +883,7 @@ public class SourceTest extends StreamTest {
|
|||
|
||||
final CompletionStage<Done> future =
|
||||
source.runWith(
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), materializer);
|
||||
Sink.foreach(elem -> probe.getRef().tell(elem, ActorRef.noSender())), system);
|
||||
|
||||
probe.expectMsgAllOf(Boolean.TRUE, Boolean.FALSE);
|
||||
|
||||
|
|
@ -911,7 +908,7 @@ public class SourceTest extends StreamTest {
|
|||
}
|
||||
});
|
||||
Source<Pair<String, Integer>, NotUsed> zippedSrc = src1.zipAll(src2, "MISSING", -1);
|
||||
zippedSrc.runWith(sink, materializer);
|
||||
zippedSrc.runWith(sink, system);
|
||||
|
||||
List<Object> output = probe.receiveN(6);
|
||||
List<Pair<String, Integer>> expected =
|
||||
|
|
@ -928,7 +925,7 @@ public class SourceTest extends StreamTest {
|
|||
@Test
|
||||
public void createEmptySource() throws Exception {
|
||||
List<Integer> actual =
|
||||
Source.empty(Integer.class).runWith(Sink.seq(), materializer).toCompletableFuture().get();
|
||||
Source.empty(Integer.class).runWith(Sink.seq(), system).toCompletableFuture().get();
|
||||
assertThat(actual, is(Collections.emptyList()));
|
||||
}
|
||||
|
||||
|
|
@ -936,7 +933,7 @@ public class SourceTest extends StreamTest {
|
|||
public void cycleSourceMustGenerateSameSequenceInRepeatedFashion() throws Exception {
|
||||
// #cycle
|
||||
final Source<Integer, NotUsed> source = Source.cycle(() -> Arrays.asList(1, 2, 3).iterator());
|
||||
CompletionStage<List<Integer>> result = source.grouped(9).runWith(Sink.head(), materializer);
|
||||
CompletionStage<List<Integer>> result = source.grouped(9).runWith(Sink.head(), system);
|
||||
List<Integer> emittedValues = result.toCompletableFuture().get();
|
||||
assertThat(emittedValues, is(Arrays.asList(1, 2, 3, 1, 2, 3, 1, 2, 3)));
|
||||
// #cycle
|
||||
|
|
@ -949,7 +946,7 @@ public class SourceTest extends StreamTest {
|
|||
// #cycle-error
|
||||
Iterator<Integer> emptyIterator = Collections.<Integer>emptyList().iterator();
|
||||
Source.cycle(() -> emptyIterator)
|
||||
.runWith(Sink.head(), materializer)
|
||||
.runWith(Sink.head(), system)
|
||||
// stream will be terminated with IllegalArgumentException
|
||||
// #cycle-error
|
||||
.toCompletableFuture()
|
||||
|
|
@ -973,7 +970,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgAllOf("A", "B", "C", "D", "E", "F");
|
||||
}
|
||||
|
|
@ -998,7 +995,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgEquals("A-D");
|
||||
probe.expectMsgEquals("B-E");
|
||||
|
|
@ -1019,7 +1016,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgEquals(new Pair<String, String>("A", "D"));
|
||||
probe.expectMsgEquals(new Pair<String, String>("B", "E"));
|
||||
|
|
@ -1040,7 +1037,7 @@ public class SourceTest extends StreamTest {
|
|||
probe.getRef().tell(elem, ActorRef.noSender());
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
probe.expectMsgAllOf("A", "B", "C", "D", "E", "F");
|
||||
}
|
||||
|
|
@ -1051,7 +1048,7 @@ public class SourceTest extends StreamTest {
|
|||
try {
|
||||
Source.maybe()
|
||||
.initialTimeout(Duration.ofSeconds(1))
|
||||
.runWith(Sink.head(), materializer)
|
||||
.runWith(Sink.head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
|
|
@ -1069,7 +1066,7 @@ public class SourceTest extends StreamTest {
|
|||
try {
|
||||
Source.maybe()
|
||||
.completionTimeout(Duration.ofSeconds(1))
|
||||
.runWith(Sink.head(), materializer)
|
||||
.runWith(Sink.head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
|
|
@ -1087,7 +1084,7 @@ public class SourceTest extends StreamTest {
|
|||
try {
|
||||
Source.maybe()
|
||||
.idleTimeout(Duration.ofSeconds(1))
|
||||
.runWith(Sink.head(), materializer)
|
||||
.runWith(Sink.head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
|
|
@ -1105,7 +1102,7 @@ public class SourceTest extends StreamTest {
|
|||
Source.<Integer>maybe()
|
||||
.keepAlive(Duration.ofSeconds(1), () -> 0)
|
||||
.takeWithin(Duration.ofMillis(1500))
|
||||
.runWith(Sink.head(), materializer)
|
||||
.runWith(Sink.head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -1127,7 +1124,7 @@ public class SourceTest extends StreamTest {
|
|||
Source.from(Arrays.asList(0, 1, 2))
|
||||
.throttle(10, Duration.ofSeconds(1), 10, ThrottleMode.shaping())
|
||||
.throttle(10, Duration.ofSeconds(1), 10, ThrottleMode.enforcing())
|
||||
.runWith(Sink.head(), materializer)
|
||||
.runWith(Sink.head(), system)
|
||||
.toCompletableFuture()
|
||||
.get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
@ -1151,7 +1148,7 @@ public class SourceTest extends StreamTest {
|
|||
@Test
|
||||
public void mustBeAbleToUsePreMaterialize() {
|
||||
final Pair<NotUsed, Source<Integer, NotUsed>> p =
|
||||
Source.<Integer>empty().preMaterialize(materializer);
|
||||
Source.<Integer>empty().preMaterialize(system);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class TcpTest extends StreamTest {
|
|||
Sink.foreach(
|
||||
new Procedure<IncomingConnection>() {
|
||||
public void apply(IncomingConnection conn) {
|
||||
conn.handleWith(Flow.of(ByteString.class), materializer);
|
||||
conn.handleWith(Flow.of(ByteString.class), system);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ public class TcpTest extends StreamTest {
|
|||
final Source<IncomingConnection, CompletionStage<ServerBinding>> binding =
|
||||
Tcp.get(system).bind(serverAddress.getHostString(), serverAddress.getPort());
|
||||
|
||||
final CompletionStage<ServerBinding> future = binding.to(echoHandler).run(materializer);
|
||||
final CompletionStage<ServerBinding> future = binding.to(echoHandler).run(system);
|
||||
final ServerBinding b = future.toCompletableFuture().get(5, TimeUnit.SECONDS);
|
||||
assertEquals(b.localAddress().getPort(), serverAddress.getPort());
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ public class TcpTest extends StreamTest {
|
|||
return acc.concat(elem);
|
||||
}
|
||||
},
|
||||
materializer);
|
||||
system);
|
||||
|
||||
final byte[] result = resultFuture.toCompletableFuture().get(5, TimeUnit.SECONDS).toArray();
|
||||
for (int i = 0; i < testInput.size(); i++) {
|
||||
|
|
@ -109,7 +109,7 @@ public class TcpTest extends StreamTest {
|
|||
final Source<IncomingConnection, CompletionStage<ServerBinding>> binding =
|
||||
Tcp.get(system).bind(serverAddress.getHostString(), serverAddress.getPort());
|
||||
|
||||
final CompletionStage<ServerBinding> future = binding.to(echoHandler).run(materializer);
|
||||
final CompletionStage<ServerBinding> future = binding.to(echoHandler).run(system);
|
||||
final ServerBinding b = future.toCompletableFuture().get(5, TimeUnit.SECONDS);
|
||||
assertEquals(b.localAddress().getPort(), serverAddress.getPort());
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ public class TcpTest extends StreamTest {
|
|||
try {
|
||||
binding
|
||||
.to(echoHandler)
|
||||
.run(materializer)
|
||||
.run(system)
|
||||
.toCompletableFuture()
|
||||
.get(5, TimeUnit.SECONDS);
|
||||
assertTrue("Expected BindFailedException, but nothing was reported", false);
|
||||
|
|
@ -152,7 +152,7 @@ public class TcpTest extends StreamTest {
|
|||
.outgoingConnection(serverAddress.getHostString(), serverAddress.getPort()),
|
||||
Keep.right())
|
||||
.to(Sink.<ByteString>ignore())
|
||||
.run(materializer)
|
||||
.run(system)
|
||||
.toCompletableFuture()
|
||||
.get(5, TimeUnit.SECONDS);
|
||||
assertTrue("Expected StreamTcpException, but nothing was reported", false);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue