Search in sources :

Example 96 with TestException

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

the class ReplaySubjectTest method peekStateTimeAndSizeValue.

@Test
public void peekStateTimeAndSizeValue() {
    ReplaySubject<Integer> rp = ReplaySubject.createWithTimeAndSize(1, TimeUnit.DAYS, Schedulers.computation(), 1);
    assertNull(rp.getValue());
    assertEquals(0, rp.getValues().length);
    assertNull(rp.getValues(new Integer[2])[0]);
    rp.onComplete();
    assertNull(rp.getValue());
    assertEquals(0, rp.getValues().length);
    assertNull(rp.getValues(new Integer[2])[0]);
    rp = ReplaySubject.createWithTimeAndSize(1, TimeUnit.DAYS, Schedulers.computation(), 1);
    rp.onError(new TestException());
    assertNull(rp.getValue());
    assertEquals(0, rp.getValues().length);
    assertNull(rp.getValues(new Integer[2])[0]);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException)

Example 97 with TestException

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

the class ReplaySubjectTest method sizeboundReplayError.

@Test
public void sizeboundReplayError() {
    ReplaySubject<Integer> rp = ReplaySubject.createWithSize(2);
    rp.onNext(1);
    rp.onNext(2);
    rp.onNext(3);
    rp.onNext(4);
    rp.onError(new TestException());
    rp.test().assertFailure(TestException.class, 3, 4);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException)

Example 98 with TestException

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

the class AsyncSubjectTest method currentStateMethodsError.

@Test
public void currentStateMethodsError() {
    AsyncSubject<Object> as = AsyncSubject.create();
    assertFalse(as.hasValue());
    assertFalse(as.hasThrowable());
    assertFalse(as.hasComplete());
    assertNull(as.getValue());
    assertNull(as.getThrowable());
    as.onError(new TestException());
    assertFalse(as.hasValue());
    assertTrue(as.hasThrowable());
    assertFalse(as.hasComplete());
    assertNull(as.getValue());
    assertTrue(as.getThrowable() instanceof TestException);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 99 with TestException

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

the class AsyncSubjectTest method onErrorCrossCancel.

@Test
@SuppressUndeliverable
public void onErrorCrossCancel() {
    AsyncSubject<Object> p = AsyncSubject.create();
    final TestObserver<Object> to2 = new TestObserver<>();
    TestObserver<Object> to1 = new TestObserver<Object>() {

        @Override
        public void onError(Throwable t) {
            to2.dispose();
            super.onError(t);
        }
    };
    p.subscribe(to1);
    p.subscribe(to2);
    p.onError(new TestException());
    to1.assertFailure(TestException.class);
    to2.assertEmpty();
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestObserver(io.reactivex.rxjava3.observers.TestObserver) Test(org.junit.Test)

Example 100 with TestException

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

the class PublishSubjectTest method currentStateMethodsError.

@Test
public void currentStateMethodsError() {
    PublishSubject<Object> as = PublishSubject.create();
    assertFalse(as.hasThrowable());
    assertFalse(as.hasComplete());
    assertNull(as.getThrowable());
    as.onError(new TestException());
    assertTrue(as.hasThrowable());
    assertFalse(as.hasComplete());
    assertTrue(as.getThrowable() instanceof TestException);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Aggregations

TestException (io.reactivex.rxjava3.exceptions.TestException)656 Test (org.junit.Test)555 IOException (java.io.IOException)95 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)90 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)81 Disposable (io.reactivex.rxjava3.disposables.Disposable)56 InOrder (org.mockito.InOrder)54 TestObserver (io.reactivex.rxjava3.observers.TestObserver)47 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)47 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)40 Observable (io.reactivex.rxjava3.core.Observable)38 io.reactivex.rxjava3.core (io.reactivex.rxjava3.core)20 Action (io.reactivex.rxjava3.functions.Action)20 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)20 CompletableSubject (io.reactivex.rxjava3.subjects.CompletableSubject)18 Observer (io.reactivex.rxjava3.core.Observer)15 TestHelper (io.reactivex.rxjava3.testsupport.TestHelper)15 Assert (org.junit.Assert)15 java.util (java.util)13 RxJavaPlugins (io.reactivex.rxjava3.plugins.RxJavaPlugins)12