Search in sources :

Example 96 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class MaybeTakeUntilPublisherTest method otherErrors.

@Test
public void otherErrors() {
    PublishProcessor<Integer> pp1 = PublishProcessor.create();
    PublishProcessor<Integer> pp2 = PublishProcessor.create();
    TestObserver<Integer> to = pp1.singleElement().takeUntil(pp2).test();
    assertTrue(pp1.hasSubscribers());
    assertTrue(pp2.hasSubscribers());
    pp2.onError(new TestException());
    assertFalse(pp1.hasSubscribers());
    assertFalse(pp2.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 97 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class MaybeTakeUntilPublisherTest method onErrorRace.

@Test
public void onErrorRace() {
    for (int i = 0; i < 500; i++) {
        final PublishProcessor<Integer> pp1 = PublishProcessor.create();
        final PublishProcessor<Integer> pp2 = PublishProcessor.create();
        TestObserver<Integer> to = pp1.singleElement().takeUntil(pp2).test();
        final TestException ex1 = new TestException();
        final TestException ex2 = new TestException();
        List<Throwable> errors = TestHelper.trackPluginErrors();
        try {
            Runnable r1 = new Runnable() {

                @Override
                public void run() {
                    pp1.onError(ex1);
                }
            };
            Runnable r2 = new Runnable() {

                @Override
                public void run() {
                    pp2.onError(ex2);
                }
            };
            TestHelper.race(r1, r2, Schedulers.single());
            to.assertFailure(TestException.class);
            if (!errors.isEmpty()) {
                TestHelper.assertUndeliverable(errors, 0, TestException.class);
            }
        } finally {
            RxJavaPlugins.reset();
        }
    }
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 98 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class MaybeTakeUntilPublisherTest method mainErrors.

@Test
public void mainErrors() {
    PublishProcessor<Integer> pp1 = PublishProcessor.create();
    PublishProcessor<Integer> pp2 = PublishProcessor.create();
    TestObserver<Integer> to = pp1.singleElement().takeUntil(pp2).test();
    assertTrue(pp1.hasSubscribers());
    assertTrue(pp2.hasSubscribers());
    pp1.onError(new TestException());
    assertFalse(pp1.hasSubscribers());
    assertFalse(pp2.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 99 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class MaybeTimeoutPublisherTest method fallbackError.

@Test
public void fallbackError() {
    PublishProcessor<Integer> pp1 = PublishProcessor.create();
    PublishProcessor<Integer> pp2 = PublishProcessor.create();
    TestObserver<Integer> to = pp1.singleElement().timeout(pp2, Maybe.<Integer>error(new TestException())).test();
    assertTrue(pp1.hasSubscribers());
    assertTrue(pp2.hasSubscribers());
    pp2.onNext(1);
    pp2.onComplete();
    assertFalse(pp1.hasSubscribers());
    assertFalse(pp2.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 100 with TestException

use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.

the class MaybeTimeoutPublisherTest method mainError.

@Test
public void mainError() {
    PublishProcessor<Integer> pp1 = PublishProcessor.create();
    PublishProcessor<Integer> pp2 = PublishProcessor.create();
    TestObserver<Integer> to = pp1.singleElement().timeout(pp2).test();
    assertTrue(pp1.hasSubscribers());
    assertTrue(pp2.hasSubscribers());
    pp1.onError(new TestException());
    assertFalse(pp1.hasSubscribers());
    assertFalse(pp2.hasSubscribers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Aggregations

TestException (io.reactivex.exceptions.TestException)417 Test (org.junit.Test)255 InOrder (org.mockito.InOrder)35 IOException (java.io.IOException)28 BooleanSubscription (io.reactivex.internal.subscriptions.BooleanSubscription)26 TestObserver (io.reactivex.observers.TestObserver)26 Observable (io.reactivex.Observable)24 Function (io.reactivex.functions.Function)24 TestSubscriber (io.reactivex.subscribers.TestSubscriber)24 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)23 TestScheduler (io.reactivex.schedulers.TestScheduler)11 Observer (io.reactivex.Observer)8 QueueDisposable (io.reactivex.internal.fuseable.QueueDisposable)8 Disposable (io.reactivex.disposables.Disposable)7 CrashingIterable (io.reactivex.internal.util.CrashingIterable)6 Action (io.reactivex.functions.Action)5 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 ObserveOnObserver (io.reactivex.internal.operators.observable.ObservableObserveOn.ObserveOnObserver)2 ScalarDisposable (io.reactivex.internal.operators.observable.ObservableScalarXMap.ScalarDisposable)2 FutureSubscriber (io.reactivex.internal.subscribers.FutureSubscriber)2