use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableReplayTest method disposeNoNeedForResetTimeAndSIzeBound.
@Test
public void disposeNoNeedForResetTimeAndSIzeBound() {
PublishProcessor<Integer> pp = PublishProcessor.create();
ConnectableFlowable<Integer> cf = pp.replay(10, 10, TimeUnit.MINUTES);
TestSubscriber<Integer> ts = cf.test();
Disposable d = cf.connect();
pp.onNext(1);
d.dispose();
ts = cf.test();
ts.assertEmpty();
cf.connect();
ts.assertEmpty();
pp.onNext(2);
ts.assertValuesOnly(2);
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableReplayTest method disposeNoNeedForResetSizeBound.
@Test
public void disposeNoNeedForResetSizeBound() {
PublishProcessor<Integer> pp = PublishProcessor.create();
ConnectableFlowable<Integer> cf = pp.replay(10);
TestSubscriber<Integer> ts = cf.test();
Disposable d = cf.connect();
pp.onNext(1);
d.dispose();
ts = cf.test();
ts.assertEmpty();
cf.connect();
ts.assertEmpty();
pp.onNext(2);
ts.assertValuesOnly(2);
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableThrottleLatestTest method missingBackpressureExceptionLatestComplete.
@Test
public void missingBackpressureExceptionLatestComplete() throws Throwable {
TestScheduler sch = new TestScheduler();
Action onCancel = mock(Action.class);
PublishProcessor<Integer> pp = PublishProcessor.create();
TestSubscriber<Integer> ts = pp.doOnCancel(onCancel).throttleLatest(1, TimeUnit.SECONDS, sch, true).test(1);
pp.onNext(1);
pp.onNext(2);
ts.assertValuesOnly(1);
pp.onComplete();
ts.assertFailure(MissingBackpressureException.class, 1);
verify(onCancel, never()).run();
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableThrottleLatestTest method reentrantComplete.
@Test
public void reentrantComplete() {
TestScheduler sch = new TestScheduler();
final PublishProcessor<Integer> pp = PublishProcessor.create();
TestSubscriber<Integer> ts = new TestSubscriber<Integer>() {
@Override
public void onNext(Integer t) {
super.onNext(t);
if (t == 1) {
pp.onNext(2);
}
if (t == 2) {
pp.onComplete();
}
}
};
pp.throttleLatest(1, TimeUnit.SECONDS, sch).subscribe(ts);
pp.onNext(1);
sch.advanceTimeBy(1, TimeUnit.SECONDS);
ts.assertResult(1, 2);
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableTakeTimedTest method takeTimed.
@Test
public void takeTimed() {
TestScheduler scheduler = new TestScheduler();
PublishProcessor<Integer> source = PublishProcessor.create();
Flowable<Integer> result = source.take(1, TimeUnit.SECONDS, scheduler);
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
result.subscribe(subscriber);
source.onNext(1);
source.onNext(2);
source.onNext(3);
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
source.onNext(4);
InOrder inOrder = inOrder(subscriber);
inOrder.verify(subscriber).onNext(1);
inOrder.verify(subscriber).onNext(2);
inOrder.verify(subscriber).onNext(3);
inOrder.verify(subscriber).onComplete();
inOrder.verifyNoMoreInteractions();
verify(subscriber, never()).onNext(4);
verify(subscriber, never()).onError(any(Throwable.class));
}
Aggregations