public IOExceptionWrapper(Throwable cause) { super(cause.toString()); _cause = cause; }
@Override public String toString() { return getCause().toString(); } }
static void assertNPE(List<Throwable> list, int index) { assertTrue(list.get(index).toString(), list.get(index) instanceof NullPointerException); }
static void assertUndeliverableTestException(List<Throwable> list, int index, String message) { assertTrue(list.get(index).toString(), list.get(index).getCause() instanceof TestException); assertEquals(message, list.get(index).getCause().getMessage()); }
static void assertTestException(List<Throwable> list, int index, String message) { assertTrue(list.get(index).toString(), list.get(index) instanceof TestException); assertEquals(message, list.get(index).getMessage()); }
public static void assertError(TestSubscriber<?> ts, int index, Class<? extends Throwable> clazz) { Throwable ex = ts.errors().get(0); if (ex instanceof CompositeException) { CompositeException ce = (CompositeException) ex; List<Throwable> cel = ce.getExceptions(); assertTrue(cel.get(index).toString(), clazz.isInstance(cel.get(index))); } else { fail(ex.toString() + ": not a CompositeException"); } }
public static void assertError(TestObserver<?> to, int index, Class<? extends Throwable> clazz, String message) { Throwable ex = to.errors().get(0); if (ex instanceof CompositeException) { CompositeException ce = (CompositeException) ex; List<Throwable> cel = ce.getExceptions(); assertTrue(cel.get(index).toString(), clazz.isInstance(cel.get(index))); assertEquals(message, cel.get(index).getMessage()); } else { fail(ex.toString() + ": not a CompositeException"); } }
public static void assertError(TestSubscriber<?> ts, int index, Class<? extends Throwable> clazz, String message) { Throwable ex = ts.errors().get(0); if (ex instanceof CompositeException) { CompositeException ce = (CompositeException) ex; List<Throwable> cel = ce.getExceptions(); assertTrue(cel.get(index).toString(), clazz.isInstance(cel.get(index))); assertEquals(message, cel.get(index).getMessage()); } else { fail(ex.toString() + ": not a CompositeException"); } }
public static void assertError(TestObserver<?> to, int index, Class<? extends Throwable> clazz) { Throwable ex = to.errors().get(0); try { if (ex instanceof CompositeException) { CompositeException ce = (CompositeException) ex; List<Throwable> cel = ce.getExceptions(); assertTrue(cel.get(index).toString(), clazz.isInstance(cel.get(index))); } else { fail(ex.toString() + ": not a CompositeException"); } } catch (AssertionError e) { ex.printStackTrace(); throw e; } }
@Test public void testOnErrorNotImplementedIsThrown() { List<Throwable> errors = TestHelper.trackPluginErrors(); Observable.just(1, 2, 3).subscribe(new Consumer<Integer>() { @Override public void accept(Integer t1) { throw new RuntimeException("hello"); } }); TestHelper.assertError(errors, 0, RuntimeException.class); assertTrue(errors.get(0).toString(), errors.get(0).getMessage().contains("hello")); RxJavaPlugins.reset(); }
@Test public void concatDelayErrorFlowableError() { TestSubscriber<Integer> ts = TestSubscriber.create(); Flowable.concatDelayError( withError(Flowable.just(withError(Flowable.just(1)), withError(Flowable.just(2))))) .subscribe(ts); ts.assertValues(1, 2); ts.assertError(CompositeException.class); ts.assertNotComplete(); CompositeException ce = (CompositeException)ts.errors().get(0); List<Throwable> cex = ce.getExceptions(); assertEquals(3, cex.size()); assertTrue(cex.get(0).toString(), cex.get(0) instanceof TestException); assertTrue(cex.get(1).toString(), cex.get(1) instanceof TestException); assertTrue(cex.get(2).toString(), cex.get(2) instanceof TestException); }
@Override public void onSubscribe(Subscription s) { @SuppressWarnings("unchecked") QueueSubscription<Integer> qs = (QueueSubscription<Integer>)s; qs.requestFusion(QueueFuseable.ANY); try { assertEquals(1, qs.poll().intValue()); } catch (Throwable ex) { fail(ex.toString()); } qs.clear(); try { assertNull(qs.poll()); } catch (Throwable ex) { fail(ex.toString()); } }
@Override public void onSubscribe(Disposable d) { @SuppressWarnings("unchecked") QueueDisposable<Integer> qd = (QueueDisposable<Integer>)d; qd.requestFusion(QueueFuseable.ANY); try { assertEquals(1, qd.poll().intValue()); } catch (Throwable ex) { fail(ex.toString()); } qd.clear(); try { assertNull(qd.poll()); } catch (Throwable ex) { fail(ex.toString()); } }
@SuppressWarnings("unchecked") @Test public void arrayDelayError() { Publisher<Integer>[] sources = new Publisher[] { Flowable.just(1), null, Flowable.range(2, 3), Flowable.error(new TestException()), Flowable.empty() }; TestSubscriber<Integer> ts = Flowable.concatArrayDelayError(sources).test(); ts.assertFailure(CompositeException.class, 1, 2, 3, 4); CompositeException composite = (CompositeException)ts.errors().get(0); List<Throwable> list = composite.getExceptions(); assertTrue(list.get(0).toString(), list.get(0) instanceof NullPointerException); assertTrue(list.get(1).toString(), list.get(1) instanceof TestException); }
@Test public void doubleError() { List<Throwable> errors = TestHelper.trackPluginErrors(); try { new ParallelInvalid() .runOn(ImmediateThinScheduler.INSTANCE) .sequential() .test() .assertFailure(TestException.class); assertFalse(errors.isEmpty()); for (Throwable ex : errors) { assertTrue(ex.toString(), ex.getCause() instanceof TestException); } } finally { RxJavaPlugins.reset(); } }
@Test public void doubleError() { List<Throwable> errors = TestHelper.trackPluginErrors(); try { new ParallelInvalid() .doOnNext(Functions.emptyConsumer()) .sequential() .test() .assertFailure(TestException.class); assertFalse(errors.isEmpty()); for (Throwable ex : errors) { assertTrue(ex.toString(), ex.getCause() instanceof TestException); } } finally { RxJavaPlugins.reset(); } }
@Test public void valueOfOnErrorIsNull() { Notification<Integer> notification = Notification.createOnError(new TestException()); assertNull(notification.getValue()); assertTrue(notification.getError().toString(), notification.getError() instanceof TestException); }
@Test public void offer() { PublishProcessor<Integer> pp = PublishProcessor.create(); TestSubscriber<Integer> ts = pp.test(0); assertFalse(pp.offer(1)); ts.request(1); assertTrue(pp.offer(1)); assertFalse(pp.offer(2)); ts.cancel(); assertTrue(pp.offer(2)); ts = pp.test(0); assertTrue(pp.offer(null)); ts.assertFailure(NullPointerException.class); assertTrue(pp.hasThrowable()); assertTrue(pp.getThrowable().toString(), pp.getThrowable() instanceof NullPointerException); }
@Test public void offer() { BehaviorProcessor<Integer> pp = BehaviorProcessor.create(); TestSubscriber<Integer> ts = pp.test(0); assertFalse(pp.offer(1)); ts.request(1); assertTrue(pp.offer(1)); assertFalse(pp.offer(2)); ts.cancel(); assertTrue(pp.offer(2)); ts = pp.test(1); assertTrue(pp.offer(null)); ts.assertFailure(NullPointerException.class, 2); assertTrue(pp.hasThrowable()); assertTrue(pp.getThrowable().toString(), pp.getThrowable() instanceof NullPointerException); }