use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableRetryWithPredicateTest method retryOnSpecificExceptionAndNotOther.
@Test
public void retryOnSpecificExceptionAndNotOther() {
final IOException ioe = new IOException();
final TestException te = new TestException();
Flowable<Integer> source = Flowable.unsafeCreate(new Publisher<Integer>() {
int count;
@Override
public void subscribe(Subscriber<? super Integer> t1) {
t1.onSubscribe(new BooleanSubscription());
count++;
t1.onNext(0);
t1.onNext(1);
if (count == 1) {
t1.onError(ioe);
return;
}
t1.onNext(2);
t1.onNext(3);
t1.onError(te);
}
});
Subscriber<Integer> subscriber = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(subscriber);
source.retry(retryOnTestException).subscribe(subscriber);
inOrder.verify(subscriber).onNext(0);
inOrder.verify(subscriber).onNext(1);
inOrder.verify(subscriber).onNext(0);
inOrder.verify(subscriber).onNext(1);
inOrder.verify(subscriber).onNext(2);
inOrder.verify(subscriber).onNext(3);
inOrder.verify(subscriber).onError(te);
verify(subscriber, never()).onError(ioe);
verify(subscriber, never()).onComplete();
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableSequenceEqualTest method doubleErrorFlowable.
@Test
public void doubleErrorFlowable() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.sequenceEqual(Flowable.never(), new Flowable<Object>() {
@Override
protected void subscribeActual(Subscriber<? super Object> s) {
s.onSubscribe(new BooleanSubscription());
s.onError(new TestException("First"));
s.onError(new TestException("Second"));
}
}, 8).toFlowable().to(TestHelper.<Boolean>testConsumer()).assertFailureAndMessage(TestException.class, "First");
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription 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.internal.subscriptions.BooleanSubscription 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();
}
}
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableTimeoutWithSelectorTest method badSourceTimeout.
@Test
public void badSourceTimeout() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
subscriber.onNext(1);
subscriber.onNext(2);
subscriber.onError(new TestException("First"));
subscriber.onNext(3);
subscriber.onComplete();
subscriber.onError(new TestException("Second"));
}
}.timeout(Functions.justFunction(Flowable.never()), Flowable.<Integer>never()).take(1).test().assertResult(1);
TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
TestHelper.assertUndeliverable(errors, 1, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
Aggregations