use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class NotificationTest method toStringPattern.
@Test
public void toStringPattern() {
assertEquals("OnNextNotification[1]", Notification.createOnNext(1).toString());
assertEquals("OnErrorNotification[io.reactivex.exceptions.TestException]", Notification.createOnError(new TestException()).toString());
assertEquals("OnCompleteNotification", Notification.createOnComplete().toString());
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class NotificationTest method valueOfOnErrorIsNull.
@Test
public void valueOfOnErrorIsNull() {
Notification<Integer> notification = Notification.createOnError(new TestException());
assertNull(notification.getValue());
assertTrue(notification.getError().toString(), notification.getError() instanceof TestException);
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FutureObserverTest method cancel2.
@Test
public void cancel2() {
fo.dispose();
assertFalse(fo.isCancelled());
assertFalse(fo.isDisposed());
assertFalse(fo.isDone());
for (int i = 0; i < 2; i++) {
fo.cancel(i == 0);
assertTrue(fo.isCancelled());
assertTrue(fo.isDisposed());
assertTrue(fo.isDone());
}
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
fo.onNext(1);
fo.onError(new TestException("First"));
fo.onError(new TestException("Second"));
fo.onComplete();
assertTrue(fo.isCancelled());
assertTrue(fo.isDisposed());
assertTrue(fo.isDone());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
TestHelper.assertUndeliverable(errors, 1, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FutureObserverTest method onCompleteOnError.
@Test
public void onCompleteOnError() throws Exception {
fo.onComplete();
fo.onError(new TestException("One"));
try {
assertNull(fo.get(5, TimeUnit.MILLISECONDS));
} catch (ExecutionException ex) {
assertTrue(ex.toString(), ex.getCause() instanceof NoSuchElementException);
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class FutureObserverTest method onErrorCancelRace.
@Test
public void onErrorCancelRace() {
RxJavaPlugins.setErrorHandler(Functions.emptyConsumer());
try {
for (int i = 0; i < 500; i++) {
final FutureSubscriber<Integer> fo = new FutureSubscriber<Integer>();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
fo.cancel(false);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
fo.onError(ex);
}
};
TestHelper.race(r1, r2, Schedulers.single());
}
} finally {
RxJavaPlugins.reset();
}
}
Aggregations