use of io.reactivex.rxjava3.subjects.SingleSubject in project RxJava by ReactiveX.
the class SingleTakeUntilTest method untilCompletableMainError.
@Test
public void untilCompletableMainError() {
SingleSubject<Integer> main = SingleSubject.create();
CompletableSubject other = CompletableSubject.create();
TestObserver<Integer> to = main.takeUntil(other).test();
assertTrue("Main no observers?", main.hasObservers());
assertTrue("Other no observers?", other.hasObservers());
main.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subjects.SingleSubject in project RxJava by ReactiveX.
the class SingleTakeUntilTest method untilCompletableOtherError.
@Test
public void untilCompletableOtherError() {
SingleSubject<Integer> main = SingleSubject.create();
CompletableSubject other = CompletableSubject.create();
TestObserver<Integer> to = main.takeUntil(other).test();
assertTrue("Main no observers?", main.hasObservers());
assertTrue("Other no observers?", other.hasObservers());
other.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasObservers());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.subjects.SingleSubject in project RxJava by ReactiveX.
the class SingleTimeoutTest method errorTimeoutRace.
@Test
public void errorTimeoutRace() {
final TestException ex = new TestException();
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final SingleSubject<Integer> subj = SingleSubject.create();
SingleSubject<Integer> fallback = SingleSubject.create();
final TestScheduler sch = new TestScheduler();
TestObserver<Integer> to = subj.timeout(1, TimeUnit.MILLISECONDS, sch, fallback).test();
Runnable r1 = new Runnable() {
@Override
public void run() {
subj.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
sch.advanceTimeBy(1, TimeUnit.MILLISECONDS);
}
};
TestHelper.race(r1, r2);
if (!fallback.hasObservers()) {
to.assertFailure(TestException.class);
} else {
to.assertEmpty();
}
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
}
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.subjects.SingleSubject in project RxJava by ReactiveX.
the class SingleTimeoutTest method fallbackDispose.
@Test
public void fallbackDispose() {
TestScheduler sch = new TestScheduler();
SingleSubject<Integer> subj = SingleSubject.create();
SingleSubject<Integer> fallback = SingleSubject.create();
TestObserver<Integer> to = subj.timeout(1, TimeUnit.SECONDS, sch, fallback).test();
assertFalse(fallback.hasObservers());
sch.advanceTimeBy(1, TimeUnit.SECONDS);
assertFalse(subj.hasObservers());
assertTrue(fallback.hasObservers());
to.dispose();
assertFalse(fallback.hasObservers());
}
use of io.reactivex.rxjava3.subjects.SingleSubject in project RxJava by ReactiveX.
the class SingleTimeoutTest method disposeWhenFallback.
@Test
public void disposeWhenFallback() {
TestScheduler sch = new TestScheduler();
SingleSubject<Integer> subj = SingleSubject.create();
subj.timeout(1, TimeUnit.SECONDS, sch, Single.just(1)).test(true).assertEmpty();
assertFalse(subj.hasObservers());
}
Aggregations