use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithFlowableSourceThrows.
@Test
public void testDelayWithFlowableSourceThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> delay = PublishProcessor.create();
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return delay;
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.delay(delayFunc).subscribe(o);
source.onNext(1);
source.onError(new TestException());
delay.onNext(1);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FlowableDelayTest method testDelayWithFlowableSubscriptionFunctionThrows.
@Test
public void testDelayWithFlowableSubscriptionFunctionThrows() {
PublishProcessor<Integer> source = PublishProcessor.create();
final PublishProcessor<Integer> delay = PublishProcessor.create();
Callable<Flowable<Integer>> subFunc = new Callable<Flowable<Integer>>() {
@Override
public Flowable<Integer> call() {
throw new TestException();
}
};
Function<Integer, Flowable<Integer>> delayFunc = new Function<Integer, Flowable<Integer>>() {
@Override
public Flowable<Integer> apply(Integer t1) {
return delay;
}
};
Subscriber<Object> o = TestHelper.mockSubscriber();
InOrder inOrder = inOrder(o);
source.delay(Flowable.defer(subFunc), delayFunc).subscribe(o);
source.onNext(1);
delay.onNext(1);
source.onNext(2);
inOrder.verify(o).onError(any(TestException.class));
inOrder.verifyNoMoreInteractions();
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class CompletableMergeIterableTest method errorRace.
@Test
public void errorRace() {
for (int i = 0; i < 500; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishSubject<Integer> ps1 = PublishSubject.create();
final PublishSubject<Integer> ps2 = PublishSubject.create();
TestObserver<Void> to = Completable.merge(Arrays.asList(ps1.ignoreElements(), ps2.ignoreElements())).test();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
ps1.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
ps2.onError(ex);
}
};
TestHelper.race(r1, r2, Schedulers.single());
to.assertFailure(TestException.class);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class CompletablePeekTest method onAfterTerminateCrashes.
@Test
public void onAfterTerminateCrashes() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Completable.complete().doAfterTerminate(new Action() {
@Override
public void run() throws Exception {
throw new TestException();
}
}).test().assertResult();
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class CompletableTimeoutTest method errorTimeoutRace.
@Test
public void errorTimeoutRace() {
for (int i = 0; i < 500; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final TestScheduler scheduler = new TestScheduler();
final PublishSubject<Integer> ps = PublishSubject.create();
TestObserver<Void> to = ps.ignoreElements().timeout(1, TimeUnit.MILLISECONDS, scheduler, Completable.complete()).test();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
ps.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);
}
};
TestHelper.race(r1, r2, Schedulers.single());
to.assertTerminated();
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
Aggregations