Search in sources :

Example 81 with TestSubscriber

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

the class QueueDrainSubscriberTest method unorderedSlowPath.

@Test
public void unorderedSlowPath() {
    TestSubscriber<Integer> ts = new TestSubscriber<>(1);
    Disposable d = Disposable.empty();
    QueueDrainSubscriber<Integer, Integer, Integer> qd = createUnordered(ts, d);
    ts.onSubscribe(new BooleanSubscription());
    qd.enter();
    qd.onNext(1);
    ts.assertEmpty();
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 82 with TestSubscriber

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

the class QueueDrainSubscriberTest method unorderedFastPathReject.

@Test
public void unorderedFastPathReject() {
    TestSubscriber<Integer> ts = new TestSubscriber<>(1);
    Disposable d = Disposable.empty();
    QueueDrainSubscriber<Integer, Integer, Integer> qd = createUnorderedReject(ts, d);
    ts.onSubscribe(new BooleanSubscription());
    qd.requested(1);
    qd.onNext(1);
    ts.assertValuesOnly(1);
    assertEquals(1, qd.requested());
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 83 with TestSubscriber

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

the class QueueDrainSubscriberTest method orderedOnNextRace.

@Test
public void orderedOnNextRace() {
    for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
        TestSubscriber<Integer> ts = new TestSubscriber<>(1);
        Disposable d = Disposable.empty();
        final QueueDrainSubscriber<Integer, Integer, Integer> qd = createOrdered(ts, d);
        ts.onSubscribe(new BooleanSubscription());
        qd.requested(Long.MAX_VALUE);
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                qd.onNext(1);
            }
        };
        TestHelper.race(r1, r1);
        ts.assertValuesOnly(1, 1);
    }
}
Also used : BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 84 with TestSubscriber

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

the class QueueDrainHelperTest method postCompleteWithRequest.

@Test
public void postCompleteWithRequest() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    ArrayDeque<Integer> queue = new ArrayDeque<>();
    AtomicLong state = new AtomicLong();
    BooleanSupplier isCancelled = new BooleanSupplier() {

        @Override
        public boolean getAsBoolean() throws Exception {
            return false;
        }
    };
    ts.onSubscribe(new BooleanSubscription());
    queue.offer(1);
    state.getAndIncrement();
    QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
    ts.assertResult(1);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) BooleanSupplier(io.reactivex.rxjava3.functions.BooleanSupplier) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) Test(org.junit.Test)

Example 85 with TestSubscriber

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

the class QueueDrainHelperTest method completeRequestRace.

@Test
public void completeRequestRace() {
    for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
        final TestSubscriber<Integer> ts = new TestSubscriber<>();
        final ArrayDeque<Integer> queue = new ArrayDeque<>();
        final AtomicLong state = new AtomicLong();
        final BooleanSupplier isCancelled = new BooleanSupplier() {

            @Override
            public boolean getAsBoolean() throws Exception {
                return false;
            }
        };
        ts.onSubscribe(new BooleanSubscription());
        queue.offer(1);
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                QueueDrainHelper.postCompleteRequest(1, ts, queue, state, isCancelled);
            }
        };
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
            }
        };
        TestHelper.race(r1, r2);
        ts.assertResult(1);
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) BooleanSubscription(io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription) TestSubscriber(io.reactivex.rxjava3.subscribers.TestSubscriber) BooleanSupplier(io.reactivex.rxjava3.functions.BooleanSupplier) RxJavaTest(io.reactivex.rxjava3.core.RxJavaTest) 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