use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableOnBackpressureReduceTest method exceptionFromReducer.
@Test
public void exceptionFromReducer() {
PublishProcessor<Integer> source = PublishProcessor.create();
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>(0);
source.onBackpressureReduce((l, r) -> {
throw new TestException("Test exception");
}).subscribe(ts);
source.onNext(1);
source.onNext(2);
TestHelper.assertError(ts.errors(), 0, TestException.class, "Test exception");
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableOnBackpressureReduceWithTest method exceptionFromSupplier.
@Test
public void exceptionFromSupplier() {
PublishProcessor<Integer> source = PublishProcessor.create();
TestSubscriberEx<List<Integer>> ts = new TestSubscriberEx<>(0L);
source.onBackpressureReduce(() -> {
throw new TestException("Test exception");
}, createTestReducer()).subscribe(ts);
source.onNext(1);
source.onNext(2);
TestHelper.assertError(ts.errors(), 0, TestException.class, "Test exception");
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class FlowableMapTest method mapFilterMapperCrashFused.
@Test
public void mapFilterMapperCrashFused() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<Integer>().setInitialFusionMode(QueueFuseable.ANY);
Flowable.range(1, 2).hide().map(new Function<Integer, Integer>() {
@Override
public Integer apply(Integer v) throws Exception {
throw new TestException();
}
}).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
return true;
}
}).subscribe(ts);
ts.assertFuseable().assertFusionMode(QueueFuseable.NONE).assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class TestSubscriberExTest method interruptTerminalEventAwaitAndUnsubscribe.
@Test
public void interruptTerminalEventAwaitAndUnsubscribe() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
final Thread t0 = Thread.currentThread();
Worker w = Schedulers.computation().createWorker();
try {
w.schedule(new Runnable() {
@Override
public void run() {
t0.interrupt();
}
}, 200, TimeUnit.MILLISECONDS);
try {
ts.awaitDone(5, TimeUnit.SECONDS);
} catch (RuntimeException allowed) {
assertTrue(allowed.toString(), allowed.getCause() instanceof InterruptedException);
}
ts.dispose();
if (!ts.isCancelled()) {
fail("Did not unsubscribe!");
}
} finally {
w.dispose();
}
}
use of io.reactivex.rxjava3.testsupport.TestSubscriberEx in project RxJava by ReactiveX.
the class TestSubscriberExTest method interruptTerminalEventAwaitTimed.
@Test
public void interruptTerminalEventAwaitTimed() {
TestSubscriberEx<Integer> ts = new TestSubscriberEx<>();
final Thread t0 = Thread.currentThread();
Worker w = Schedulers.computation().createWorker();
try {
w.schedule(new Runnable() {
@Override
public void run() {
t0.interrupt();
}
}, 200, TimeUnit.MILLISECONDS);
try {
if (ts.await(5, TimeUnit.SECONDS)) {
fail("Did not interrupt wait!");
}
} catch (InterruptedException expected) {
// expected
}
} finally {
// clear interrupted flag
Thread.interrupted();
w.dispose();
}
}
Aggregations