Search in sources :

Example 21 with CompletableSubject

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

the class FlowableMergeWithCompletableTest method cancel.

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

Example 22 with CompletableSubject

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

the class FlowableMergeWithCompletableTest method cancelMainOnOtherError.

@Test
public void cancelMainOnOtherError() {
    PublishProcessor<Integer> pp = PublishProcessor.create();
    CompletableSubject cs = CompletableSubject.create();
    TestSubscriber<Integer> ts = pp.mergeWith(cs).test();
    assertTrue(pp.hasSubscribers());
    assertTrue(cs.hasObservers());
    cs.onError(new TestException());
    ts.assertFailure(TestException.class);
    assertFalse("main has observers!", pp.hasSubscribers());
    assertFalse("other has observers", cs.hasObservers());
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 23 with CompletableSubject

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

the class FlowableMergeWithCompletableTest method cancelOtherOnMainError.

@Test
public void cancelOtherOnMainError() {
    PublishProcessor<Integer> pp = PublishProcessor.create();
    CompletableSubject cs = CompletableSubject.create();
    TestSubscriber<Integer> ts = pp.mergeWith(cs).test();
    assertTrue(pp.hasSubscribers());
    assertTrue(cs.hasObservers());
    pp.onError(new TestException());
    ts.assertFailure(TestException.class);
    assertFalse("main has observers!", pp.hasSubscribers());
    assertFalse("other has observers", cs.hasObservers());
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) CompletableSubject(io.reactivex.rxjava3.subjects.CompletableSubject) Test(org.junit.Test)

Example 24 with CompletableSubject

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

the class ObservableMergeWithCompletableTest method cancelOtherOnMainError.

@Test
public void cancelOtherOnMainError() {
    PublishSubject<Integer> ps = PublishSubject.create();
    CompletableSubject cs = CompletableSubject.create();
    TestObserver<Integer> to = ps.mergeWith(cs).test();
    assertTrue(ps.hasObservers());
    assertTrue(cs.hasObservers());
    ps.onError(new TestException());
    to.assertFailure(TestException.class);
    assertFalse("main has observers!", ps.hasObservers());
    assertFalse("other has observers", cs.hasObservers());
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) Test(org.junit.Test)

Example 25 with CompletableSubject

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

the class ObservableMergeWithCompletableTest method cancelMainOnOtherError.

@Test
public void cancelMainOnOtherError() {
    PublishSubject<Integer> ps = PublishSubject.create();
    CompletableSubject cs = CompletableSubject.create();
    TestObserver<Integer> to = ps.mergeWith(cs).test();
    assertTrue(ps.hasObservers());
    assertTrue(cs.hasObservers());
    cs.onError(new TestException());
    to.assertFailure(TestException.class);
    assertFalse("main has observers!", ps.hasObservers());
    assertFalse("other has observers", cs.hasObservers());
}
Also used : TestException(io.reactivex.rxjava3.exceptions.TestException) 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