Search in sources :

Example 61 with BooleanSubscription

use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class ReplayProcessorTest method subscribeAfterDone.

@Test
public void subscribeAfterDone() {
    ReplayProcessor<Integer> rp = ReplayProcessor.create();
    rp.onComplete();
    BooleanSubscription bs = new BooleanSubscription();
    rp.onSubscribe(bs);
    assertTrue(bs.isCancelled());
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 62 with BooleanSubscription

use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class SerializedProcessorTest method onCompleteOnSubscribeRace.

@Test
public void onCompleteOnSubscribeRace() {
    for (int i = 0; i < 500; i++) {
        final FlowableProcessor<Integer> s = PublishProcessor.<Integer>create().toSerialized();
        TestSubscriber<Integer> ts = s.test();
        final BooleanSubscription bs = new BooleanSubscription();
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                s.onComplete();
            }
        };
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                s.onSubscribe(bs);
            }
        };
        TestHelper.race(r1, r2, Schedulers.single());
        ts.assertResult();
    }
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 63 with BooleanSubscription

use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class SerializedProcessorTest method onSubscribeOnSubscribeRace.

@Test
public void onSubscribeOnSubscribeRace() {
    for (int i = 0; i < 500; i++) {
        final FlowableProcessor<Integer> s = PublishProcessor.<Integer>create().toSerialized();
        TestSubscriber<Integer> ts = s.test();
        final BooleanSubscription bs1 = new BooleanSubscription();
        final BooleanSubscription bs2 = new BooleanSubscription();
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                s.onSubscribe(bs1);
            }
        };
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                s.onSubscribe(bs2);
            }
        };
        TestHelper.race(r1, r2, Schedulers.single());
        ts.assertEmpty();
    }
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 64 with BooleanSubscription

use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class ResourceSubscriberTest method startOnce.

@Test
public void startOnce() {
    List<Throwable> error = TestHelper.trackPluginErrors();
    try {
        TestResourceSubscriber<Integer> tc = new TestResourceSubscriber<Integer>();
        tc.onSubscribe(new BooleanSubscription());
        BooleanSubscription d = new BooleanSubscription();
        tc.onSubscribe(d);
        assertTrue(d.isCancelled());
        assertEquals(1, tc.start);
        TestHelper.assertError(error, 0, IllegalStateException.class, "Subscription already set!");
    } finally {
        RxJavaPlugins.reset();
    }
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Example 65 with BooleanSubscription

use of io.reactivex.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.

the class ResourceSubscriberTest method dispose.

@Test
public void dispose() {
    TestResourceSubscriber<Integer> tc = new TestResourceSubscriber<Integer>();
    tc.dispose();
    BooleanSubscription d = new BooleanSubscription();
    tc.onSubscribe(d);
    assertTrue(d.isCancelled());
    assertEquals(0, tc.start);
}
Also used : BooleanSubscription(io.reactivex.internal.subscriptions.BooleanSubscription) Test(org.junit.Test)

Aggregations

BooleanSubscription (io.reactivex.internal.subscriptions.BooleanSubscription)131 Test (org.junit.Test)70 TestSubscriber (io.reactivex.subscribers.TestSubscriber)31 TestException (io.reactivex.exceptions.TestException)24 InOrder (org.mockito.InOrder)21 IOException (java.io.IOException)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 BooleanSupplier (io.reactivex.functions.BooleanSupplier)5 ForEachWhileSubscriber (io.reactivex.internal.subscribers.ForEachWhileSubscriber)5 ArrayDeque (java.util.ArrayDeque)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 Disposable (io.reactivex.disposables.Disposable)4 GroupedFlowable (io.reactivex.flowables.GroupedFlowable)4 Subscriber (org.reactivestreams.Subscriber)4 BaseObserveOnSubscriber (io.reactivex.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber)3 Worker (io.reactivex.Scheduler.Worker)2 Nullable (io.reactivex.annotations.Nullable)2 ConnectableFlowable (io.reactivex.flowables.ConnectableFlowable)2 SubscribeOnSubscriber (io.reactivex.internal.operators.flowable.FlowableSubscribeOn.SubscribeOnSubscriber)2 FutureSubscriber (io.reactivex.internal.subscribers.FutureSubscriber)2