Search in sources :

Example 1 with DisposableObserver

use of io.reactivex.rxjava3.observers.DisposableObserver in project RxJava by ReactiveX.

the class ObservableDelayTest method onErrorFinal.

@Test
public void onErrorFinal() {
    TestScheduler scheduler = new TestScheduler();
    Observable.error(new TestException()).delay(1, TimeUnit.MILLISECONDS, scheduler).subscribe(new DisposableObserver<Object>() {

        @Override
        public void onNext(Object value) {
        }

        @Override
        public void onError(Throwable e) {
            throw new TestException();
        }

        @Override
        public void onComplete() {
        }
    });
    try {
        scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
        fail("Should have thrown");
    } catch (TestException ex) {
    // expected
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException)

Example 2 with DisposableObserver

use of io.reactivex.rxjava3.observers.DisposableObserver in project RxJava by ReactiveX.

the class ObservableDelayTest method onCompleteFinal.

@Test
public void onCompleteFinal() {
    TestScheduler scheduler = new TestScheduler();
    Observable.empty().delay(1, TimeUnit.MILLISECONDS, scheduler).subscribe(new DisposableObserver<Object>() {

        @Override
        public void onNext(Object value) {
        }

        @Override
        public void onError(Throwable e) {
        }

        @Override
        public void onComplete() {
            throw new TestException();
        }
    });
    try {
        scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
        fail("Should have thrown");
    } catch (TestException ex) {
    // expected
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)2