use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class ObservableReplayEagerTruncateTest method connectConsumerThrows.
@Test
public void connectConsumerThrows() {
ConnectableObservable<Integer> co = Observable.range(1, 2).replay();
try {
co.connect(new Consumer<Disposable>() {
@Override
public void accept(Disposable t) throws Exception {
throw new TestException();
}
});
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
co.test().assertEmpty().dispose();
co.connect();
co.test().assertResult(1, 2);
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class ObservableReplayEagerTruncateTest method disposeNoNeedForResetTimeAndSIzeBound.
@Test
public void disposeNoNeedForResetTimeAndSIzeBound() {
PublishSubject<Integer> ps = PublishSubject.create();
ConnectableObservable<Integer> co = ps.replay(10, 10, TimeUnit.MINUTES, Schedulers.single(), true);
TestObserver<Integer> to = co.test();
Disposable d = co.connect();
ps.onNext(1);
d.dispose();
to = co.test();
to.assertEmpty();
co.connect();
to.assertEmpty();
ps.onNext(2);
to.assertValuesOnly(2);
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class ObservableResourceWrapperTest method onErrorDisposes.
@Test
public void onErrorDisposes() {
TestObserver<Object> to = new TestObserver<>();
ObserverResourceWrapper<Object> orw = new ObserverResourceWrapper<>(to);
Disposable d = Disposable.empty();
Disposable d1 = Disposable.empty();
orw.setResource(d1);
orw.onSubscribe(d);
orw.onError(new TestException());
assertTrue(d1.isDisposed());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class ObservableObserveOnTest method outputFusedCancelReentrant.
@Test
public void outputFusedCancelReentrant() throws Exception {
final UnicastSubject<Integer> us = UnicastSubject.create();
final CountDownLatch cdl = new CountDownLatch(1);
us.observeOn(Schedulers.single()).subscribe(new Observer<Integer>() {
Disposable upstream;
int count;
@Override
public void onSubscribe(Disposable d) {
this.upstream = d;
((QueueDisposable<?>) d).requestFusion(QueueFuseable.ANY);
}
@Override
public void onNext(Integer value) {
if (++count == 1) {
us.onNext(2);
upstream.dispose();
cdl.countDown();
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
us.onNext(1);
cdl.await();
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class TestObserverExTest method completeDelegateThrows.
@Test
public void completeDelegateThrows() {
TestObserverEx<Integer> to = new TestObserverEx<>(new Observer<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Integer value) {
}
@Override
public void onError(Throwable e) {
throw new TestException();
}
@Override
public void onComplete() {
throw new TestException();
}
});
to.onSubscribe(Disposable.empty());
try {
to.onComplete();
throw new RuntimeException("Should have thrown!");
} catch (TestException ex) {
to.assertTerminated();
}
}
Aggregations