use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableReplayEagerTruncateTest method disposeNoNeedForResetTimeAndSIzeBound.
@Test
public void disposeNoNeedForResetTimeAndSIzeBound() {
PublishProcessor<Integer> pp = PublishProcessor.create();
ConnectableFlowable<Integer> cf = pp.replay(10, 10, TimeUnit.MINUTES, Schedulers.single(), true);
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 FlowableReplayEagerTruncateTest method disposeNoNeedForResetTimeBound.
@Test
public void disposeNoNeedForResetTimeBound() {
PublishProcessor<Integer> pp = PublishProcessor.create();
ConnectableFlowable<Integer> cf = pp.replay(10, TimeUnit.MINUTES, Schedulers.single(), true);
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 FlowableRetryTest method unsubscribeFromRetry.
@Test
public void unsubscribeFromRetry() {
PublishProcessor<Integer> processor = PublishProcessor.create();
final AtomicInteger count = new AtomicInteger(0);
Disposable sub = processor.retry().subscribe(new Consumer<Integer>() {
@Override
public void accept(Integer n) {
count.incrementAndGet();
}
});
processor.onNext(1);
sub.dispose();
processor.onNext(2);
assertEquals(1, count.get());
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowablePublishFunctionTest method oneStartOnly.
@Test
public void oneStartOnly() {
final AtomicInteger startCount = new AtomicInteger();
TestSubscriber<Integer> ts = new TestSubscriber<Integer>() {
@Override
public void onStart() {
startCount.incrementAndGet();
}
};
PublishProcessor<Integer> pp = PublishProcessor.create();
pp.publish(f -> f.take(1)).subscribe(ts);
Assert.assertEquals(1, startCount.get());
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableOnBackpressureReduceWithTest method exceptionFromSupplier.
@Test
public void exceptionFromSupplier() {
PublishProcessor<Integer> source = PublishProcessor.create();
TestSubscriberEx<List<Integer>> ts = new TestSubscriberEx<>(0L);
source.onBackpressureReduce(() -> {
throw new TestException("Test exception");
}, createTestReducer()).subscribe(ts);
source.onNext(1);
source.onNext(2);
TestHelper.assertError(ts.errors(), 0, TestException.class, "Test exception");
}
Aggregations