use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableTakeUntilTest method untilPublisherOtherError.
@Test
public void untilPublisherOtherError() {
PublishProcessor<Integer> main = PublishProcessor.create();
PublishProcessor<Integer> other = PublishProcessor.create();
TestSubscriber<Integer> ts = main.takeUntil(other).test();
assertTrue("Main no subscribers?", main.hasSubscribers());
assertTrue("Other no subscribers?", other.hasSubscribers());
other.onError(new TestException());
assertFalse("Main has subscribers?", main.hasSubscribers());
assertFalse("Other has subscribers?", other.hasSubscribers());
ts.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableTimeoutWithSelectorTest method lateOnTimeoutError.
@Test
public void lateOnTimeoutError() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp = PublishProcessor.create();
final Subscriber<?>[] sub = { null, null };
final Flowable<Integer> pp2 = new Flowable<Integer>() {
int count;
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
sub[count++] = s;
}
};
TestSubscriber<Integer> ts = pp.timeout(Functions.justFunction(pp2)).test();
pp.onNext(0);
Runnable r1 = new Runnable() {
@Override
public void run() {
pp.onNext(1);
}
};
final Throwable ex = new TestException();
Runnable r2 = new Runnable() {
@Override
public void run() {
sub[0].onError(ex);
}
};
TestHelper.race(r1, r2);
ts.assertValueAt(0, 0);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableRetryWithPredicateTest method unsubscribeFromRetry.
@Test
public void unsubscribeFromRetry() {
PublishProcessor<Integer> processor = PublishProcessor.create();
final AtomicInteger count = new AtomicInteger(0);
Disposable sub = processor.retry(retryTwice).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 FlowableTimeoutWithSelectorTest method lateOnTimeoutFallbackRace.
@Test
public void lateOnTimeoutFallbackRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp = PublishProcessor.create();
final Subscriber<?>[] sub = { null, null };
final Flowable<Integer> pp2 = new Flowable<Integer>() {
int count;
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
assertFalse(((Disposable) s).isDisposed());
s.onSubscribe(new BooleanSubscription());
sub[count++] = s;
}
};
TestSubscriber<Integer> ts = pp.timeout(Functions.justFunction(pp2), Flowable.<Integer>never()).test();
pp.onNext(0);
Runnable r1 = new Runnable() {
@Override
public void run() {
pp.onNext(1);
}
};
final Throwable ex = new TestException();
Runnable r2 = new Runnable() {
@Override
public void run() {
sub[0].onError(ex);
}
};
TestHelper.race(r1, r2);
ts.assertValueAt(0, 0);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.processors.PublishProcessor in project RxJava by ReactiveX.
the class FlowableTimeoutWithSelectorTest method onCompleteOnTimeoutRaceFallback.
@Test
public void onCompleteOnTimeoutRaceFallback() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp = PublishProcessor.create();
final Subscriber<?>[] sub = { null, null };
final Flowable<Integer> pp2 = new Flowable<Integer>() {
int count;
@Override
protected void subscribeActual(Subscriber<? super Integer> s) {
assertFalse(((Disposable) s).isDisposed());
s.onSubscribe(new BooleanSubscription());
sub[count++] = s;
}
};
TestSubscriber<Integer> ts = pp.timeout(Functions.justFunction(pp2), Flowable.<Integer>never()).test();
pp.onNext(0);
Runnable r1 = new Runnable() {
@Override
public void run() {
pp.onComplete();
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
sub[0].onComplete();
}
};
TestHelper.race(r1, r2);
ts.assertValueAt(0, 0);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
Aggregations