use of io.reactivex.rxjava3.functions.Action in project RxJava by ReactiveX.
the class DisposableLambdaObserverTest method disposeCrash.
@Test
public void disposeCrash() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
DisposableLambdaObserver<Integer> o = new DisposableLambdaObserver<>(new TestObserver<>(), Functions.emptyConsumer(), new Action() {
@Override
public void run() throws Exception {
throw new TestException();
}
});
o.onSubscribe(Disposable.empty());
assertFalse(o.isDisposed());
o.dispose();
assertTrue(o.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.functions.Action in project RxJava by ReactiveX.
the class CompletableConcatDelayErrorTest method normalIterable.
@Test
public void normalIterable() throws Throwable {
Action action1 = mock(Action.class);
Action action2 = mock(Action.class);
Completable.concatDelayError(Arrays.asList(Completable.fromAction(action1), Completable.error(new TestException()), Completable.fromAction(action2))).test().assertFailure(TestException.class);
verify(action1).run();
verify(action2).run();
}
use of io.reactivex.rxjava3.functions.Action in project RxJava by ReactiveX.
the class FlowableToSingleTest method shouldUseUnsafeSubscribeInternallyNotSubscribe.
@Test
public void shouldUseUnsafeSubscribeInternallyNotSubscribe() {
TestSubscriber<String> subscriber = TestSubscriber.create();
final AtomicBoolean unsubscribed = new AtomicBoolean(false);
Single<String> single = Flowable.just("Hello World!").doOnCancel(new Action() {
@Override
public void run() {
unsubscribed.set(true);
}
}).single("");
single.toFlowable().subscribe(subscriber);
subscriber.assertComplete();
Assert.assertFalse(unsubscribed.get());
}
use of io.reactivex.rxjava3.functions.Action in project RxJava by ReactiveX.
the class FlowableThrottleLatestTest method missingBackpressureExceptionLatest.
@Test
public void missingBackpressureExceptionLatest() throws Throwable {
TestScheduler sch = new TestScheduler();
Action onCancel = mock(Action.class);
TestSubscriber<Integer> ts = Flowable.just(1, 2).concatWith(Flowable.<Integer>never()).doOnCancel(onCancel).throttleLatest(1, TimeUnit.SECONDS, sch, true).test(1);
sch.advanceTimeBy(1, TimeUnit.SECONDS);
ts.assertFailure(MissingBackpressureException.class, 1);
verify(onCancel).run();
}
use of io.reactivex.rxjava3.functions.Action in project RxJava by ReactiveX.
the class FlowableToCompletableTest method shouldUseUnsafeSubscribeInternallyNotSubscribe.
@Test
public void shouldUseUnsafeSubscribeInternallyNotSubscribe() {
TestSubscriber<String> subscriber = TestSubscriber.create();
final AtomicBoolean unsubscribed = new AtomicBoolean(false);
Completable cmp = Flowable.just("Hello World!").doOnCancel(new Action() {
@Override
public void run() {
unsubscribed.set(true);
}
}).ignoreElements();
cmp.<String>toFlowable().subscribe(subscriber);
subscriber.assertComplete();
assertFalse(unsubscribed.get());
}
Aggregations