Search in sources :

Example 6 with Flowable

use of io.reactivex.rxjava3.core.Flowable in project RxJava by ReactiveX.

the class FlowableWindowWithStartEndFlowableTest method closeError.

@Test
public void closeError() throws Throwable {
    TestHelper.withErrorTracking(errors -> {
        AtomicReference<Subscriber<? super Integer>> ref1 = new AtomicReference<>();
        AtomicReference<Subscriber<? super Integer>> ref2 = new AtomicReference<>();
        Flowable<Integer> f1 = Flowable.<Integer>unsafeCreate(ref1::set);
        Flowable<Integer> f2 = Flowable.<Integer>unsafeCreate(ref2::set);
        TestSubscriber<Integer> ts = BehaviorProcessor.createDefault(1).window(f1, v -> f2).flatMap(v -> v).test();
        ref1.get().onSubscribe(new BooleanSubscription());
        ref1.get().onNext(1);
        ref2.get().onSubscribe(new BooleanSubscription());
        ref2.get().onError(new TestException());
        ref2.get().onError(new TestException());
        ts.assertFailure(TestException.class);
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    });
}
Also used : java.util(java.util) io.reactivex.rxjava3.functions(io.reactivex.rxjava3.functions) java.util.concurrent.atomic(java.util.concurrent.atomic) io.reactivex.rxjava3.subscribers(io.reactivex.rxjava3.subscribers) IOException(java.io.IOException) io.reactivex.rxjava3.exceptions(io.reactivex.rxjava3.exceptions) io.reactivex.rxjava3.processors(io.reactivex.rxjava3.processors) TimeUnit(java.util.concurrent.TimeUnit) Functions(io.reactivex.rxjava3.internal.functions.Functions) TestScheduler(io.reactivex.rxjava3.schedulers.TestScheduler) org.reactivestreams(org.reactivestreams) org.junit(org.junit) io.reactivex.rxjava3.core(io.reactivex.rxjava3.core) Assert(org.junit.Assert) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) io.reactivex.rxjava3.testsupport(io.reactivex.rxjava3.testsupport) RxJavaPlugins(io.reactivex.rxjava3.plugins.RxJavaPlugins) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)

Example 7 with Flowable

use of io.reactivex.rxjava3.core.Flowable in project RxJava by ReactiveX.

the class FlowableWindowWithStartEndFlowableTest method windowOpenMainError.

@Test
public void windowOpenMainError() {
    AtomicReference<Subscriber<? super Integer>> ref1 = new AtomicReference<>();
    PublishProcessor<Object> pp = PublishProcessor.create();
    Flowable<Integer> f1 = Flowable.<Integer>unsafeCreate(ref1::set);
    AtomicInteger counter = new AtomicInteger();
    TestSubscriber<Flowable<Object>> ts = pp.window(f1, v -> Flowable.never()).doOnNext(w -> {
        if (counter.getAndIncrement() == 0) {
            ref1.get().onNext(2);
            pp.onNext(1);
            pp.onError(new TestException());
        }
        w.test();
    }).test();
    ref1.get().onSubscribe(new BooleanSubscription());
    ref1.get().onNext(1);
    ts.assertError(TestException.class);
}
Also used : java.util(java.util) io.reactivex.rxjava3.functions(io.reactivex.rxjava3.functions) java.util.concurrent.atomic(java.util.concurrent.atomic) io.reactivex.rxjava3.subscribers(io.reactivex.rxjava3.subscribers) IOException(java.io.IOException) io.reactivex.rxjava3.exceptions(io.reactivex.rxjava3.exceptions) io.reactivex.rxjava3.processors(io.reactivex.rxjava3.processors) TimeUnit(java.util.concurrent.TimeUnit) Functions(io.reactivex.rxjava3.internal.functions.Functions) TestScheduler(io.reactivex.rxjava3.schedulers.TestScheduler) org.reactivestreams(org.reactivestreams) org.junit(org.junit) io.reactivex.rxjava3.core(io.reactivex.rxjava3.core) Assert(org.junit.Assert) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) io.reactivex.rxjava3.testsupport(io.reactivex.rxjava3.testsupport) RxJavaPlugins(io.reactivex.rxjava3.plugins.RxJavaPlugins) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)

Example 8 with Flowable

use of io.reactivex.rxjava3.core.Flowable in project RxJava by ReactiveX.

the class FlowableWithLatestFromTest method withError.

@Test
public void withError() {
    TestSubscriber<String> ts = new TestSubscriber<>(0);
    Flowable.range(1, 3).withLatestFrom(new Flowable<?>[] { Flowable.just(1), Flowable.error(new TestException()) }, toArray).subscribe(ts);
    ts.assertNoValues();
    ts.assertError(TestException.class);
    ts.assertNotComplete();
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 9 with Flowable

use of io.reactivex.rxjava3.core.Flowable in project RxJava by ReactiveX.

the class FlowableWithLatestFromTest method withMainError.

@Test
public void withMainError() {
    TestSubscriber<String> ts = new TestSubscriber<>(0);
    Flowable.error(new TestException()).withLatestFrom(new Flowable<?>[] { Flowable.just(1), Flowable.just(1) }, toArray).subscribe(ts);
    ts.assertNoValues();
    ts.assertError(TestException.class);
    ts.assertNotComplete();
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 10 with Flowable

use of io.reactivex.rxjava3.core.Flowable in project RxJava by ReactiveX.

the class MaybeDelaySubscriptionTest method withPublisherCallAfterTerminalEvent.

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

            @Override
            protected void subscribeActual(Subscriber<? super Integer> subscriber) {
                subscriber.onSubscribe(new BooleanSubscription());
                subscriber.onNext(1);
                subscriber.onError(new TestException());
                subscriber.onComplete();
                subscriber.onNext(2);
            }
        };
        Maybe.just(1).delaySubscription(f).test().assertResult(1);
        TestHelper.assertUndeliverable(errors, 0, TestException.class);
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestException(io.reactivex.rxjava3.exceptions.TestException) Subscriber(org.reactivestreams.Subscriber) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)177 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)121 TestException (io.reactivex.rxjava3.exceptions.TestException)95 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)67 InOrder (org.mockito.InOrder)41 IOException (java.io.IOException)27 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)22 Disposable (io.reactivex.rxjava3.disposables.Disposable)21 Flowable (io.reactivex.rxjava3.core.Flowable)19 TimeUnit (java.util.concurrent.TimeUnit)19 FlowableRxInvokerProvider (org.apache.cxf.jaxrs.rx3.client.FlowableRxInvokerProvider)18 FlowableRxInvoker (org.apache.cxf.jaxrs.rx3.client.FlowableRxInvoker)17 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)15 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)13 ClientBuilder (javax.ws.rs.client.ClientBuilder)13 MediaType (javax.ws.rs.core.MediaType)13 AbstractResourceInfo (org.apache.cxf.jaxrs.model.AbstractResourceInfo)13 AbstractBusClientServerTestBase (org.apache.cxf.testutil.common.AbstractBusClientServerTestBase)13 Assert.assertTrue (org.junit.Assert.assertTrue)13 BeforeClass (org.junit.BeforeClass)13