Search in sources :

Example 16 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class FutureSubscriberTest method onCompleteOnError.

@Test
@SuppressUndeliverable
public void onCompleteOnError() throws Exception {
    fs.onComplete();
    fs.onError(new TestException("One"));
    try {
        assertNull(fs.get(5, TimeUnit.MILLISECONDS));
    } catch (ExecutionException ex) {
        assertTrue(ex.toString(), ex.getCause() instanceof NoSuchElementException);
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest)

Example 17 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class FutureSubscriberTest method onCompleteCancelRace.

@Test
@SuppressUndeliverable
public void onCompleteCancelRace() {
    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        final FutureSubscriber<Integer> fs = new FutureSubscriber<>();
        if (i % 3 == 0) {
            fs.onSubscribe(new BooleanSubscription());
        }
        if (i % 2 == 0) {
            fs.onNext(1);
        }
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                fs.cancel(false);
            }
        };
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                fs.onComplete();
            }
        };
        TestHelper.race(r1, r2);
    }
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest)

Example 18 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class FutureSubscriberTest method onErrorOnComplete.

@Test
@SuppressUndeliverable
public void onErrorOnComplete() throws Exception {
    fs.onError(new TestException("One"));
    fs.onComplete();
    try {
        fs.get(5, TimeUnit.MILLISECONDS);
    } catch (ExecutionException ex) {
        assertTrue(ex.toString(), ex.getCause() instanceof TestException);
        assertEquals("One", ex.getCause().getMessage());
    }
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest)

Example 19 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class LambdaSubscriberTest method badSourceEmitAfterDone.

@Test
@SuppressUndeliverable
public void badSourceEmitAfterDone() {
    Flowable<Integer> source = Flowable.fromPublisher(new Publisher<Integer>() {

        @Override
        public void subscribe(Subscriber<? super Integer> s) {
            BooleanSubscription s1 = new BooleanSubscription();
            s.onSubscribe(s1);
            s.onNext(1);
            s.onComplete();
            s.onNext(2);
            s.onError(new TestException());
            s.onComplete();
        }
    });
    final List<Object> received = new ArrayList<>();
    LambdaSubscriber<Object> subscriber = new LambdaSubscriber<>(new Consumer<Object>() {

        @Override
        public void accept(Object v) throws Exception {
            received.add(v);
        }
    }, new Consumer<Throwable>() {

        @Override
        public void accept(Throwable e) throws Exception {
            received.add(e);
        }
    }, new Action() {

        @Override
        public void run() throws Exception {
            received.add(100);
        }
    }, new Consumer<Subscription>() {

        @Override
        public void accept(Subscription s) throws Exception {
            s.request(Long.MAX_VALUE);
        }
    });
    source.subscribe(subscriber);
    assertEquals(Arrays.asList(1, 100), received);
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 20 with SuppressUndeliverable

use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.

the class ObservableWindowWithTimeTest method overlappingOnError.

@Test
@SuppressUndeliverable
public void overlappingOnError() {
    TestScheduler scheduler = new TestScheduler();
    PublishSubject<Integer> ps = PublishSubject.create();
    TestObserver<Integer> to = ps.window(2, 1, TimeUnit.SECONDS, scheduler).flatMap(Functions.<Observable<Integer>>identity()).test();
    ps.onError(new TestException());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Observable(io.reactivex.rxjava3.core.Observable)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)31 Test (org.junit.Test)30 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 Observable (io.reactivex.rxjava3.core.Observable)8 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)8 IOException (java.io.IOException)8 SuppressUndeliverable (io.reactivex.rxjava3.testsupport.SuppressUndeliverable)7 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)6 Disposable (io.reactivex.rxjava3.disposables.Disposable)6 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)5 Scheduler (io.reactivex.rxjava3.core.Scheduler)3 TestObserver (io.reactivex.rxjava3.observers.TestObserver)3 NewThreadWorker (io.reactivex.rxjava3.internal.schedulers.NewThreadWorker)2 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)2 Observer (io.reactivex.rxjava3.core.Observer)1 Cancellable (io.reactivex.rxjava3.functions.Cancellable)1 ComputationScheduler (io.reactivex.rxjava3.internal.schedulers.ComputationScheduler)1 DelayedRunnable (io.reactivex.rxjava3.internal.schedulers.ExecutorScheduler.DelayedRunnable)1 IoScheduler (io.reactivex.rxjava3.internal.schedulers.IoScheduler)1 ScheduledWorker (io.reactivex.rxjava3.internal.schedulers.SingleScheduler.ScheduledWorker)1