Search in sources :

Example 66 with TestException

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

the class SingleTakeUntilTest method otherErrorCompletable.

@Test
public void otherErrorCompletable() {
    PublishProcessor<Integer> pp = PublishProcessor.create();
    PublishProcessor<Integer> source = PublishProcessor.create();
    TestObserver<Integer> to = source.single(-99).takeUntil(pp.ignoreElements()).test();
    pp.onError(new TestException());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 67 with TestException

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

the class SingleTakeUntilTest method untilSingleOtherError.

@Test
public void untilSingleOtherError() {
    SingleSubject<Integer> main = SingleSubject.create();
    SingleSubject<Integer> other = SingleSubject.create();
    TestObserver<Integer> to = main.takeUntil(other).test();
    assertTrue("Main no observers?", main.hasObservers());
    assertTrue("Other no observers?", other.hasObservers());
    other.onError(new TestException());
    assertFalse("Main has observers?", main.hasObservers());
    assertFalse("Other has observers?", other.hasObservers());
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 68 with TestException

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

the class SingleFromPublisherTest method badSource.

@Test
public void badSource() {
    List<Throwable> errors = TestHelper.trackPluginErrors();
    try {
        Single.fromPublisher(new Flowable<Integer>() {

            @Override
            protected void subscribeActual(Subscriber<? super Integer> s) {
                s.onSubscribe(new BooleanSubscription());
                BooleanSubscription s2 = new BooleanSubscription();
                s.onSubscribe(s2);
                assertTrue(s2.isCancelled());
                s.onNext(1);
                s.onComplete();
                s.onNext(2);
                s.onError(new TestException());
                s.onComplete();
            }
        }).test().assertResult(1);
        TestHelper.assertError(errors, 0, IllegalStateException.class, "Subscription already set!");
        TestHelper.assertUndeliverable(errors, 1, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 69 with TestException

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

the class SingleOfTypeTest method errorNotInstance.

@Test
public void errorNotInstance() {
    TestObserver<String> to = Single.<Integer>error(new TestException()).ofType(String.class).test();
    // don't make this fluent, target type required!
    to.assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 70 with TestException

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

the class SingleOfTypeTest method error.

@Test
public void error() {
    TestObserver<Number> to = Single.<Integer>error(new TestException()).ofType(Number.class).test();
    // don't make this fluent, target type required!
    to.assertFailure(TestException.class);
}
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