use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeDoOnEventTest method onSubscribeCrash.
@Test
public void onSubscribeCrash() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final Disposable bs = Disposable.empty();
new Maybe<Integer>() {
@Override
protected void subscribeActual(MaybeObserver<? super Integer> observer) {
observer.onSubscribe(bs);
observer.onError(new TestException("Second"));
observer.onComplete();
observer.onSuccess(1);
}
}.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable d) throws Exception {
throw new TestException("First");
}
}).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(bs.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeCreateTest method tryOnError.
@Test
public void tryOnError() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final Boolean[] response = { null };
Maybe.create(new MaybeOnSubscribe<Object>() {
@Override
public void subscribe(MaybeEmitter<Object> e) throws Exception {
e.onSuccess(1);
response[0] = e.tryOnError(new TestException());
}
}).test().assertResult(1);
assertFalse(response[0]);
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeCreateTest method onErrorThrows2.
@Test
public void onErrorThrows2() {
Maybe.create(new MaybeOnSubscribe<Object>() {
@Override
public void subscribe(MaybeEmitter<Object> e) throws Exception {
try {
e.onError(new IOException());
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) {
throw new TestException();
}
@Override
public void onComplete() {
}
});
}
use of io.reactivex.rxjava3.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 = Disposable.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.rxjava3.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();
}
});
}
Aggregations