use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableSubscriberTest method onNextCrashes.
@Test
public void onNextCrashes() {
final TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
ts.onSubscribe(new BooleanSubscription());
ForEachWhileSubscriber<Integer> s = new ForEachWhileSubscriber<Integer>(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable e) throws Exception {
ts.onError(e);
}
}, new Action() {
@Override
public void run() throws Exception {
ts.onComplete();
}
});
BooleanSubscription b = new BooleanSubscription();
s.onSubscribe(b);
s.onNext(1);
assertTrue(b.isCancelled());
ts.assertFailure(TestException.class);
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableSubscriberTest method onCompleteThrows.
@Test
public void onCompleteThrows() {
ForEachWhileSubscriber<Integer> s = new ForEachWhileSubscriber<Integer>(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
return true;
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable e) throws Exception {
}
}, new Action() {
@Override
public void run() throws Exception {
throw new TestException("Inner");
}
});
List<Throwable> list = TestHelper.trackPluginErrors();
try {
s.onSubscribe(new BooleanSubscription());
s.onComplete();
TestHelper.assertUndeliverable(list, 0, TestException.class, "Inner");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableSubscriberTest method onErrorThrows.
@Test
public void onErrorThrows() {
ForEachWhileSubscriber<Integer> s = new ForEachWhileSubscriber<Integer>(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
return true;
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable e) throws Exception {
throw new TestException("Inner");
}
}, new Action() {
@Override
public void run() throws Exception {
}
});
List<Throwable> list = TestHelper.trackPluginErrors();
try {
s.onSubscribe(new BooleanSubscription());
s.onError(new TestException("Outer"));
TestHelper.assertError(list, 0, CompositeException.class);
List<Throwable> cel = TestHelper.compositeList(list.get(0));
TestHelper.assertError(cel, 0, TestException.class, "Outer");
TestHelper.assertError(cel, 1, TestException.class, "Inner");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FutureObserverTest method onCompleteCancelRace.
@Test
public void onCompleteCancelRace() {
for (int i = 0; i < 500; i++) {
final FutureSubscriber<Integer> fo = new FutureSubscriber<Integer>();
if (i % 3 == 0) {
fo.onSubscribe(new BooleanSubscription());
}
if (i % 2 == 0) {
fo.onNext(1);
}
Runnable r1 = new Runnable() {
@Override
public void run() {
fo.cancel(false);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
fo.onComplete();
}
};
TestHelper.race(r1, r2, Schedulers.single());
}
}
use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class FlowableSubscriberTest method suppressAfterCompleteEvents.
@Test
public void suppressAfterCompleteEvents() {
final TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
ts.onSubscribe(new BooleanSubscription());
ForEachWhileSubscriber<Integer> s = new ForEachWhileSubscriber<Integer>(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
ts.onNext(v);
return true;
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable e) throws Exception {
ts.onError(e);
}
}, new Action() {
@Override
public void run() throws Exception {
ts.onComplete();
}
});
s.onComplete();
s.onNext(1);
s.onError(new TestException());
s.onComplete();
ts.assertResult();
}
Aggregations