Search in sources :

Example 1 with TestException

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

the class NotificationTest method toStringPattern.

@Test
public void toStringPattern() {
    assertEquals("OnNextNotification[1]", Notification.createOnNext(1).toString());
    assertEquals("OnErrorNotification[io.reactivex.exceptions.TestException]", Notification.createOnError(new TestException()).toString());
    assertEquals("OnCompleteNotification", Notification.createOnComplete().toString());
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 2 with TestException

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

the class NotificationTest method valueOfOnErrorIsNull.

@Test
public void valueOfOnErrorIsNull() {
    Notification<Integer> notification = Notification.createOnError(new TestException());
    assertNull(notification.getValue());
    assertTrue(notification.getError().toString(), notification.getError() instanceof TestException);
}
Also used : TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 3 with TestException

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

the class FutureObserverTest method cancel2.

@Test
public void cancel2() {
    fo.dispose();
    assertFalse(fo.isCancelled());
    assertFalse(fo.isDisposed());
    assertFalse(fo.isDone());
    for (int i = 0; i < 2; i++) {
        fo.cancel(i == 0);
        assertTrue(fo.isCancelled());
        assertTrue(fo.isDisposed());
        assertTrue(fo.isDone());
    }
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        fo.onNext(1);
        fo.onError(new TestException("First"));
        fo.onError(new TestException("Second"));
        fo.onComplete();
        assertTrue(fo.isCancelled());
        assertTrue(fo.isDisposed());
        assertTrue(fo.isDone());
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
        TestHelper.assertUndeliverable(errors, 1, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : TestException(io.reactivex.exceptions.TestException)

Example 4 with TestException

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

the class FutureObserverTest method onCompleteOnError.

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

Example 5 with TestException

use of io.reactivex.exceptions.TestException 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)

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