use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method disposed.
@Test
public void disposed() {
TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.NONE);
TakeLast source = new TakeLast(to);
Disposable d = Disposable.empty();
source.onSubscribe(d);
to.dispose();
source.onNext(1);
source.onComplete();
to.assertNoValues().assertNoErrors().assertNotComplete();
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method disposedAfterOnNext.
@Test
public void disposedAfterOnNext() {
final TestObserver<Integer> to = new TestObserver<>();
TakeLast source = new TakeLast(new Observer<Integer>() {
Disposable upstream;
@Override
public void onSubscribe(Disposable d) {
this.upstream = d;
to.onSubscribe(d);
}
@Override
public void onNext(Integer value) {
to.onNext(value);
upstream.dispose();
}
@Override
public void onError(Throwable e) {
to.onError(e);
}
@Override
public void onComplete() {
to.onComplete();
}
});
source.onSubscribe(Disposable.empty());
source.onNext(1);
source.onComplete();
to.assertValue(1).assertNoErrors().assertNotComplete();
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method nonfusedEmpty.
@Test
public void nonfusedEmpty() {
TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.NONE);
TakeLast source = new TakeLast(to);
Disposable d = Disposable.empty();
source.onSubscribe(d);
source.onComplete();
to.assertResult();
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method fused.
@Test
public void fused() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.ANY);
TakeFirst source = new TakeFirst(to);
Disposable d = Disposable.empty();
source.onSubscribe(d);
to.assertFuseable();
to.assertFusionMode(QueueFuseable.ASYNC);
source.onNext(1);
source.onNext(1);
source.onError(new TestException());
source.onComplete();
assertTrue(d.isDisposed());
to.assertResult(1);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method dispose.
@Test
public void dispose() {
TestObserver<Integer> to = new TestObserver<>();
TakeFirst source = new TakeFirst(to);
Disposable d = Disposable.empty();
source.onSubscribe(d);
assertFalse(d.isDisposed());
to.dispose();
assertTrue(d.isDisposed());
assertTrue(source.isDisposed());
}
Aggregations