Search in sources :

Example 6 with TestSubscriber

use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.

the class FlowableWindowWithStartEndFlowableTest method windowOpenMainCompletes.

@Test
public void windowOpenMainCompletes() {
    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.onComplete();
        }
        w.test();
    }).test();
    ref1.get().onSubscribe(new BooleanSubscription());
    ref1.get().onNext(1);
    ts.assertComplete();
}
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 TestSubscriber

use of io.reactivex.rxjava3.subscribers.TestSubscriber 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 8 with TestSubscriber

use of io.reactivex.rxjava3.subscribers.TestSubscriber 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 9 with TestSubscriber

use of io.reactivex.rxjava3.subscribers.TestSubscriber 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 10 with TestSubscriber

use of io.reactivex.rxjava3.subscribers.TestSubscriber 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)

Aggregations

Test (org.junit.Test)169 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)116 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)106 TestException (io.reactivex.rxjava3.exceptions.TestException)56 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)27 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 IOException (java.io.IOException)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 Flowable (io.reactivex.rxjava3.core.Flowable)13 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 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)12