use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableElementAtTest method badSourceObservable.
@Test
public void badSourceObservable() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposables.empty());
observer.onNext(1);
observer.onNext(2);
observer.onError(new TestException());
observer.onComplete();
}
}.elementAt(0).toFlowable().test().assertResult(1);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableFilterTest method sourceIgnoresCancelConditional.
@Test
public void sourceIgnoresCancelConditional() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.fromPublisher(new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
ConditionalSubscriber<? super Integer> cs = (ConditionalSubscriber<? super Integer>) s;
cs.onSubscribe(new BooleanSubscription());
cs.tryOnNext(1);
cs.tryOnNext(2);
cs.onError(new IOException());
cs.onComplete();
}
}).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
return true;
}
}).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableFilterTest method sourceIgnoresCancel.
@Test
public void sourceIgnoresCancel() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.fromPublisher(new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
s.onNext(1);
s.onNext(2);
s.onError(new IOException());
s.onComplete();
}
}).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableMapTest method mapFilterMapperCrashFused.
@Test
public void mapFilterMapperCrashFused() {
TestSubscriber<Integer> ts = SubscriberFusion.newTest(QueueSubscription.ANY);
Flowable.range(1, 2).hide().map(new Function<Integer, Integer>() {
@Override
public Integer apply(Integer v) throws Exception {
throw new TestException();
}
}).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
return true;
}
}).subscribe(ts);
ts.assertOf(SubscriberFusion.<Integer>assertFuseable()).assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueSubscription.NONE)).assertFailure(TestException.class);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableMapTest method sourceIgnoresCancel.
@Test
public void sourceIgnoresCancel() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable.fromPublisher(new Publisher<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
s.onNext(1);
s.onNext(2);
s.onError(new IOException());
s.onComplete();
}
}).map(new Function<Integer, Object>() {
@Override
public Object apply(Integer v) throws Exception {
throw new TestException();
}
}).test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
} finally {
RxJavaPlugins.reset();
}
}
Aggregations