use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class DeferredScalarObserverTest method fusedReject.
@Test
public void fusedReject() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
TestObserverEx<Integer> to = new TestObserverEx<>(QueueFuseable.SYNC);
TakeFirst source = new TakeFirst(to);
Disposable d = Disposable.empty();
source.onSubscribe(d);
to.assertFuseable();
to.assertFusionMode(QueueFuseable.NONE);
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 MaybeCreateTest method onCompleteThrows.
@Test
public void onCompleteThrows() {
Maybe.create(new MaybeOnSubscribe<Object>() {
@Override
public void subscribe(MaybeEmitter<Object> e) throws Exception {
Disposable d = Disposable.empty();
e.setDisposable(d);
try {
e.onComplete();
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
assertTrue(d.isDisposed());
assertTrue(e.isDisposed());
}
}).subscribe(new MaybeObserver<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSuccess(Object value) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
throw new TestException();
}
});
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class MaybeDoOnEventTest method onSubscribeCrash.
@Test
public void onSubscribeCrash() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final Disposable bs = Disposable.empty();
new Maybe<Integer>() {
@Override
protected void subscribeActual(MaybeObserver<? super Integer> observer) {
observer.onSubscribe(bs);
observer.onError(new TestException("Second"));
observer.onComplete();
observer.onSuccess(1);
}
}.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable d) throws Exception {
throw new TestException("First");
}
}).to(TestHelper.<Integer>testConsumer()).assertFailureAndMessage(TestException.class, "First");
assertTrue(bs.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "Second");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class MaybeCreateTest method onErrorThrows2.
@Test
public void onErrorThrows2() {
Maybe.create(new MaybeOnSubscribe<Object>() {
@Override
public void subscribe(MaybeEmitter<Object> e) throws Exception {
try {
e.onError(new IOException());
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
assertTrue(e.isDisposed());
}
}).subscribe(new MaybeObserver<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSuccess(Object value) {
}
@Override
public void onError(Throwable e) {
throw new TestException();
}
@Override
public void onComplete() {
}
});
}
use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.
the class MaybeCreateTest method onSuccessThrows.
@Test
public void onSuccessThrows() {
Maybe.create(new MaybeOnSubscribe<Object>() {
@Override
public void subscribe(MaybeEmitter<Object> e) throws Exception {
Disposable d = Disposable.empty();
e.setDisposable(d);
try {
e.onSuccess(1);
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
assertTrue(d.isDisposed());
assertTrue(e.isDisposed());
}
}).subscribe(new MaybeObserver<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSuccess(Object value) {
throw new TestException();
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
}
Aggregations