Search in sources :

Example 96 with TestSubscriber

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

the class FlowableCacheTest method valuesAndThenError.

@Test
public void valuesAndThenError() {
    Flowable<Integer> source = Flowable.range(1, 10).concatWith(Flowable.<Integer>error(new TestException())).cache();
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    source.subscribe(ts);
    ts.assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    ts.assertNotComplete();
    ts.assertError(TestException.class);
    TestSubscriber<Integer> ts2 = new TestSubscriber<>();
    source.subscribe(ts2);
    ts2.assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    ts2.assertNotComplete();
    ts2.assertError(TestException.class);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestException(io.reactivex.rxjava3.exceptions.TestException) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) Test(org.junit.Test)

Example 97 with TestSubscriber

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

the class FlowableBufferTest method timedSizeBufferAlreadyCleared.

@Test
public void timedSizeBufferAlreadyCleared() {
    TestScheduler sch = new TestScheduler();
    TestSubscriber<List<Integer>> ts = new TestSubscriber<>();
    BufferExactBoundedSubscriber<Integer, List<Integer>> sub = new BufferExactBoundedSubscriber<>(ts, Functions.justSupplier((List<Integer>) new ArrayList<Integer>()), 1, TimeUnit.SECONDS, 1, false, sch.createWorker());
    BooleanSubscription bs = new BooleanSubscription();
    sub.onSubscribe(bs);
    sub.producerIndex++;
    sub.run();
    assertFalse(sub.isDisposed());
    sub.enter();
    sub.onComplete();
    assertTrue(sub.isDisposed());
    sub.run();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)

Example 98 with TestSubscriber

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

the class FlowableBufferTest method timedSkipCancelWhenSecondBuffer.

@Test
public void timedSkipCancelWhenSecondBuffer() {
    TestScheduler sch = new TestScheduler();
    final TestSubscriber<List<Integer>> ts = new TestSubscriber<>();
    BufferSkipBoundedSubscriber<Integer, List<Integer>> sub = new BufferSkipBoundedSubscriber<>(ts, new Supplier<List<Integer>>() {

        int calls;

        @Override
        public List<Integer> get() throws Exception {
            if (++calls == 2) {
                ts.cancel();
            }
            return new ArrayList<>();
        }
    }, 1, 1, TimeUnit.SECONDS, sch.createWorker());
    sub.onSubscribe(new BooleanSubscription());
    sub.run();
    assertTrue(ts.isCancelled());
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) IOException(java.io.IOException)

Example 99 with TestSubscriber

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

the class FlowableBufferTest method bufferExactBoundaryBadSource.

@Test
public void bufferExactBoundaryBadSource() {
    Flowable<Integer> pp = new Flowable<Integer>() {

        @Override
        protected void subscribeActual(Subscriber<? super Integer> subscriber) {
            subscriber.onSubscribe(new BooleanSubscription());
            subscriber.onComplete();
            subscriber.onNext(1);
            subscriber.onComplete();
        }
    };
    final AtomicReference<Subscriber<? super Integer>> ref = new AtomicReference<>();
    Flowable<Integer> b = new Flowable<Integer>() {

        @Override
        protected void subscribeActual(Subscriber<? super Integer> subscriber) {
            subscriber.onSubscribe(new BooleanSubscription());
            ref.set(subscriber);
        }
    };
    TestSubscriber<List<Integer>> ts = pp.buffer(b).test();
    ref.get().onNext(1);
    ts.assertResult(Collections.<Integer>emptyList());
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)

Example 100 with TestSubscriber

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

the class FlowableConcatWithMaybeTest method otherError.

@Test
public void otherError() {
    final TestSubscriber<Integer> ts = new TestSubscriber<>();
    Flowable.range(1, 5).concatWith(Maybe.<Integer>error(new TestException())).subscribe(ts);
    ts.assertFailure(TestException.class, 1, 2, 3, 4, 5);
}
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