public CrashDummy assertInnerError(int index, Class<? extends Throwable> clazz) { List<Throwable> cel = TestCommonHelper.compositeList(error); TestCommonHelper.assertError(cel, index, clazz); return this; }
public CrashDummy assertInnerError(int index, Class<? extends Throwable> clazz, String message) { List<Throwable> cel = TestCommonHelper.compositeList(error); TestCommonHelper.assertError(cel, index, clazz, message); return this; }
public CrashDummy assertInnerError(int index, Class<? extends Throwable> clazz, String message) { List<Throwable> cel = TestCommonHelper.compositeList(error); TestCommonHelper.assertError(cel, index, clazz, message); return this; }
public CrashDummy assertInnerError(int index, Class<? extends Throwable> clazz) { List<Throwable> cel = TestCommonHelper.compositeList(error); TestCommonHelper.assertError(cel, index, clazz); return this; }
@After public void after() { RxJavaCommonPlugins.reset(); assertFalse("" + errors, errors.isEmpty()); TestCommonHelper.assertError(errors, 0, OnErrorNotImplementedException.class); Throwable c = errors.get(0).getCause(); assertTrue("" + c, c instanceof TestException); }
@Test public void invalidDeferredRequest() { AtomicReference<Subscription> s = new AtomicReference<Subscription>(); AtomicLong r = new AtomicLong(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { SubscriptionHelper.deferredRequest(s, r, -99); TestCommonHelper.assertError(errors, 0, IllegalArgumentException.class, "n > 0 required but it was -99"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void eagerMapperThrowsDisposerThrows() { TestObserver<Integer> ts = Single.using(Functions.justCallable(Disposables.empty()), mapperThrows, disposerThrows) .test() .assertFailure(CompositeException.class); List<Throwable> ce = TestCommonHelper.compositeList(ts.errors().get(0)); TestCommonHelper.assertError(ce, 0, TestException.class, "Mapper"); TestCommonHelper.assertError(ce, 1, TestException.class, "Disposer"); }
@Test public void producedMore() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { AtomicLong requested = new AtomicLong(1); assertEquals(0, BackpressureHelper.produced(requested, 2)); TestCommonHelper.assertError(list, 0, IllegalStateException.class, "More produced than requested: -1"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void producedMoreCancel() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { AtomicLong requested = new AtomicLong(1); assertEquals(0, BackpressureHelper.producedCancel(requested, 2)); TestCommonHelper.assertError(list, 0, IllegalStateException.class, "More produced than requested: -1"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void validateNullThrows() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { SubscriptionHelper.validate(null, null); TestCommonHelper.assertError(errors, 0, NullPointerException.class, "next is null"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void invalidDeferredRequest() { SubscriptionArbiter sa = new SubscriptionArbiter(); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { sa.request(-99); TestCommonHelper.assertError(errors, 0, IllegalArgumentException.class, "n > 0 required but it was -99"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void validationNull() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { assertFalse(DisposableHelper.validate(null, null)); TestCommonHelper.assertError(list, 0, NullPointerException.class, "next is null"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void onErrorNull() { TestObserver<Integer> to = Maybe.<Integer>error(new TestException()) .flatMap(Functions.justFunction(Maybe.just(1)), Functions.justFunction((Maybe<Integer>)null), Functions.justCallable(Maybe.just(1))) .test() .assertFailure(CompositeException.class); List<Throwable> ce = TestCommonHelper.compositeList(to.errors().get(0)); TestCommonHelper.assertError(ce, 0, TestException.class); TestCommonHelper.assertError(ce, 1, NullPointerException.class); }
@Test public void badRequest() { TestSubscriber<Integer> ts = new TestSubscriber<Integer>(0L); ScalarSubscription<Integer> sc = new ScalarSubscription<Integer>(ts, 1); List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { sc.request(-99); TestCommonHelper.assertError(errors, 0, IllegalArgumentException.class, "n > 0 required but it was -99"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void errors() { TestObserver<Integer> ts = TestObserver.create(); ts.onSubscribe(Disposables.empty()); assertEquals(0, ts.errors().size()); ts.onError(new TestException()); assertEquals(1, ts.errors().size()); TestCommonHelper.assertError(ts.errors(), 0, TestException.class); }
@Test public void errors() { TestSubscriber<Integer> ts = TestSubscriber.create(); ts.onSubscribe(new BooleanSubscription()); assertEquals(0, ts.errors().size()); ts.onError(new TestException()); assertEquals(1, ts.errors().size()); TestCommonHelper.assertError(ts.errors(), 0, TestException.class); }
@Test public void negativeRequest() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); TestSubscriber<Integer> ts = TestSubscriber.create(0); TestingDeferredScalarSubscriber ds = new TestingDeferredScalarSubscriber(ts); ds.setupDownstream(); ds.downstreamRequest(-99); RxJavaCommonPlugins.reset(); TestCommonHelper.assertError(list, 0, IllegalArgumentException.class, "n > 0 required but it was -99"); }
@Test public void invalidDeferredRequest() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { new FullArbiter<Integer>(new TestSubscriber<Integer>(), null, 128).request(-99); TestCommonHelper.assertError(errors, 0, IllegalArgumentException.class, "n > 0 required but it was -99"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void boundaryOnError() { TestSubscriber<Object> to = Flowable.error(new TestException()) .window(Flowable.never()) .flatMap(Functions.<Flowable<Object>>identity(), true) .test() .assertFailure(CompositeException.class); List<Throwable> errors = TestCommonHelper.compositeList(to.errors().get(0)); TestCommonHelper.assertError(errors, 0, TestException.class); }
@Test public void boundaryOnError() { TestObserver<Object> to = Observable.error(new TestException()) .window(Observable.never()) .flatMap(Functions.<Observable<Object>>identity(), true) .test() .assertFailure(CompositeException.class); List<Throwable> errors = TestCommonHelper.compositeList(to.errors().get(0)); TestCommonHelper.assertError(errors, 0, TestException.class); }