@Test public void onSubscribeAndDisposeCrashes() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { CrashDummy cd = new CrashDummy(true, 1, false, false, true); SafeObserver<Object> so = cd.toSafe(); so.onSubscribe(cd); TestCommonHelper.assertError(list, 0, CompositeException.class); List<Throwable> ce = TestCommonHelper.compositeList(list.get(0)); TestCommonHelper.assertError(ce, 0, TestException.class, "onSubscribe()"); TestCommonHelper.assertError(ce, 1, TestException.class, "dispose()"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void utilityClass() { TestCommonHelper.checkUtilityClass(SchedulerPoolFactory.class); } }
@Override public void run() { c.decrementAndGet(); while (c.get() != 0 && !pp.hasSubscribers()) { } TestCommonHelper.race(r1, r2); } });
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; }
@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 errorConsumerEmpty() throws Exception { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { Functions.ERROR_CONSUMER.accept(new TestException()); TestCommonHelper.assertUndeliverable(errors, 0, TestException.class); assertEquals(errors.toString(), 1, errors.size()); } finally { RxJavaCommonPlugins.reset(); } } }
@Test public void requestMaxEnum() { TestCommonHelper.checkEnum(FlowableInternalHelper.RequestMax.class); } }
@Test public void timerDelayZero() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { for (int i = 0; i < 1000; i++) { Flowable.timer(0, TimeUnit.MILLISECONDS).blockingFirst(); } assertTrue(errors.toString(), errors.isEmpty()); } finally { RxJavaCommonPlugins.reset(); } }
@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); }
/** * Returns an expanded error list of the given test consumer. * @param to the test consumer instance * @return the list */ public static List<Throwable> errorList(TestObserver<?> to) { return TestCommonHelper.compositeList(to.errors().get(0)); }
@Test public void onSubscribeCrashes() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { CrashDummy cd = new CrashDummy(true, 1, false, false, false); SafeObserver<Object> so = cd.toSafe(); so.onSubscribe(cd); TestCommonHelper.assertUndeliverable(list, 0, TestException.class, "onSubscribe()"); } 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(); } }
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; }
@Test public void failureHandlingEnum() { TestCommonHelper.checkEnum(ParallelFailureHandling.class); } }
@Test public void timerDelayZero() { List<Throwable> errors = TestCommonHelper.trackPluginErrors(); try { for (int i = 0; i < 1000; i++) { Observable.timer(0, TimeUnit.MILLISECONDS).blockingFirst(); } assertTrue(errors.toString(), errors.isEmpty()); } 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); }
/** * Returns an expanded error list of the given test consumer. * @param to the test consumer instance * @return the list */ public static List<Throwable> errorList(TestSubscriber<?> to) { return compositeList(to.errors().get(0)); }
@Test public void onSubscribeCrashes() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { CrashDummy cd = new CrashDummy(true, 1, false, false, false, false); SafeSubscriber<Object> so = cd.toSafe(); so.onSubscribe(cd); TestCommonHelper.assertUndeliverable(list, 0, TestException.class, "onSubscribe()"); } finally { RxJavaCommonPlugins.reset(); } }
@Test public void onCompleteteNoSubscribeOnErrorCrash() { List<Throwable> list = TestCommonHelper.trackPluginErrors(); try { CrashDummy cd = new CrashDummy(false, 1, true, true, false, false); SafeSubscriber<Object> so = cd.toSafe(); so.onComplete(); TestCommonHelper.assertError(list, 0, CompositeException.class); List<Throwable> ce = TestCommonHelper.compositeList(list.get(0)); TestCommonHelper.assertError(ce, 0, NullPointerException.class, "Subscription not set!"); TestCommonHelper.assertError(ce, 1, TestException.class); } 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(); } }