Search in sources :

Example 26 with CompletableSubject

use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.

the class FlowableConcatWithCompletableTest method cancelOther.

@Test
public void cancelOther() {
    CompletableSubject other = CompletableSubject.create();
    TestSubscriber<Object> ts = Flowable.empty().concatWith(other).test();
    assertTrue(other.hasObservers());
    ts.cancel();
    assertFalse(other.hasObservers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 27 with CompletableSubject

use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.

the class CompletableAndThenPublisherTest method cancelMain.

@Test
public void cancelMain() {
    CompletableSubject cs = CompletableSubject.create();
    PublishProcessor<Integer> pp = PublishProcessor.create();
    TestSubscriber<Integer> ts = cs.andThen(pp).test();
    assertTrue(cs.hasObservers());
    assertFalse(pp.hasSubscribers());
    ts.cancel();
    assertFalse(cs.hasObservers());
    assertFalse(pp.hasSubscribers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 28 with CompletableSubject

use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.

the class CompletableAndThenPublisherTest method cancelOther.

@Test
public void cancelOther() {
    CompletableSubject cs = CompletableSubject.create();
    PublishProcessor<Integer> pp = PublishProcessor.create();
    TestSubscriber<Integer> ts = cs.andThen(pp).test();
    assertTrue(cs.hasObservers());
    assertFalse(pp.hasSubscribers());
    cs.onComplete();
    assertFalse(cs.hasObservers());
    assertTrue(pp.hasSubscribers());
    ts.cancel();
    assertFalse(cs.hasObservers());
    assertFalse(pp.hasSubscribers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 29 with CompletableSubject

use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.

the class FlowableSwitchMapCompletableTest method dispose.

@Test
public void dispose() {
    PublishProcessor<Integer> pp = PublishProcessor.create();
    CompletableSubject cs = CompletableSubject.create();
    TestObserver<Void> to = pp.switchMapCompletable(Functions.justFunction(cs)).test();
    pp.onNext(1);
    assertTrue(pp.hasSubscribers());
    assertTrue(cs.hasObservers());
    to.dispose();
    assertFalse(pp.hasSubscribers());
    assertFalse(cs.hasObservers());
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 30 with CompletableSubject

use of io.reactivex.rxjava3.subjects.CompletableSubject in project RxJava by ReactiveX.

the class FlowableSwitchMapCompletableTest method onNextInnerCompleteRace.

@Test
public void onNextInnerCompleteRace() {
    for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
        final PublishProcessor<Integer> pp = PublishProcessor.create();
        final CompletableSubject cs = CompletableSubject.create();
        TestObserver<Void> to = pp.switchMapCompletable(Functions.justFunction(cs)).test();
        pp.onNext(1);
        Runnable r1 = new Runnable() {

            @Override
            public void run() {
                pp.onNext(2);
            }
        };
        Runnable r2 = new Runnable() {

            @Override
            public void run() {
                cs.onComplete();
            }
        };
        TestHelper.race(r1, r2);
        to.assertEmpty();
    }
}
Also used : CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)49 CompletableSubject (io.reactivex.rxjava3.subjects.CompletableSubject)41 TestException (io.reactivex.rxjava3.exceptions.TestException)14 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 TestScheduler (io.reactivex.rxjava3.schedulers.TestScheduler)1