Search in sources :

Example 1 with FutureSubscriber

use of io.reactivex.internal.subscribers.FutureSubscriber in project RxJava by ReactiveX.

the class FutureObserverTest method onErrorCancelRace.

@Test
public void onErrorCancelRace() {
    RxJavaPlugins.setErrorHandler(Functions.emptyConsumer());
    try {
        for (int i = 0; i < 500; i++) {
            final FutureSubscriber<Integer> fo = new FutureSubscriber<Integer>();
            final TestException ex = new TestException();
            Runnable r1 = new Runnable() {

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

                @Override
                public void run() {
                    fo.onError(ex);
                }
            };
            TestHelper.race(r1, r2, Schedulers.single());
        }
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : FutureSubscriber(io.reactivex.internal.subscribers.FutureSubscriber) TestException(io.reactivex.exceptions.TestException)

Example 2 with FutureSubscriber

use of io.reactivex.internal.subscribers.FutureSubscriber in project RxJava by ReactiveX.

the class FutureObserverTest method onCompleteCancelRace.

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

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

            @Override
            public void run() {
                fo.onComplete();
            }
        };
        TestHelper.race(r1, r2, Schedulers.single());
    }
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) FutureSubscriber(io.reactivex.internal.subscribers.FutureSubscriber)

Example 3 with FutureSubscriber

use of io.reactivex.internal.subscribers.FutureSubscriber in project RxJava by ReactiveX.

the class FutureSubscriberTest method onErrorCancelRace.

@Test
public void onErrorCancelRace() {
    for (int i = 0; i < 500; i++) {
        final FutureSubscriber<Integer> fs = new FutureSubscriber<Integer>();
        final TestException ex = new TestException();
        Runnable r1 = new Runnable() {

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

            @Override
            public void run() {
                fs.onError(ex);
            }
        };
        TestHelper.race(r1, r2, Schedulers.single());
    }
}
Also used : FutureSubscriber(io.reactivex.internal.subscribers.FutureSubscriber) TestException(io.reactivex.exceptions.TestException)

Example 4 with FutureSubscriber

use of io.reactivex.internal.subscribers.FutureSubscriber in project RxJava by ReactiveX.

the class FutureSubscriberTest method onCompleteCancelRace.

@Test
public void onCompleteCancelRace() {
    for (int i = 0; i < 500; i++) {
        final FutureSubscriber<Integer> fs = new FutureSubscriber<Integer>();
        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, Schedulers.single());
    }
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) FutureSubscriber(io.reactivex.internal.subscribers.FutureSubscriber)

Aggregations

FutureSubscriber (io.reactivex.internal.subscribers.FutureSubscriber)4 TestException (io.reactivex.exceptions.TestException)2 BooleanSubscription (io.reactivex.internal.subscriptions.BooleanSubscription)2