use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeCacheTest method onlineError.
@Test
public void onlineError() {
PublishProcessor<Integer> pp = PublishProcessor.create();
Maybe<Integer> source = pp.singleElement().cache();
assertFalse(pp.hasSubscribers());
assertNotNull(((MaybeCache<Integer>) source).source.get());
TestObserver<Integer> ts = source.test();
assertNull(((MaybeCache<Integer>) source).source.get());
assertTrue(pp.hasSubscribers());
source.test(true).assertEmpty();
ts.assertEmpty();
pp.onError(new TestException());
ts.assertFailure(TestException.class);
source.test().assertFailure(TestException.class);
source.test(true).assertEmpty();
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeCreateTest method onSuccessThrows.
@Test
public void onSuccessThrows() {
Maybe.create(new MaybeOnSubscribe<Object>() {
@Override
public void subscribe(MaybeEmitter<Object> e) throws Exception {
Disposable d = Disposables.empty();
e.setDisposable(d);
try {
e.onSuccess(1);
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
assertTrue(d.isDisposed());
assertTrue(e.isDisposed());
}
}).subscribe(new MaybeObserver<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSuccess(Object value) {
throw new TestException();
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeCreateTest method onCompleteThrows2.
@Test
public void onCompleteThrows2() {
Maybe.create(new MaybeOnSubscribe<Object>() {
@Override
public void subscribe(MaybeEmitter<Object> e) throws Exception {
try {
e.onComplete();
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
assertTrue(e.isDisposed());
}
}).subscribe(new MaybeObserver<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSuccess(Object value) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
throw new TestException();
}
});
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeDelaySubscriptionTest method withPublisherCallAfterTerminalEvent.
@Test
public void withPublisherCallAfterTerminalEvent() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Flowable<Integer> f = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> observer) {
observer.onSubscribe(new BooleanSubscription());
observer.onNext(1);
observer.onError(new TestException());
observer.onComplete();
observer.onNext(2);
}
};
Maybe.just(1).delaySubscription(f).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 MaybeDoAfterSuccessTest method consumerThrows.
@Test
public void consumerThrows() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Maybe.just(1).doAfterSuccess(new Consumer<Integer>() {
@Override
public void accept(Integer e) throws Exception {
throw new TestException();
}
}).test().assertResult(1);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
Aggregations