use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeBlockingSubscribeTest method threeArgEmptyFails.
@Test
public void threeArgEmptyFails() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<Integer> success = mock(Consumer.class);
@SuppressWarnings("unchecked") Consumer<? super Throwable> consumer = mock(Consumer.class);
Action action = mock(Action.class);
doThrow(new TestException()).when(action).run();
Maybe.<Integer>empty().delay(50, TimeUnit.MILLISECONDS, Schedulers.computation()).blockingSubscribe(success, consumer, action);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
verify(success, never()).accept(any());
verify(consumer, never()).accept(any());
verify(action).run();
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeBlockingSubscribeTest method oneArgSuccessFails.
@Test
public void oneArgSuccessFails() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<Integer> success = mock(Consumer.class);
doThrow(new TestException()).when(success).accept(any());
Maybe.just(1).blockingSubscribe(success);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
verify(success).accept(1);
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeBlockingSubscribeTest method twoArgErrorFails.
@Test
public void twoArgErrorFails() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<Integer> success = mock(Consumer.class);
@SuppressWarnings("unchecked") Consumer<? super Throwable> consumer = mock(Consumer.class);
doThrow(new TestException()).when(consumer).accept(any());
Maybe.<Integer>error(new TestException()).delay(50, TimeUnit.MILLISECONDS, Schedulers.computation()).blockingSubscribe(success, consumer);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
verify(success, never()).accept(any());
verify(consumer).accept(any(TestException.class));
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class BooleanRunnableTest method runnableThrows.
@Test
public void runnableThrows() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
BooleanRunnable task = new BooleanRunnable(() -> {
throw new TestException();
});
try {
task.run();
fail("Should have thrown!");
} catch (TestException expected) {
// expected
}
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class InstantPeriodicTaskTest method dispose3.
@Test
public void dispose3() throws Exception {
ExecutorService exec = Executors.newSingleThreadExecutor();
try {
InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() {
@Override
public void run() {
throw new TestException();
}
}, exec);
task.dispose();
FutureTask<Void> f1 = new FutureTask<>(Functions.EMPTY_RUNNABLE, null);
task.setFirst(f1);
assertTrue(f1.isCancelled());
FutureTask<Void> f2 = new FutureTask<>(Functions.EMPTY_RUNNABLE, null);
task.setRest(f2);
assertTrue(f2.isCancelled());
} finally {
exec.shutdownNow();
RxJavaPlugins.reset();
}
}
Aggregations