@Override public Object apply(Long aLong) throws Exception { throw new Exception(); } });
@Override public Object apply(Long aLong) throws Exception { throw new Exception(); } });
private static boolean hasConstructorUsableByGetChecked( Class<? extends Exception> exceptionClass) { try { Exception unused = newWithCause(exceptionClass, new Exception()); return true; } catch (Exception e) { return false; } }
@Override public Publisher<Integer> apply(Long aLong) throws Exception { return Flowable.error(new Exception()); } });
@Override public ObservableSource<Integer> apply(Long aLong) throws Exception { return Observable.error(new Exception()); } });
public void testGetCasualChainLoop() { Exception cause = new Exception(); Exception exception = new Exception(cause); cause.initCause(exception); try { Throwables.getCausalChain(cause); fail("Should have throw IAE"); } catch (IllegalArgumentException expected) { assertThat(expected).hasCauseThat().isSameAs(cause); } }
@Test public void testErrorPassThru() { Exception exception = new Exception("test"); Observable<Integer> o = Observable.error(exception); Observable<Integer> dematerialize = o.dematerialize(); Observer<Integer> observer = TestHelper.mockObserver(); dematerialize.subscribe(observer); verify(observer, times(1)).onError(exception); verify(observer, times(0)).onComplete(); verify(observer, times(0)).onNext(any(Integer.class)); }
@Test public void testSkipError() { Exception e = new Exception(); Observable<String> ok = Observable.just("one"); Observable<String> error = Observable.error(e); Observable<String> skip = Observable.concat(ok, error).skip(100); Observer<String> observer = TestHelper.mockObserver(); skip.subscribe(observer); verify(observer, never()).onNext(any(String.class)); verify(observer, times(1)).onError(e); verify(observer, never()).onComplete(); }
@Test public void testDematerialize3() { Exception exception = new Exception("test"); Observable<Integer> o = Observable.error(exception); Observable<Integer> dematerialize = o.materialize().dematerialize(); Observer<Integer> observer = TestHelper.mockObserver(); dematerialize.subscribe(observer); verify(observer, times(1)).onError(exception); verify(observer, times(0)).onComplete(); verify(observer, times(0)).onNext(any(Integer.class)); }
public void testCatching_rejectionPropagatesToOutput() throws Exception { SettableFuture<String> input = SettableFuture.create(); ListenableFuture<String> transformed = catching(input, Throwable.class, constant("foo"), REJECTING_EXECUTOR); input.setException(new Exception()); try { getDone(transformed); fail(); } catch (ExecutionException expected) { assertThat(expected.getCause()).isInstanceOf(RejectedExecutionException.class); } }
@Test public void testOnErrorIntegerNotificationWhenNotEqual() { final Notification<Integer> onErrorNotification = Notification.createOnError(new Exception()); final Notification<Integer> onErrorNotification2 = Notification.createOnError(new Exception()); Assert.assertFalse(onErrorNotification.equals(onErrorNotification2)); } }
@Test public void testErrorPassThru() { Exception exception = new Exception("test"); Flowable<Integer> flowable = Flowable.error(exception); Flowable<Integer> dematerialize = flowable.dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); dematerialize.subscribe(subscriber); verify(subscriber, times(1)).onError(exception); verify(subscriber, times(0)).onComplete(); verify(subscriber, times(0)).onNext(any(Integer.class)); }
@Test public void testDematerialize3() { Exception exception = new Exception("test"); Flowable<Integer> flowable = Flowable.error(exception); Flowable<Integer> dematerialize = flowable.materialize().dematerialize(); Subscriber<Integer> subscriber = TestHelper.mockSubscriber(); dematerialize.subscribe(subscriber); verify(subscriber, times(1)).onError(exception); verify(subscriber, times(0)).onComplete(); verify(subscriber, times(0)).onNext(any(Integer.class)); }
@Test(expected = NullPointerException.class) public void testForEachWithNull() { Flowable.error(new Exception("boo")) // .forEach(null); }
@Test public void testSkipError() { Exception e = new Exception(); Flowable<String> ok = Flowable.just("one"); Flowable<String> error = Flowable.error(e); Flowable<String> skip = Flowable.concat(ok, error).skip(100); Subscriber<String> subscriber = TestHelper.mockSubscriber(); skip.subscribe(subscriber); verify(subscriber, never()).onNext(any(String.class)); verify(subscriber, times(1)).onError(e); verify(subscriber, never()).onComplete(); }
@Test(expected = NullPointerException.class) public void testForEachWithNull() { Observable.error(new Exception("boo")) // .forEach(null); }
public void testSetFailureNull() throws Exception { try { future.setException(null); fail(); } catch (NullPointerException expected) { } assertFalse(future.isDone()); assertTrue(future.setException(new Exception("failure"))); tester.testFailedFuture("failure"); }
@Test public void testOnErrorIntegerNotificationsWhenEqual() { final Exception exception = new Exception(); final Notification<Integer> onErrorNotification = Notification.createOnError(exception); final Notification<Integer> onErrorNotification2 = Notification.createOnError(exception); Assert.assertTrue(onErrorNotification.equals(onErrorNotification2)); }
@Test @Ignore("Nulls are not allowed") public void testOnErrorIntegerNotificationDoesNotEqualNullNotification() { final Notification<Integer> integerNotification = Notification.createOnError(new Exception()); final Notification<Integer> nullNotification = Notification.createOnError(null); Assert.assertFalse(integerNotification.equals(nullNotification)); }
@Test @Ignore("Nulls are not allowed") public void testOnErrorNullNotificationDoesNotEqualIntegerNotification() { final Notification<Integer> integerNotification = Notification.createOnError(new Exception()); final Notification<Integer> nullNotification = Notification.createOnError(null); Assert.assertFalse(nullNotification.equals(integerNotification)); }