@Override public void subscribe(CoreSubscriber<? super Throwable> actual) { completionSignal.subscribe(actual); } }
@Override public void subscribe(CoreSubscriber<? super Long> actual) { completionSignal.subscribe(actual); }
@Test(expected = NullPointerException.class) public void subscribeNull() { DirectProcessor.create().subscribe((Subscriber<Object>)null); }
@Test public void terminatedWithError() { AssertSubscriber<Integer> ts = AssertSubscriber.create(); DirectProcessor<Integer> tp = DirectProcessor.create(); tp.onError(new RuntimeException("forced failure")); tp.subscribe(ts); Assert.assertFalse("Subscribers present?", tp.hasDownstreams()); Assert.assertFalse("Completed?", tp.hasCompleted()); Assert.assertNotNull("No error?", tp.getError()); Assert.assertTrue("No error?", tp.hasError()); Throwable e = tp.getError(); Assert.assertTrue("Wrong exception? " + e, RuntimeException.class.isInstance(e)); Assert.assertEquals("forced failure", e.getMessage()); ts.assertNoValues() .assertNotComplete() .assertError(RuntimeException.class) .assertErrorMessage("forced failure"); }
@Test public void subscriberAlreadyCancelled() { AssertSubscriber<Integer> ts = AssertSubscriber.create(); ts.cancel(); DirectProcessor<Integer> tp = DirectProcessor.create(); tp.subscribe(ts); Assert.assertFalse("Subscribers present?", tp.hasDownstreams()); tp.onNext(1); ts.assertNoValues() .assertNotComplete() .assertNoError(); }
@Test public void terminatedNormally() { AssertSubscriber<Integer> ts = AssertSubscriber.create(); DirectProcessor<Integer> tp = DirectProcessor.create(); tp.onComplete(); tp.subscribe(ts); Assert.assertFalse("Subscribers present?", tp.hasDownstreams()); Assert.assertTrue("Not completed?", tp.hasCompleted()); Assert.assertNull("Has error?", tp.getError()); Assert.assertFalse("Has error?", tp.hasError()); ts.assertNoValues() .assertComplete() .assertNoError(); }
@Test public void subscriberCancels() { AssertSubscriber<Integer> ts = AssertSubscriber.create(); DirectProcessor<Integer> tp = DirectProcessor.create(); tp.subscribe(ts); Assert.assertTrue("No Subscribers present?", tp.hasDownstreams()); tp.onNext(1); ts.assertValues(1) .assertNoError() .assertNotComplete(); ts.cancel(); Assert.assertFalse("Subscribers present?", tp.hasDownstreams()); tp.onNext(2); ts.assertValues(1) .assertNotComplete() .assertNoError(); }
@Override public void subscribe(CoreSubscriber<? super Throwable> actual) { completionSignal.subscribe(actual); } }
@Override public void subscribe(CoreSubscriber<? super Long> actual) { completionSignal.subscribe(actual); }
@Override public NettyContext onClose(final Runnable onClose) { onInactive.subscribe(null, e -> onClose.run(), onClose); return this; }
protected ChannelOperations(Channel channel, BiFunction<? super INBOUND, ? super OUTBOUND, ? extends Publisher<Void>> handler, ContextHandler<?> context, DirectProcessor<Void> processor) { this.handler = Objects.requireNonNull(handler, "handler"); this.channel = Objects.requireNonNull(channel, "channel"); this.context = Objects.requireNonNull(context, "context"); this.inbound = new FluxReceive(this); this.onInactive = processor; Subscription[] _s = new Subscription[1]; Mono.fromDirect(context.onCloseOrRelease(channel)) .doOnSubscribe(s -> _s[0] = s) .subscribe(onInactive); if(_s[0] != null) { //remove closeFuture listener ref by onCloseOrRelease // subscription when onInactive is called for any reason from // onHandlerTerminate onInactive.subscribe(null, null, _s[0]::cancel); } }
.subscribe(null, acof, acof);