public void GroupBy_must_abort_onError_from_upstream_when_substreams_are_running() { this.AssertAllStagesStopped(() => { var publisherProbe = TestPublisher.CreateManualProbe <int>(this); var publisher = Source.FromPublisher(publisherProbe) .GroupBy(2, x => x % 2) .Lift(x => x % 2) .RunWith(Sink.AsPublisher <Tuple <int, Source <int, NotUsed> > >(false), Materializer); var subscriber = TestSubscriber.CreateManualProbe <Tuple <int, Source <int, NotUsed> > >(this); publisher.Subscribe(subscriber); var upstreamSubscription = publisherProbe.ExpectSubscription(); var downstreamSubscription = subscriber.ExpectSubscription(); downstreamSubscription.Request(100); upstreamSubscription.SendNext(1); var substream = subscriber.ExpectNext().Item2; var substreamPuppet = new StreamPuppet(substream.RunWith(Sink.AsPublisher <int>(false), Materializer), this); substreamPuppet.Request(1); substreamPuppet.ExpectNext(1); var ex = new TestException("test"); upstreamSubscription.SendError(ex); substreamPuppet.ExpectError(ex); subscriber.ExpectError().Should().Be(ex); }, Materializer); }
public void GroupBy_must_fail_when_exceeding_maxSubstreams() { this.AssertAllStagesStopped(() => { var f = Flow.Create <int>().GroupBy(1, x => x % 2).PrefixAndTail(0).MergeSubstreams(); var t = ((Flow <int, Tuple <IImmutableList <int>, Source <int, NotUsed> >, NotUsed>)f) .RunWith(TestSource.SourceProbe <int>(this), TestSink.SinkProbe <Tuple <IImmutableList <int>, Source <int, NotUsed> > >(this), Materializer); var up = t.Item1; var down = t.Item2; down.Request(2); up.SendNext(1); var first = down.ExpectNext(); var s1 = new StreamPuppet(first.Item2.RunWith(Sink.AsPublisher <int>(false), Materializer), this); s1.Request(1); s1.ExpectNext(1); up.SendNext(2); var ex = down.ExpectError(); ex.Message.Should().Contain("too many substreams"); s1.ExpectError(ex); }, Materializer); }
public void SplitWhen_must_fail_stream_when_SplitWhen_function_throws() { this.AssertAllStagesStopped(() => { var publisherProbe = this.CreateManualPublisherProbe <int>(); var ex = new TestException("test"); var publisher = Source.FromPublisher(publisherProbe).SplitWhen(i => { if (i == 3) { throw ex; } return(i % 3 == 0); }).Lift().RunWith(Sink.AsPublisher <Source <int, NotUsed> >(false), Materializer); var subscriber = this.CreateManualSubscriberProbe <Source <int, NotUsed> >(); publisher.Subscribe(subscriber); var upstreamSubscription = publisherProbe.ExpectSubscription(); var downstreamSubscription = subscriber.ExpectSubscription(); downstreamSubscription.Request(100); upstreamSubscription.SendNext(1); var substream = subscriber.ExpectNext(); var substreamPuppet = new StreamPuppet(substream.RunWith(Sink.AsPublisher <int>(false), Materializer), this); substreamPuppet.Request(10); substreamPuppet.ExpectNext(1); upstreamSubscription.SendNext(2); substreamPuppet.ExpectNext(2); upstreamSubscription.SendNext(3); subscriber.ExpectError().Should().Be(ex); substreamPuppet.ExpectError(ex); upstreamSubscription.ExpectCancellation(); }, Materializer); }
public void SplitAfter_must_fail_stream_when_SplitAfter_function_throws() { this.AssertAllStagesStopped(() => { var publisherProbe = TestPublisher.CreateManualProbe<int>(this); var ex = new TestException("test"); var publisher = Source.FromPublisher(publisherProbe).SplitAfter(i => { if (i == 3) throw ex; return i%3 == 0; }).Lift().RunWith(Sink.AsPublisher<Source<int, NotUsed>>(false), Materializer); var subscriber = TestSubscriber.CreateManualProbe<Source<int, NotUsed>>(this); publisher.Subscribe(subscriber); var upstreamSubscription = publisherProbe.ExpectSubscription(); var downstreamSubscription = subscriber.ExpectSubscription(); downstreamSubscription.Request(100); upstreamSubscription.SendNext(1); var substream = subscriber.ExpectNext(); var substreamPuppet = new StreamPuppet(substream.RunWith(Sink.AsPublisher<int>(false), Materializer), this); substreamPuppet.Request(10); substreamPuppet.ExpectNext(1); upstreamSubscription.SendNext(2); substreamPuppet.ExpectNext(2); upstreamSubscription.SendNext(3); subscriber.ExpectError().Should().Be(ex); substreamPuppet.ExpectError(ex); upstreamSubscription.ExpectCancellation(); }, Materializer); }
public void GroupBy_must_fail_when_exceeding_maxSubstreams() { this.AssertAllStagesStopped(() => { var f = Flow.Create<int>().GroupBy(1, x => x%2).PrefixAndTail(0).MergeSubstreams(); var t = ((Flow<int, Tuple<IImmutableList<int>, Source<int, NotUsed>>, NotUsed>) f) .RunWith(this.SourceProbe<int>(), this.SinkProbe<Tuple<IImmutableList<int>, Source<int, NotUsed>>>(), Materializer); var up = t.Item1; var down = t.Item2; down.Request(2); up.SendNext(1); var first = down.ExpectNext(); var s1 = new StreamPuppet(first.Item2.RunWith(Sink.AsPublisher<int>(false), Materializer), this); s1.Request(1); s1.ExpectNext(1); up.SendNext(2); var ex = down.ExpectError(); ex.Message.Should().Contain("too many substreams"); s1.ExpectError(ex); }, Materializer); }
public void GroupBy_must_fail_stream_when_GroupBy_function_throws() { this.AssertAllStagesStopped(() => { var publisherProbe = this.CreateManualPublisherProbe<int>(); var ex = new TestException("test"); var publisher = Source.FromPublisher(publisherProbe).GroupBy(2, i => { if (i == 2) throw ex; return i%2; }) .Lift(x => x%2) .RunWith(Sink.AsPublisher<Tuple<int, Source<int, NotUsed>>>(false), Materializer); var subscriber = this.CreateManualSubscriberProbe<Tuple<int, Source<int, NotUsed>>>(); publisher.Subscribe(subscriber); var upstreamSubscription = publisherProbe.ExpectSubscription(); var downstreamSubscription = subscriber.ExpectSubscription(); downstreamSubscription.Request(100); upstreamSubscription.SendNext(1); var substream = subscriber.ExpectNext().Item2; var substreamPuppet = new StreamPuppet(substream.RunWith(Sink.AsPublisher<int>(false), Materializer), this); substreamPuppet.Request(1); substreamPuppet.ExpectNext(1); upstreamSubscription.SendNext(2); subscriber.ExpectError().Should().Be(ex); substreamPuppet.ExpectError(ex); upstreamSubscription.ExpectCancellation(); }, Materializer); }
public void GroupBy_must_abort_onError_from_upstream_when_substreams_are_running() { this.AssertAllStagesStopped(() => { var publisherProbe = this.CreateManualPublisherProbe<int>(); var publisher = Source.FromPublisher(publisherProbe) .GroupBy(2, x => x % 2) .Lift(x => x % 2) .RunWith(Sink.AsPublisher<Tuple<int, Source<int, NotUsed>>>(false), Materializer); var subscriber = this.CreateManualSubscriberProbe<Tuple<int, Source<int, NotUsed>>>(); publisher.Subscribe(subscriber); var upstreamSubscription = publisherProbe.ExpectSubscription(); var downstreamSubscription = subscriber.ExpectSubscription(); downstreamSubscription.Request(100); upstreamSubscription.SendNext(1); var substream = subscriber.ExpectNext().Item2; var substreamPuppet = new StreamPuppet(substream.RunWith(Sink.AsPublisher<int>(false), Materializer), this); substreamPuppet.Request(1); substreamPuppet.ExpectNext(1); var ex = new TestException("test"); upstreamSubscription.SendError(ex); substreamPuppet.ExpectError(ex); subscriber.ExpectError().Should().Be(ex); }, Materializer); }