diff --git a/src/test/java/io/reactivex/RxJavaTest.java b/src/test/java/io/reactivex/RxJavaTest.java new file mode 100644 index 0000000000..b0e2fc2367 --- /dev/null +++ b/src/test/java/io/reactivex/RxJavaTest.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.reactivex; + +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.Timeout; + +import java.util.concurrent.TimeUnit; + +public abstract class RxJavaTest { + @Rule + public Timeout globalTimeout = new Timeout(5, TimeUnit.MINUTES); + + /** + * Announce creates a log print preventing Travis CI from killing the build. + */ + @Test + @Ignore + public final void announce() { + } +} diff --git a/src/test/java/io/reactivex/completable/CompletableRetryTest.java b/src/test/java/io/reactivex/completable/CompletableRetryTest.java index 23619078bd..b450e3229f 100644 --- a/src/test/java/io/reactivex/completable/CompletableRetryTest.java +++ b/src/test/java/io/reactivex/completable/CompletableRetryTest.java @@ -14,6 +14,7 @@ package io.reactivex.completable; import io.reactivex.Completable; +import io.reactivex.RxJavaTest; import io.reactivex.functions.Action; import io.reactivex.functions.Predicate; import io.reactivex.internal.functions.Functions; @@ -22,7 +23,7 @@ import static org.junit.Assert.assertEquals; -public class CompletableRetryTest { +public class CompletableRetryTest extends RxJavaTest { @Test public void retryTimesPredicateWithMatchingPredicate() { final AtomicInteger atomicInteger = new AtomicInteger(3); diff --git a/src/test/java/io/reactivex/completable/CompletableTest.java b/src/test/java/io/reactivex/completable/CompletableTest.java index e78638de12..d4549b8291 100644 --- a/src/test/java/io/reactivex/completable/CompletableTest.java +++ b/src/test/java/io/reactivex/completable/CompletableTest.java @@ -44,7 +44,7 @@ /** * Test Completable methods and operators. */ -public class CompletableTest { +public class CompletableTest extends RxJavaTest { /** * Iterable that returns an Iterator that throws in its hasNext method. */ @@ -148,7 +148,7 @@ public void assertSubscriptions(int n) { /** An error Completable object. */ final ErrorCompletable error = new ErrorCompletable(); - @Test(timeout = 5000) + @Test public void complete() { Completable c = Completable.complete(); @@ -160,14 +160,14 @@ public void concatNull() { Completable.concatArray((Completable[])null); } - @Test(timeout = 5000) + @Test public void concatEmpty() { Completable c = Completable.concatArray(); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void concatSingleSource() { Completable c = Completable.concatArray(normal.completable); @@ -176,14 +176,14 @@ public void concatSingleSource() { normal.assertSubscriptions(1); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void concatSingleSourceThrows() { Completable c = Completable.concatArray(error.completable); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void concatMultipleSources() { Completable c = Completable.concatArray(normal.completable, normal.completable, normal.completable); @@ -192,21 +192,21 @@ public void concatMultipleSources() { normal.assertSubscriptions(3); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void concatMultipleOneThrows() { Completable c = Completable.concatArray(normal.completable, error.completable, normal.completable); c.blockingAwait(); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void concatMultipleOneIsNull() { Completable c = Completable.concatArray(normal.completable, null); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void concatIterableEmpty() { Completable c = Completable.concat(Collections.emptyList()); @@ -218,7 +218,7 @@ public void concatIterableNull() { Completable.concat((Iterable)null); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void concatIterableIteratorNull() { Completable c = Completable.concat(new Iterable() { @Override @@ -230,14 +230,14 @@ public Iterator iterator() { c.blockingAwait(); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void concatIterableWithNull() { Completable c = Completable.concat(Arrays.asList(normal.completable, (Completable)null)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void concatIterableSingle() { Completable c = Completable.concat(Collections.singleton(normal.completable)); @@ -246,7 +246,7 @@ public void concatIterableSingle() { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void concatIterableMany() { Completable c = Completable.concat(Arrays.asList(normal.completable, normal.completable, normal.completable)); @@ -255,14 +255,14 @@ public void concatIterableMany() { normal.assertSubscriptions(3); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void concatIterableOneThrows() { Completable c = Completable.concat(Collections.singleton(error.completable)); c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void concatIterableManyOneThrows() { Completable c = Completable.concat(Arrays.asList(normal.completable, error.completable)); @@ -295,14 +295,14 @@ public void concatIterableIteratorNextThrows() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void concatObservableEmpty() { Completable c = Completable.concat(Flowable.empty()); c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void concatObservableError() { Completable c = Completable.concat(Flowable.error(new Supplier() { @Override @@ -314,7 +314,7 @@ public Throwable get() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void concatObservableSingle() { Completable c = Completable.concat(Flowable.just(normal.completable)); @@ -323,14 +323,14 @@ public void concatObservableSingle() { normal.assertSubscriptions(1); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void concatObservableSingleThrows() { Completable c = Completable.concat(Flowable.just(error.completable)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void concatObservableMany() { Completable c = Completable.concat(Flowable.just(normal.completable).repeat(3)); @@ -339,14 +339,14 @@ public void concatObservableMany() { normal.assertSubscriptions(3); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void concatObservableManyOneThrows() { Completable c = Completable.concat(Flowable.just(normal.completable, error.completable)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void concatObservablePrefetch() { final List requested = new ArrayList(); Flowable cs = Flowable @@ -371,7 +371,7 @@ public void createNull() { Completable.unsafeCreate(null); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void createOnSubscribeThrowsNPE() { Completable c = Completable.unsafeCreate(new CompletableSource() { @Override @@ -381,7 +381,7 @@ public void createOnSubscribeThrowsNPE() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void createOnSubscribeThrowsRuntimeException() { List errors = TestHelper.trackPluginErrors(); try { @@ -407,7 +407,7 @@ public void subscribe(CompletableObserver observer) { } } - @Test(timeout = 5000) + @Test public void defer() { Completable c = Completable.defer(new Supplier() { @Override @@ -428,7 +428,7 @@ public void deferNull() { Completable.defer(null); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void deferReturnsNull() { Completable c = Completable.defer(new Supplier() { @Override @@ -440,7 +440,7 @@ public Completable get() { c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void deferFunctionThrows() { Completable c = Completable.defer(new Supplier() { @Override @@ -450,7 +450,7 @@ public void deferFunctionThrows() { c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void deferErrorSource() { Completable c = Completable.defer(new Supplier() { @Override @@ -467,7 +467,7 @@ public void errorSupplierNull() { Completable.error((Supplier)null); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void errorSupplierNormal() { Completable c = Completable.error(new Supplier() { @Override @@ -479,7 +479,7 @@ public Throwable get() { c.blockingAwait(); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void errorSupplierReturnsNull() { Completable c = Completable.error(new Supplier() { @Override @@ -491,7 +491,7 @@ public Throwable get() { c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void errorSupplierThrows() { Completable c = Completable.error(new Supplier() { @Override @@ -506,7 +506,7 @@ public void errorNull() { Completable.error((Throwable)null); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void errorNormal() { Completable c = Completable.error(new TestException()); @@ -518,7 +518,7 @@ public void fromCallableNull() { Completable.fromCallable(null); } - @Test(timeout = 5000) + @Test public void fromCallableNormal() { final AtomicInteger calls = new AtomicInteger(); @@ -534,7 +534,7 @@ public Object call() throws Exception { Assert.assertEquals(1, calls.get()); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void fromCallableThrows() { Completable c = Completable.fromCallable(new Callable() { @Override @@ -549,14 +549,14 @@ public void fromFlowableNull() { Completable.fromPublisher(null); } - @Test(timeout = 5000) + @Test public void fromFlowableEmpty() { Completable c = Completable.fromPublisher(Flowable.empty()); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void fromFlowableSome() { for (int n = 1; n < 10000; n *= 10) { Completable c = Completable.fromPublisher(Flowable.range(1, n)); @@ -565,7 +565,7 @@ public void fromFlowableSome() { } } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void fromFlowableError() { Completable c = Completable.fromPublisher(Flowable.error(new Supplier() { @Override @@ -582,14 +582,14 @@ public void fromObservableNull() { Completable.fromObservable(null); } - @Test(timeout = 5000) + @Test public void fromObservableEmpty() { Completable c = Completable.fromObservable(Observable.empty()); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void fromObservableSome() { for (int n = 1; n < 10000; n *= 10) { Completable c = Completable.fromObservable(Observable.range(1, n)); @@ -598,7 +598,7 @@ public void fromObservableSome() { } } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void fromObservableError() { Completable c = Completable.fromObservable(Observable.error(new Supplier() { @Override @@ -615,7 +615,7 @@ public void fromActionNull() { Completable.fromAction(null); } - @Test(timeout = 5000) + @Test public void fromActionNormal() { final AtomicInteger calls = new AtomicInteger(); @@ -631,7 +631,7 @@ public void run() { Assert.assertEquals(1, calls.get()); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void fromActionThrows() { Completable c = Completable.fromAction(new Action() { @Override @@ -646,14 +646,14 @@ public void fromSingleNull() { Completable.fromSingle(null); } - @Test(timeout = 5000) + @Test public void fromSingleNormal() { Completable c = Completable.fromSingle(Single.just(1)); c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void fromSingleThrows() { Completable c = Completable.fromSingle(Single.error(new Supplier() { @Override @@ -670,14 +670,14 @@ public void mergeNull() { Completable.mergeArray((Completable[])null); } - @Test(timeout = 5000) + @Test public void mergeEmpty() { Completable c = Completable.mergeArray(); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeSingleSource() { Completable c = Completable.mergeArray(normal.completable); @@ -686,14 +686,14 @@ public void mergeSingleSource() { normal.assertSubscriptions(1); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeSingleSourceThrows() { Completable c = Completable.mergeArray(error.completable); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeMultipleSources() { Completable c = Completable.mergeArray(normal.completable, normal.completable, normal.completable); @@ -702,21 +702,21 @@ public void mergeMultipleSources() { normal.assertSubscriptions(3); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeMultipleOneThrows() { Completable c = Completable.mergeArray(normal.completable, error.completable, normal.completable); c.blockingAwait(); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void mergeMultipleOneIsNull() { Completable c = Completable.mergeArray(normal.completable, null); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeIterableEmpty() { Completable c = Completable.merge(Collections.emptyList()); @@ -728,7 +728,7 @@ public void mergeIterableNull() { Completable.merge((Iterable)null); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void mergeIterableIteratorNull() { Completable c = Completable.merge(new Iterable() { @Override @@ -740,14 +740,14 @@ public Iterator iterator() { c.blockingAwait(); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void mergeIterableWithNull() { Completable c = Completable.merge(Arrays.asList(normal.completable, (Completable)null)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeIterableSingle() { Completable c = Completable.merge(Collections.singleton(normal.completable)); @@ -756,7 +756,7 @@ public void mergeIterableSingle() { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void mergeIterableMany() { Completable c = Completable.merge(Arrays.asList(normal.completable, normal.completable, normal.completable)); @@ -765,14 +765,14 @@ public void mergeIterableMany() { normal.assertSubscriptions(3); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeIterableOneThrows() { Completable c = Completable.merge(Collections.singleton(error.completable)); c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeIterableManyOneThrows() { Completable c = Completable.merge(Arrays.asList(normal.completable, error.completable)); @@ -805,14 +805,14 @@ public void mergeIterableIteratorNextThrows() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeObservableEmpty() { Completable c = Completable.merge(Flowable.empty()); c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeObservableError() { Completable c = Completable.merge(Flowable.error(new Supplier() { @Override @@ -824,7 +824,7 @@ public Throwable get() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeObservableSingle() { Completable c = Completable.merge(Flowable.just(normal.completable)); @@ -833,14 +833,14 @@ public void mergeObservableSingle() { normal.assertSubscriptions(1); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeObservableSingleThrows() { Completable c = Completable.merge(Flowable.just(error.completable)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeObservableMany() { Completable c = Completable.merge(Flowable.just(normal.completable).repeat(3)); @@ -849,14 +849,14 @@ public void mergeObservableMany() { normal.assertSubscriptions(3); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeObservableManyOneThrows() { Completable c = Completable.merge(Flowable.just(normal.completable, error.completable)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeObservableMaxConcurrent() { final List requested = new ArrayList(); Flowable cs = Flowable @@ -882,14 +882,14 @@ public void mergeDelayErrorNull() { Completable.mergeArrayDelayError((Completable[])null); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorEmpty() { Completable c = Completable.mergeArrayDelayError(); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorSingleSource() { Completable c = Completable.mergeArrayDelayError(normal.completable); @@ -898,14 +898,14 @@ public void mergeDelayErrorSingleSource() { normal.assertSubscriptions(1); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeDelayErrorSingleSourceThrows() { Completable c = Completable.mergeArrayDelayError(error.completable); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorMultipleSources() { Completable c = Completable.mergeArrayDelayError(normal.completable, normal.completable, normal.completable); @@ -914,7 +914,7 @@ public void mergeDelayErrorMultipleSources() { normal.assertSubscriptions(3); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorMultipleOneThrows() { Completable c = Completable.mergeArrayDelayError(normal.completable, error.completable, normal.completable); @@ -925,14 +925,14 @@ public void mergeDelayErrorMultipleOneThrows() { } } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void mergeDelayErrorMultipleOneIsNull() { Completable c = Completable.mergeArrayDelayError(normal.completable, null); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorIterableEmpty() { Completable c = Completable.mergeDelayError(Collections.emptyList()); @@ -944,7 +944,7 @@ public void mergeDelayErrorIterableNull() { Completable.mergeDelayError((Iterable)null); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void mergeDelayErrorIterableIteratorNull() { Completable c = Completable.mergeDelayError(new Iterable() { @Override @@ -956,14 +956,14 @@ public Iterator iterator() { c.blockingAwait(); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void mergeDelayErrorIterableWithNull() { Completable c = Completable.mergeDelayError(Arrays.asList(normal.completable, (Completable)null)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorIterableSingle() { Completable c = Completable.mergeDelayError(Collections.singleton(normal.completable)); @@ -972,7 +972,7 @@ public void mergeDelayErrorIterableSingle() { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorIterableMany() { Completable c = Completable.mergeDelayError(Arrays.asList(normal.completable, normal.completable, normal.completable)); @@ -981,14 +981,14 @@ public void mergeDelayErrorIterableMany() { normal.assertSubscriptions(3); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeDelayErrorIterableOneThrows() { Completable c = Completable.mergeDelayError(Collections.singleton(error.completable)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorIterableManyOneThrows() { Completable c = Completable.mergeDelayError(Arrays.asList(normal.completable, error.completable, normal.completable)); @@ -1025,14 +1025,14 @@ public void mergeDelayErrorIterableIteratorNextThrows() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorObservableEmpty() { Completable c = Completable.mergeDelayError(Flowable.empty()); c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeDelayErrorObservableError() { Completable c = Completable.mergeDelayError(Flowable.error(new Supplier() { @Override @@ -1044,7 +1044,7 @@ public Throwable get() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorObservableSingle() { Completable c = Completable.mergeDelayError(Flowable.just(normal.completable)); @@ -1053,14 +1053,14 @@ public void mergeDelayErrorObservableSingle() { normal.assertSubscriptions(1); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeDelayErrorObservableSingleThrows() { Completable c = Completable.mergeDelayError(Flowable.just(error.completable)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorObservableMany() { Completable c = Completable.mergeDelayError(Flowable.just(normal.completable).repeat(3)); @@ -1069,14 +1069,14 @@ public void mergeDelayErrorObservableMany() { normal.assertSubscriptions(3); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void mergeDelayErrorObservableManyOneThrows() { Completable c = Completable.mergeDelayError(Flowable.just(normal.completable, error.completable)); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void mergeDelayErrorObservableMaxConcurrent() { final List requested = new ArrayList(); Flowable cs = Flowable @@ -1097,7 +1097,7 @@ public void accept(long v) { Assert.assertEquals(Arrays.asList(5L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), requested); } - @Test(timeout = 5000) + @Test public void never() { final AtomicBoolean onSubscribeCalled = new AtomicBoolean(); final AtomicInteger calls = new AtomicInteger(); @@ -1122,21 +1122,21 @@ public void onComplete() { Assert.assertEquals("There were calls to onXXX methods", 0, calls.get()); } - @Test(timeout = 1500) + @Test public void timer() { Completable c = Completable.timer(500, TimeUnit.MILLISECONDS); c.blockingAwait(); } - @Test(timeout = 1500) + @Test public void timerNewThread() { Completable c = Completable.timer(500, TimeUnit.MILLISECONDS, Schedulers.newThread()); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void timerTestScheduler() { TestScheduler scheduler = new TestScheduler(); @@ -1170,7 +1170,7 @@ public void onError(Throwable e) { Assert.assertEquals(1, calls.get()); } - @Test(timeout = 2000) + @Test public void timerCancel() throws InterruptedException { Completable c = Completable.timer(250, TimeUnit.MILLISECONDS); @@ -1213,7 +1213,7 @@ public void timerSchedulerNull() { Completable.timer(1, TimeUnit.SECONDS, null); } - @Test(timeout = 5000) + @Test public void usingNormalEager() { final AtomicInteger dispose = new AtomicInteger(); @@ -1259,7 +1259,7 @@ public void onComplete() { Assert.assertNull(error.get()); } - @Test(timeout = 5000) + @Test public void usingNormalLazy() { final AtomicInteger dispose = new AtomicInteger(); @@ -1305,7 +1305,7 @@ public void onComplete() { Assert.assertNull(error.get()); } - @Test(timeout = 5000) + @Test public void usingErrorEager() { final AtomicInteger dispose = new AtomicInteger(); @@ -1351,7 +1351,7 @@ public void onComplete() { Assert.assertFalse(complete.get()); } - @Test(timeout = 5000) + @Test public void usingErrorLazy() { final AtomicInteger dispose = new AtomicInteger(); @@ -1517,7 +1517,7 @@ public Completable apply(Object v) { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void composeNormal() { Completable c = error.completable.compose(new CompletableTransformer() { @Override @@ -1534,7 +1534,7 @@ public void composeNull() { error.completable.compose(null); } - @Test(timeout = 5000) + @Test public void concatWithNormal() { Completable c = normal.completable.concatWith(normal.completable); @@ -1543,7 +1543,7 @@ public void concatWithNormal() { normal.assertSubscriptions(2); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void concatWithError() { Completable c = normal.completable.concatWith(error.completable); @@ -1565,7 +1565,7 @@ public void delaySchedulerNull() { normal.completable.delay(1, TimeUnit.SECONDS, null); } - @Test(timeout = 5000) + @Test public void delayNormal() throws InterruptedException { Completable c = normal.completable.delay(250, TimeUnit.MILLISECONDS); @@ -1604,7 +1604,7 @@ public void onComplete() { Assert.assertNull(error.get()); } - @Test(timeout = 5000) + @Test public void delayErrorImmediately() throws InterruptedException { final TestScheduler scheduler = new TestScheduler(); final Completable c = error.completable.delay(250, TimeUnit.MILLISECONDS, scheduler); @@ -1639,7 +1639,7 @@ public void onComplete() { Assert.assertFalse("Already done", done.get()); } - @Test(timeout = 5000) + @Test public void delayErrorToo() throws InterruptedException { Completable c = error.completable.delay(250, TimeUnit.MILLISECONDS, Schedulers.computation(), true); @@ -1674,7 +1674,7 @@ public void onComplete() { Assert.assertTrue(error.get() instanceof TestException); } - @Test(timeout = 5000) + @Test public void doOnCompleteNormal() { final AtomicInteger calls = new AtomicInteger(); @@ -1690,7 +1690,7 @@ public void run() { Assert.assertEquals(1, calls.get()); } - @Test(timeout = 5000) + @Test public void doOnCompleteError() { final AtomicInteger calls = new AtomicInteger(); @@ -1716,7 +1716,7 @@ public void doOnCompleteNull() { normal.completable.doOnComplete(null); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void doOnCompleteThrows() { Completable c = normal.completable.doOnComplete(new Action() { @Override @@ -1726,7 +1726,7 @@ public void doOnCompleteThrows() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void doOnDisposeNormalDoesntCall() { final AtomicInteger calls = new AtomicInteger(); @@ -1742,7 +1742,7 @@ public void run() { Assert.assertEquals(0, calls.get()); } - @Test(timeout = 5000) + @Test public void doOnDisposeErrorDoesntCall() { final AtomicInteger calls = new AtomicInteger(); @@ -1762,7 +1762,7 @@ public void run() { Assert.assertEquals(0, calls.get()); } - @Test(timeout = 5000) + @Test public void doOnDisposeChildCancels() { final AtomicInteger calls = new AtomicInteger(); @@ -1798,7 +1798,7 @@ public void doOnDisposeNull() { normal.completable.doOnDispose(null); } - @Test(timeout = 5000) + @Test public void doOnDisposeThrows() { List errors = TestHelper.trackPluginErrors(); try { @@ -1830,7 +1830,7 @@ public void onComplete() { } } - @Test(timeout = 5000) + @Test public void doOnErrorNoError() { final AtomicReference error = new AtomicReference(); @@ -1846,7 +1846,7 @@ public void accept(Throwable e) { Assert.assertNull(error.get()); } - @Test(timeout = 5000) + @Test public void doOnErrorHasError() { final AtomicReference err = new AtomicReference(); @@ -1872,7 +1872,7 @@ public void doOnErrorNull() { normal.completable.doOnError(null); } - @Test(timeout = 5000) + @Test public void doOnErrorThrows() { Completable c = error.completable.doOnError(new Consumer() { @Override @@ -1889,7 +1889,7 @@ public void doOnErrorThrows() { } } - @Test(timeout = 5000) + @Test public void doOnSubscribeNormal() { final AtomicInteger calls = new AtomicInteger(); @@ -1922,7 +1922,7 @@ public void doOnSubscribeThrows() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void doOnTerminateNormal() { final AtomicInteger calls = new AtomicInteger(); @@ -1938,7 +1938,7 @@ public void run() { Assert.assertEquals(1, calls.get()); } - @Test(timeout = 5000) + @Test public void doOnTerminateError() { final AtomicInteger calls = new AtomicInteger(); @@ -1964,7 +1964,7 @@ public void liftNull() { normal.completable.lift(null); } - @Test(timeout = 5000, expected = NullPointerException.class) + @Test(expected = NullPointerException.class) public void liftReturnsNull() { Completable c = normal.completable.lift(new CompletableOperator() { @Override @@ -2000,14 +2000,14 @@ public void onSubscribe(Disposable d) { } } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void liftOnCompleteError() { Completable c = normal.completable.lift(new CompletableOperatorSwap()); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void liftOnErrorComplete() { Completable c = error.completable.lift(new CompletableOperatorSwap()); @@ -2019,7 +2019,7 @@ public void mergeWithNull() { normal.completable.mergeWith(null); } - @Test(timeout = 5000) + @Test public void mergeWithNormal() { Completable c = normal.completable.mergeWith(normal.completable); @@ -2033,7 +2033,7 @@ public void observeOnNull() { normal.completable.observeOn(null); } - @Test(timeout = 5000) + @Test public void observeOnNormal() throws InterruptedException { final AtomicReference name = new AtomicReference(); final AtomicReference err = new AtomicReference(); @@ -2066,7 +2066,7 @@ public void onError(Throwable e) { Assert.assertTrue(name.get().startsWith("RxComputation")); } - @Test(timeout = 5000) + @Test public void observeOnError() throws InterruptedException { final AtomicReference name = new AtomicReference(); final AtomicReference err = new AtomicReference(); @@ -2100,14 +2100,14 @@ public void onError(Throwable e) { Assert.assertTrue(name.get().startsWith("RxComputation")); } - @Test(timeout = 5000) + @Test public void onErrorComplete() { Completable c = error.completable.onErrorComplete(); c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void onErrorCompleteFalse() { Completable c = error.completable.onErrorComplete(new Predicate() { @Override @@ -2129,7 +2129,7 @@ public void onErrorResumeNextNull() { error.completable.onErrorResumeNext(null); } - @Test(timeout = 5000) + @Test public void onErrorResumeNextFunctionReturnsNull() { Completable c = error.completable.onErrorResumeNext(new Function() { @Override @@ -2149,7 +2149,7 @@ public Completable apply(Throwable e) { } } - @Test(timeout = 5000) + @Test public void onErrorResumeNextFunctionThrows() { Completable c = error.completable.onErrorResumeNext(new Function() { @Override @@ -2168,7 +2168,7 @@ public void onErrorResumeNextFunctionThrows() { } } - @Test(timeout = 5000) + @Test public void onErrorResumeNextNormal() { Completable c = error.completable.onErrorResumeNext(new Function() { @Override @@ -2180,7 +2180,7 @@ public Completable apply(Throwable v) { c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void onErrorResumeNextError() { Completable c = error.completable.onErrorResumeNext(new Function() { @Override @@ -2192,7 +2192,7 @@ public Completable apply(Throwable v) { c.blockingAwait(); } - @Test(timeout = 2000) + @Test public void repeatNormal() { final AtomicReference err = new AtomicReference(); final AtomicInteger calls = new AtomicInteger(); @@ -2232,14 +2232,14 @@ public void onComplete() { Assert.assertNull(err.get()); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void repeatError() { Completable c = error.completable.repeat(); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void repeat5Times() { final AtomicInteger calls = new AtomicInteger(); @@ -2256,7 +2256,7 @@ public Object call() throws Exception { Assert.assertEquals(5, calls.get()); } - @Test(timeout = 5000) + @Test public void repeat1Time() { final AtomicInteger calls = new AtomicInteger(); @@ -2273,7 +2273,7 @@ public Object call() throws Exception { Assert.assertEquals(1, calls.get()); } - @Test(timeout = 5000) + @Test public void repeat0Time() { final AtomicInteger calls = new AtomicInteger(); @@ -2290,7 +2290,7 @@ public Object call() throws Exception { Assert.assertEquals(0, calls.get()); } - @Test(timeout = 5000) + @Test public void repeatUntilNormal() { final AtomicInteger calls = new AtomicInteger(); final AtomicInteger times = new AtomicInteger(5); @@ -2323,7 +2323,7 @@ public void repeatWhenNull() { normal.completable.repeatWhen(null); } - @Test(timeout = 5000) + @Test public void retryNormal() { Completable c = normal.completable.retry(); @@ -2332,7 +2332,7 @@ public void retryNormal() { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void retry5Times() { final AtomicInteger calls = new AtomicInteger(5); Completable c = Completable.fromAction(new Action() { @@ -2347,7 +2347,7 @@ public void run() { c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void retryBiPredicate5Times() { Completable c = error.completable.retry(new BiPredicate() { @Override @@ -2359,14 +2359,14 @@ public boolean test(Integer n, Throwable e) { c.blockingAwait(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void retryTimes5Error() { Completable c = error.completable.retry(5); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void retryTimes5Normal() { final AtomicInteger calls = new AtomicInteger(); @@ -2389,7 +2389,7 @@ public void retryNegativeTimes() { normal.completable.retry(-1); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void retryPredicateError() { Completable c = error.completable.retry(new Predicate() { @Override @@ -2406,7 +2406,7 @@ public void retryPredicateNull() { error.completable.retry((Predicate)null); } - @Test(timeout = 5000) + @Test public void retryPredicate5Times() { final AtomicInteger calls = new AtomicInteger(5); @@ -2427,7 +2427,7 @@ public boolean test(Throwable e) { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void retryWhen5Times() { final AtomicInteger calls = new AtomicInteger(5); @@ -2449,7 +2449,7 @@ public Publisher apply(Flowable f) { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void subscribe() throws InterruptedException { final AtomicBoolean complete = new AtomicBoolean(); @@ -2473,7 +2473,7 @@ public void run() { assertTrue(d.isDisposed()); } - @Test(timeout = 5000) + @Test public void subscribeDispose() throws InterruptedException { final AtomicBoolean complete = new AtomicBoolean(); @@ -2497,7 +2497,7 @@ public void run() { Assert.assertFalse("Completed", complete.get()); } - @Test(timeout = 5000) + @Test public void subscribeTwoCallbacksNormal() { final AtomicReference err = new AtomicReference(); final AtomicBoolean complete = new AtomicBoolean(); @@ -2517,7 +2517,7 @@ public void accept(Throwable e) { Assert.assertTrue("Not completed", complete.get()); } - @Test(timeout = 5000) + @Test public void subscribeTwoCallbacksError() { final AtomicReference err = new AtomicReference(); final AtomicBoolean complete = new AtomicBoolean(); @@ -2553,7 +2553,7 @@ public void run() { } }, null); } - @Test(timeout = 5000) + @Test public void subscribeTwoCallbacksCompleteThrows() { List errors = TestHelper.trackPluginErrors(); try { @@ -2575,7 +2575,7 @@ public void accept(Throwable e) { } } - @Test(timeout = 5000) + @Test public void subscribeTwoCallbacksOnErrorThrows() { List errors = TestHelper.trackPluginErrors(); try { @@ -2593,7 +2593,7 @@ public void run() { } } } - @Test(timeout = 5000) + @Test public void subscribeObserverNormal() { TestObserver to = new TestObserver(); @@ -2604,7 +2604,7 @@ public void subscribeObserverNormal() { to.assertNoErrors(); } - @Test(timeout = 5000) + @Test public void subscribeObserverError() { TestObserver to = new TestObserver(); @@ -2615,7 +2615,7 @@ public void subscribeObserverError() { to.assertError(TestException.class); } - @Test(timeout = 5000) + @Test public void subscribeActionNormal() { final AtomicBoolean run = new AtomicBoolean(); @@ -2629,7 +2629,7 @@ public void run() { Assert.assertTrue("Not completed", run.get()); } - @Test(timeout = 5000) + @Test public void subscribeActionError() { List errors = TestHelper.trackPluginErrors(); try { @@ -2670,7 +2670,7 @@ public void subscribeCompletableSubscriberNull() { normal.completable.subscribe((CompletableObserver)null); } - @Test(timeout = 5000) + @Test public void subscribeSubscriberNormal() { TestSubscriber ts = new TestSubscriber(); @@ -2681,7 +2681,7 @@ public void subscribeSubscriberNormal() { ts.assertNoErrors(); } - @Test(timeout = 5000) + @Test public void subscribeSubscriberError() { TestSubscriber ts = new TestSubscriber(); @@ -2697,7 +2697,7 @@ public void subscribeOnNull() { normal.completable.subscribeOn(null); } - @Test(timeout = 5000) + @Test public void subscribeOnNormal() { final AtomicReference name = new AtomicReference(); @@ -2714,7 +2714,7 @@ public void subscribe(CompletableObserver observer) { Assert.assertTrue(name.get().startsWith("RxComputation")); } - @Test(timeout = 5000) + @Test public void subscribeOnError() { final AtomicReference name = new AtomicReference(); @@ -2736,7 +2736,7 @@ public void subscribe(CompletableObserver observer) { Assert.assertTrue(name.get().startsWith("RxComputation")); } - @Test(timeout = 5000) + @Test public void timeoutSwitchNormal() { Completable c = Completable.never().timeout(100, TimeUnit.MILLISECONDS, normal.completable); @@ -2745,7 +2745,7 @@ public void timeoutSwitchNormal() { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void timeoutTimerCancelled() throws InterruptedException { Completable c = Completable.fromCallable(new Callable() { @Override @@ -2777,7 +2777,7 @@ public void timeoutOtherNull() { normal.completable.timeout(1, TimeUnit.SECONDS, (Completable)null); } - @Test(timeout = 5000) + @Test public void toNormal() { normal.completable .to(new CompletableConverter>() { @@ -2791,7 +2791,7 @@ public Flowable apply(Completable c) { .assertNoValues(); } - @Test(timeout = 5000) + @Test public void asNormal() { normal.completable .to(new CompletableConverter>() { @@ -2822,27 +2822,27 @@ public void toNull() { normal.completable.to(null); } - @Test(timeout = 5000) + @Test public void toFlowableNormal() { normal.completable.toFlowable().blockingForEach(Functions.emptyConsumer()); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void toFlowableError() { error.completable.toFlowable().blockingForEach(Functions.emptyConsumer()); } - @Test(timeout = 5000) + @Test public void toObservableNormal() { normal.completable.toObservable().blockingForEach(Functions.emptyConsumer()); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void toObservableError() { error.completable.toObservable().blockingForEach(Functions.emptyConsumer()); } - @Test(timeout = 5000) + @Test public void toSingleSupplierNormal() { Assert.assertEquals(1, normal.completable.toSingle(new Supplier() { @Override @@ -2852,7 +2852,7 @@ public Object get() { }).blockingGet()); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void toSingleSupplierError() { error.completable.toSingle(new Supplier() { @Override @@ -2885,12 +2885,12 @@ public void toSingleSupplierThrows() { }).blockingGet(); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void toSingleDefaultError() { error.completable.toSingleDefault(1).blockingGet(); } - @Test(timeout = 5000) + @Test public void toSingleDefaultNormal() { Assert.assertEquals((Integer)1, normal.completable.toSingleDefault(1).blockingGet()); } @@ -2900,7 +2900,7 @@ public void toSingleDefaultNull() { normal.completable.toSingleDefault(null); } - @Test(timeout = 5000) + @Test public void unsubscribeOnNormal() throws InterruptedException { final AtomicReference name = new AtomicReference(); final CountDownLatch cdl = new CountDownLatch(1); @@ -2946,28 +2946,28 @@ public void ambArrayNull() { Completable.ambArray((Completable[])null); } - @Test(timeout = 5000) + @Test public void ambArrayEmpty() { Completable c = Completable.ambArray(); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void ambArraySingleNormal() { Completable c = Completable.ambArray(normal.completable); c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void ambArraySingleError() { Completable.ambArray(error.completable) .test() .assertError(TestException.class); } - @Test(timeout = 5000) + @Test public void ambArrayOneFires() { PublishProcessor pp1 = PublishProcessor.create(); PublishProcessor pp2 = PublishProcessor.create(); @@ -2998,7 +2998,7 @@ public void run() { Assert.assertTrue("Not completed", complete.get()); } - @Test(timeout = 5000) + @Test public void ambArrayOneFiresError() { PublishProcessor pp1 = PublishProcessor.create(); PublishProcessor pp2 = PublishProcessor.create(); @@ -3029,7 +3029,7 @@ public void accept(Throwable v) { Assert.assertTrue("Not completed", complete.get() instanceof TestException); } - @Test(timeout = 5000) + @Test public void ambArraySecondFires() { PublishProcessor pp1 = PublishProcessor.create(); PublishProcessor pp2 = PublishProcessor.create(); @@ -3060,7 +3060,7 @@ public void run() { Assert.assertTrue("Not completed", complete.get()); } - @Test(timeout = 5000) + @Test public void ambArraySecondFiresError() { PublishProcessor pp1 = PublishProcessor.create(); PublishProcessor pp2 = PublishProcessor.create(); @@ -3091,14 +3091,14 @@ public void accept(Throwable v) { Assert.assertTrue("Not completed", complete.get() instanceof TestException); } - @Test(timeout = 5000) + @Test public void ambMultipleOneIsNull() { Completable.ambArray(null, normal.completable) .test() .assertError(NullPointerException.class); } - @Test(timeout = 5000) + @Test public void ambIterableEmpty() { Completable c = Completable.amb(Collections.emptyList()); @@ -3110,7 +3110,7 @@ public void ambIterableNull() { Completable.amb((Iterable)null); } - @Test(timeout = 5000) + @Test public void ambIterableIteratorNull() { Completable.amb(new Iterable() { @Override @@ -3120,14 +3120,14 @@ public Iterator iterator() { }).test().assertError(NullPointerException.class); } - @Test(timeout = 5000) + @Test public void ambIterableWithNull() { Completable.amb(Arrays.asList(null, normal.completable)) .test() .assertError(NullPointerException.class); } - @Test(timeout = 5000) + @Test public void ambIterableSingle() { Completable c = Completable.amb(Collections.singleton(normal.completable)); @@ -3136,7 +3136,7 @@ public void ambIterableSingle() { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void ambIterableMany() { Completable c = Completable.amb(Arrays.asList(normal.completable, normal.completable, normal.completable)); @@ -3145,14 +3145,14 @@ public void ambIterableMany() { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void ambIterableOneThrows() { Completable.amb(Collections.singleton(error.completable)) .test() .assertError(TestException.class); } - @Test(timeout = 5000) + @Test public void ambIterableManyOneThrows() { Completable.amb(Arrays.asList(error.completable, normal.completable)) .test() @@ -3188,7 +3188,7 @@ public void ambWithNull() { normal.completable.ambWith(null); } - @Test(timeout = 5000) + @Test public void ambWithArrayOneFires() { PublishProcessor pp1 = PublishProcessor.create(); PublishProcessor pp2 = PublishProcessor.create(); @@ -3219,7 +3219,7 @@ public void run() { Assert.assertTrue("Not completed", complete.get()); } - @Test(timeout = 5000) + @Test public void ambWithArrayOneFiresError() { PublishProcessor pp1 = PublishProcessor.create(); PublishProcessor pp2 = PublishProcessor.create(); @@ -3250,7 +3250,7 @@ public void accept(Throwable v) { Assert.assertTrue("Not completed", complete.get() instanceof TestException); } - @Test(timeout = 5000) + @Test public void ambWithArraySecondFires() { PublishProcessor pp1 = PublishProcessor.create(); PublishProcessor pp2 = PublishProcessor.create(); @@ -3281,7 +3281,7 @@ public void run() { Assert.assertTrue("Not completed", complete.get()); } - @Test(timeout = 5000) + @Test public void ambWithArraySecondFiresError() { PublishProcessor pp1 = PublishProcessor.create(); PublishProcessor pp2 = PublishProcessor.create(); @@ -3312,7 +3312,7 @@ public void accept(Throwable v) { Assert.assertTrue("Not completed", complete.get() instanceof TestException); } - @Test(timeout = 5000) + @Test public void startWithCompletableNormal() { final AtomicBoolean run = new AtomicBoolean(); Completable c = normal.completable @@ -3330,7 +3330,7 @@ public Object call() throws Exception { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void startWithCompletableError() { Completable c = normal.completable.startWith(error.completable); @@ -3343,7 +3343,7 @@ public void startWithCompletableError() { } } - @Test(timeout = 5000) + @Test public void startWithFlowableNormal() { final AtomicBoolean run = new AtomicBoolean(); Flowable c = normal.completable @@ -3367,7 +3367,7 @@ public Object call() throws Exception { ts.assertNoErrors(); } - @Test(timeout = 5000) + @Test public void startWithFlowableError() { Flowable c = normal.completable .startWith(Flowable.error(new TestException())); @@ -3383,7 +3383,7 @@ public void startWithFlowableError() { ts.assertNotComplete(); } - @Test(timeout = 5000) + @Test public void startWithObservableNormal() { final AtomicBoolean run = new AtomicBoolean(); Observable o = normal.completable @@ -3407,7 +3407,7 @@ public Object call() throws Exception { to.assertNoErrors(); } - @Test(timeout = 5000) + @Test public void startWithObservableError() { Observable o = normal.completable .startWith(Observable.error(new TestException())); @@ -3792,7 +3792,7 @@ public void hookCreate() throws Throwable { verify(onCreate, times(1)).apply(create); } - @Test(timeout = 5000) + @Test public void doOnCompletedNormal() { final AtomicInteger calls = new AtomicInteger(); @@ -3808,7 +3808,7 @@ public void run() { Assert.assertEquals(1, calls.get()); } - @Test(timeout = 5000) + @Test public void doOnCompletedError() { final AtomicInteger calls = new AtomicInteger(); @@ -3834,7 +3834,7 @@ public void doOnCompletedNull() { normal.completable.doOnComplete(null); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void doOnCompletedThrows() { Completable c = normal.completable.doOnComplete(new Action() { @Override @@ -3844,7 +3844,7 @@ public void doOnCompletedThrows() { c.blockingAwait(); } - @Test(timeout = 5000) + @Test public void doAfterTerminateNormal() { final AtomicBoolean doneAfter = new AtomicBoolean(); final AtomicBoolean complete = new AtomicBoolean(); @@ -3948,7 +3948,7 @@ public void andThenFlowableNull() { normal.completable.andThen((Observable)null); } - @Test(timeout = 5000) + @Test public void andThenCompletableNormal() { final AtomicBoolean run = new AtomicBoolean(); Completable c = normal.completable @@ -3966,7 +3966,7 @@ public Object call() throws Exception { normal.assertSubscriptions(1); } - @Test(timeout = 5000) + @Test public void andThenCompletableError() { Completable c = normal.completable.andThen(error.completable); @@ -3979,7 +3979,7 @@ public void andThenCompletableError() { } } - @Test(timeout = 5000) + @Test public void andThenFlowableNormal() { final AtomicBoolean run = new AtomicBoolean(); Flowable c = normal.completable @@ -4003,7 +4003,7 @@ public Object call() throws Exception { ts.assertNoErrors(); } - @Test(timeout = 5000) + @Test public void andThenFlowableError() { Flowable c = normal.completable .andThen(Flowable.error(new TestException())); @@ -4123,81 +4123,6 @@ public void subscribeReportsUnsubscribed() { assertTrue("Not unsubscribed?", completableSubscription.isDisposed()); } - @Ignore("onXXX methods are not allowed to throw") - @Test - public void safeOnCompleteThrows() { - /* - try { - normal.completable.subscribe(new CompletableSubscriber() { - - @Override - public void onComplete() { - throw new TestException("Forced failure"); - } - - @Override - public void onError(Throwable e) { - - } - - @Override - public void onSubscribe(Subscription s) { - - } - - }); - Assert.fail("Did not propagate exception!"); - } catch (OnCompletedFailedException ex) { - Throwable c = ex.getCause(); - Assert.assertNotNull(c); - - Assert.assertEquals("Forced failure", c.getMessage()); - } - */ - } - - @Ignore("onXXX methods are not allowed to throw") - @Test - public void safeOnErrorThrows() { - /* - try { - error.completable.subscribe(new CompletableSubscriber() { - - @Override - public void onComplete() { - } - - @Override - public void onError(Throwable e) { - throw new TestException("Forced failure"); - } - - @Override - public void onSubscribe(Subscription s) { - - } - - }); - Assert.fail("Did not propagate exception!"); - } catch (OnErrorFailedException ex) { - Throwable c = ex.getCause(); - Assert.assertTrue("" + c, c instanceof CompositeException); - - CompositeException ce = (CompositeException)c; - - List list = ce.getExceptions(); - - Assert.assertEquals(2, list.size()); - - Assert.assertTrue("" + list.get(0), list.get(0) instanceof TestException); - Assert.assertNull(list.get(0).getMessage()); - - Assert.assertTrue("" + list.get(1), list.get(1) instanceof TestException); - Assert.assertEquals("Forced failure", list.get(1).getMessage()); - } - */ - } - @Test public void hookSubscribeStart() throws Throwable { TestSubscriber ts = new TestSubscriber(); @@ -4212,22 +4137,6 @@ public void hookSubscribeStart() throws Throwable { verify(onStart, times(1)).apply(eq(completable), any(CompletableObserver.class)); } - @Ignore("No unsafeSubscribe") - @Test - public void hookUnsafeSubscribeStart() { - /* - TestSubscriber ts = new TestSubscriber(); - Completable completable = Completable.create(new CompletableOnSubscribe() { - @Override public void call(CompletableSubscriber s) { - s.onComplete(); - } - }); - completable.unsafeSubscribe(ts); - - verify(onStart, times(1)).call(eq(completable), any(Completable.CompletableOnSubscribe.class)); - */ - } - @Test public void onStartCalledSafe() { TestSubscriber ts = new TestSubscriber() { @@ -4244,25 +4153,6 @@ public void onStart() { ts.assertComplete(); } - @Ignore("No unsafeSubscribe") - @Test - public void onStartCalledUnsafeSafe() { - /* - TestSubscriber ts = new TestSubscriber() { - @Override - public void onStart() { - onNext(1); - } - }; - - normal.completable.unsafeSubscribe(ts); - - ts.assertValue(1); - ts.assertNoErrors(); - ts.assertCompleted(); - */ - } - @Test public void onErrorCompleteFunctionThrows() { TestSubscriberEx ts = new TestSubscriberEx(); @@ -4334,80 +4224,6 @@ public void accept(Throwable e) { assertNotNull("Unsubscribed before the call to onError", disposableRef.get()); } - @Ignore("onXXX methods are not allowed to throw") - @Test - public void safeOnCompleteThrowsRegularSubscriber() { - /* - try { - normal.completable.subscribe(new FlowableSubscriber() { - - @Override - public void onComplete() { - throw new TestException("Forced failure"); - } - - @Override - public void onError(Throwable e) { - - } - - @Override - public void onNext(Object t) { - - } - }); - Assert.fail("Did not propagate exception!"); - } catch (OnCompletedFailedException ex) { - Throwable c = ex.getCause(); - Assert.assertNotNull(c); - - Assert.assertEquals("Forced failure", c.getMessage()); - } - */ - } - - @Ignore("onXXX methods are not allowed to throw") - @Test - public void safeOnErrorThrowsRegularSubscriber() { - /* - try { - error.completable.subscribe(new FlowableSubscriber() { - - @Override - public void onComplete() { - - } - - @Override - public void onError(Throwable e) { - throw new TestException("Forced failure"); - } - - @Override - public void onNext(Object t) { - - } - }); - Assert.fail("Did not propagate exception!"); - } catch (OnErrorFailedException ex) { - Throwable c = ex.getCause(); - Assert.assertTrue("" + c, c instanceof CompositeException); - - CompositeException ce = (CompositeException)c; - - List list = ce.getExceptions(); - - Assert.assertEquals(2, list.size()); - - Assert.assertTrue("" + list.get(0), list.get(0) instanceof TestException); - Assert.assertNull(list.get(0).getMessage()); - - Assert.assertTrue("" + list.get(1), list.get(1) instanceof TestException); - Assert.assertEquals("Forced failure", list.get(1).getMessage()); - } - */ - } - @Test public void propagateExceptionSubscribeOneActionThrowFromOnSuccess() { expectUncaughtTestException(new Action() { @@ -4474,7 +4290,7 @@ public void fromFutureNull() { Completable.fromFuture(null); } - @Test(timeout = 5000) + @Test public void fromFutureNormal() { ExecutorService exec = Executors.newSingleThreadExecutor(); @@ -4492,7 +4308,7 @@ public void run() { } } - @Test(timeout = 5000) + @Test public void fromFutureThrows() { ExecutorService exec = Executors.newSingleThreadExecutor(); @@ -4521,7 +4337,7 @@ public void fromRunnableNull() { Completable.fromRunnable(null); } - @Test(timeout = 5000) + @Test public void fromRunnableNormal() { final AtomicInteger calls = new AtomicInteger(); @@ -4537,7 +4353,7 @@ public void run() { Assert.assertEquals(1, calls.get()); } - @Test(timeout = 5000, expected = TestException.class) + @Test(expected = TestException.class) public void fromRunnableThrows() { Completable c = Completable.fromRunnable(new Runnable() { @Override @@ -4621,7 +4437,7 @@ public void accept(final Throwable throwable) throws Exception { } } - @Test(timeout = 5000) + @Test public void subscribeTwoCallbacksDispose() { PublishProcessor pp = PublishProcessor.create(); Disposable d = pp.ignoreElements().subscribe(Functions.EMPTY_ACTION, Functions.emptyConsumer()); diff --git a/src/test/java/io/reactivex/completable/CompletableTimerTest.java b/src/test/java/io/reactivex/completable/CompletableTimerTest.java index 909e8c28ba..fa690a327e 100644 --- a/src/test/java/io/reactivex/completable/CompletableTimerTest.java +++ b/src/test/java/io/reactivex/completable/CompletableTimerTest.java @@ -13,6 +13,7 @@ package io.reactivex.completable; +import io.reactivex.RxJavaTest; import org.junit.Test; import java.util.concurrent.TimeUnit; @@ -24,7 +25,7 @@ import static org.junit.Assert.assertEquals; -public class CompletableTimerTest { +public class CompletableTimerTest extends RxJavaTest { @Test public void timer() { final TestScheduler testScheduler = new TestScheduler(); diff --git a/src/test/java/io/reactivex/disposables/CompositeDisposableTest.java b/src/test/java/io/reactivex/disposables/CompositeDisposableTest.java index 7e042cc456..fde6cab472 100644 --- a/src/test/java/io/reactivex/disposables/CompositeDisposableTest.java +++ b/src/test/java/io/reactivex/disposables/CompositeDisposableTest.java @@ -20,13 +20,14 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; +import io.reactivex.RxJavaTest; import org.junit.Test; import io.reactivex.exceptions.CompositeException; import io.reactivex.functions.Action; import io.reactivex.testsupport.TestHelper; -public class CompositeDisposableTest { +public class CompositeDisposableTest extends RxJavaTest { @Test public void success() { @@ -54,7 +55,7 @@ public void run() { assertEquals(2, counter.get()); } - @Test(timeout = 1000) + @Test public void shouldUnsubscribeAll() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(); final CompositeDisposable cd = new CompositeDisposable(); @@ -235,7 +236,7 @@ public void run() { assertEquals(1, counter.get()); } - @Test(timeout = 1000) + @Test public void unsubscribeIdempotenceConcurrently() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(); diff --git a/src/test/java/io/reactivex/disposables/DisposablesTest.java b/src/test/java/io/reactivex/disposables/DisposablesTest.java index 9740d2e8ab..670013f37c 100644 --- a/src/test/java/io/reactivex/disposables/DisposablesTest.java +++ b/src/test/java/io/reactivex/disposables/DisposablesTest.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.concurrent.atomic.*; +import io.reactivex.RxJavaTest; import org.junit.Test; import org.reactivestreams.Subscription; @@ -28,7 +29,7 @@ import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.testsupport.TestHelper; -public class DisposablesTest { +public class DisposablesTest extends RxJavaTest { @Test public void unsubscribeOnlyOnce() { diff --git a/src/test/java/io/reactivex/disposables/FutureDisposableTest.java b/src/test/java/io/reactivex/disposables/FutureDisposableTest.java index de7ee68385..b42d808c4f 100644 --- a/src/test/java/io/reactivex/disposables/FutureDisposableTest.java +++ b/src/test/java/io/reactivex/disposables/FutureDisposableTest.java @@ -16,11 +16,13 @@ import java.util.concurrent.FutureTask; import static org.junit.Assert.*; + +import io.reactivex.RxJavaTest; import org.junit.Test; import io.reactivex.internal.functions.Functions; -public class FutureDisposableTest { +public class FutureDisposableTest extends RxJavaTest { @Test public void normal() { diff --git a/src/test/java/io/reactivex/disposables/SequentialDisposableTest.java b/src/test/java/io/reactivex/disposables/SequentialDisposableTest.java index c442225929..07a25908db 100644 --- a/src/test/java/io/reactivex/disposables/SequentialDisposableTest.java +++ b/src/test/java/io/reactivex/disposables/SequentialDisposableTest.java @@ -19,6 +19,7 @@ import java.util.*; import java.util.concurrent.CountDownLatch; +import io.reactivex.RxJavaTest; import org.junit.*; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; @@ -26,7 +27,7 @@ import io.reactivex.internal.disposables.SequentialDisposable; @RunWith(MockitoJUnitRunner.class) -public class SequentialDisposableTest { +public class SequentialDisposableTest extends RxJavaTest { private SequentialDisposable serialDisposable; @Before @@ -117,7 +118,7 @@ public void settingUnderlyingWhenUnsubscribedCausesImmediateUnsubscription() { verify(underlying).dispose(); } - @Test(timeout = 1000) + @Test public void settingUnderlyingWhenUnsubscribedCausesImmediateUnsubscriptionConcurrently() throws InterruptedException { final Disposable firstSet = mock(Disposable.class); diff --git a/src/test/java/io/reactivex/disposables/SerialDisposableTests.java b/src/test/java/io/reactivex/disposables/SerialDisposableTests.java index 1ad96251ee..e10f41d671 100644 --- a/src/test/java/io/reactivex/disposables/SerialDisposableTests.java +++ b/src/test/java/io/reactivex/disposables/SerialDisposableTests.java @@ -19,6 +19,7 @@ import java.util.*; import java.util.concurrent.CountDownLatch; +import io.reactivex.RxJavaTest; import org.junit.*; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; @@ -26,7 +27,7 @@ import io.reactivex.internal.disposables.DisposableHelper; @RunWith(MockitoJUnitRunner.class) -public class SerialDisposableTests { +public class SerialDisposableTests extends RxJavaTest { private SerialDisposable serialDisposable; @Before @@ -117,7 +118,7 @@ public void settingUnderlyingWhenUnsubscribedCausesImmediateUnsubscription() { verify(underlying).dispose(); } - @Test(timeout = 1000) + @Test public void settingUnderlyingWhenUnsubscribedCausesImmediateUnsubscriptionConcurrently() throws InterruptedException { final Disposable firstSet = mock(Disposable.class); diff --git a/src/test/java/io/reactivex/exceptions/CompositeExceptionTest.java b/src/test/java/io/reactivex/exceptions/CompositeExceptionTest.java index 4367466f34..b3b9518830 100644 --- a/src/test/java/io/reactivex/exceptions/CompositeExceptionTest.java +++ b/src/test/java/io/reactivex/exceptions/CompositeExceptionTest.java @@ -20,11 +20,12 @@ import java.io.*; import java.util.*; +import io.reactivex.RxJavaTest; import org.junit.Test; import io.reactivex.exceptions.CompositeException.CompositeExceptionCausalChain; -public class CompositeExceptionTest { +public class CompositeExceptionTest extends RxJavaTest { private final Throwable ex1 = new Throwable("Ex1"); private final Throwable ex2 = new Throwable("Ex2", ex1); @@ -38,7 +39,7 @@ private CompositeException getNewCompositeExceptionWithEx123() { return new CompositeException(throwables); } - @Test(timeout = 1000) + @Test public void multipleWithSameCause() { Throwable rootCause = new Throwable("RootCause"); Throwable e1 = new Throwable("1", rootCause); @@ -72,7 +73,7 @@ public void emptyErrors() { } } - @Test(timeout = 1000) + @Test public void compositeExceptionFromParentThenChild() { CompositeException cex = new CompositeException(ex1, ex2); @@ -87,7 +88,7 @@ public void compositeExceptionFromParentThenChild() { cex.getCause().printStackTrace(); } - @Test(timeout = 1000) + @Test public void compositeExceptionFromChildThenParent() { CompositeException cex = new CompositeException(ex2, ex1); @@ -102,7 +103,7 @@ public void compositeExceptionFromChildThenParent() { cex.getCause().printStackTrace(); } - @Test(timeout = 1000) + @Test public void compositeExceptionFromChildAndComposite() { CompositeException cex = new CompositeException(ex1, getNewCompositeExceptionWithEx123()); @@ -117,7 +118,7 @@ public void compositeExceptionFromChildAndComposite() { cex.getCause().printStackTrace(); } - @Test(timeout = 1000) + @Test public void compositeExceptionFromCompositeAndChild() { CompositeException cex = new CompositeException(getNewCompositeExceptionWithEx123(), ex1); @@ -132,7 +133,7 @@ public void compositeExceptionFromCompositeAndChild() { cex.getCause().printStackTrace(); } - @Test(timeout = 1000) + @Test public void compositeExceptionFromTwoDuplicateComposites() { List exs = new ArrayList(); exs.add(getNewCompositeExceptionWithEx123()); @@ -190,7 +191,7 @@ public void nullElement() { composite.printStackTrace(); } - @Test(timeout = 1000) + @Test public void compositeExceptionWithUnsupportedInitCause() { Throwable t = new Throwable() { @@ -214,7 +215,7 @@ public synchronized Throwable initCause(Throwable cause) { cex.getCause().printStackTrace(); } - @Test(timeout = 1000) + @Test public void compositeExceptionWithNullInitCause() { Throwable t = new Throwable("ThrowableWithNullInitCause") { diff --git a/src/test/java/io/reactivex/exceptions/ExceptionsNullTest.java b/src/test/java/io/reactivex/exceptions/ExceptionsNullTest.java deleted file mode 100644 index aba4ab8bdc..0000000000 --- a/src/test/java/io/reactivex/exceptions/ExceptionsNullTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2016-present, RxJava Contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.reactivex.exceptions; - -import org.junit.*; - -/** - * Checks the Exception classes to verify they don't crash with null argument. - */ -public class ExceptionsNullTest { - - @Ignore("OnCompleteFailedException will likely not be ported") - @Test - public void onCompleteFailedExceptionNull() { -// Throwable t = new OnCompleteFailedException(null); -// -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("OnCompleteFailedException will likely not be ported") - @Test - public void onCompleteFailedExceptionMessageAndNull() { -// Throwable t = new OnCompleteFailedException("Message", null); -// -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("OnErrorFailedException will likely not be ported") - @Test - public void onErrorFailedExceptionNull() { -// Throwable t = new OnErrorFailedException(null); -// -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("OnErrorFailedException will likely not be ported") - @Test - public void onErrorFailedExceptionMessageAndNull() { -// Throwable t = new OnErrorFailedException("Message", null); -// -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("UnsubscribeFailedException will likely not be ported") - @Test - public void unsubscribeFailedExceptionNull() { -// Throwable t = new UnsubscribeFailedException(null); -// -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("UnsubscribeFailedException will likely not be ported") - @Test - public void unsubscribeFailedExceptionMessageAndNull() { -// Throwable t = new UnsubscribeFailedException("Message", null); -// -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("OnErrorNotImplementedException will likely not be ported") - @Test - public void onErrorNotImplementedExceptionNull() { -// Throwable t = new OnErrorNotImplementedException(null); -// -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("OnErrorNotImplementedException will likely not be ported") - @Test - public void onErrorNotImplementedExceptionMessageAndNull() { -// Throwable t = new OnErrorNotImplementedException("Message", null); -// -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("OnErrorThrowable may be ported later") - @Test - public void onErrorThrowableFrom() { -// Throwable t = OnErrorThrowable.from(null); -// Assert.assertTrue(t.getCause() instanceof NullPointerException); - } - - @Ignore("OnErrorThrowable may be ported later") - @Test - public void onErrorThrowableAddValueAsLastCause() { -// Throwable t = OnErrorThrowable.addValueAsLastCause(null, "value"); -// Assert.assertTrue(t instanceof NullPointerException); - } - -} diff --git a/src/test/java/io/reactivex/exceptions/ExceptionsTest.java b/src/test/java/io/reactivex/exceptions/ExceptionsTest.java index 8286fce43a..9d2e9ba4e9 100644 --- a/src/test/java/io/reactivex/exceptions/ExceptionsTest.java +++ b/src/test/java/io/reactivex/exceptions/ExceptionsTest.java @@ -22,20 +22,17 @@ import java.util.concurrent.atomic.AtomicInteger; import org.junit.*; -import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.functions.*; import io.reactivex.internal.util.ExceptionHelper; -import io.reactivex.observables.GroupedObservable; import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.subjects.PublishSubject; import io.reactivex.testsupport.TestHelper; -public class ExceptionsTest { +public class ExceptionsTest extends RxJavaTest { - @Ignore("Exceptions is not an enum") @Test public void constructorShouldBePrivate() { TestHelper.checkUtilityClass(ExceptionHelper.class); @@ -59,35 +56,6 @@ public void accept(Integer t1) { RxJavaPlugins.reset(); } - /** - * Outdated test: Observer should not suppress errors from onCompleted. - * https://github.com/ReactiveX/RxJava/issues/3885 - */ - @Ignore("v2 components should not throw") - @Test(expected = RuntimeException.class) - public void onCompletedExceptionIsThrown() { - Observable.empty() - .subscribe(new Observer() { - @Override - public void onComplete() { - throw new RuntimeException(); - } - - @Override - public void onError(Throwable e) { - } - - @Override - public void onNext(Object o) { - } - - @Override - public void onSubscribe(Disposable d) { - - } - }); - } - @Test public void stackOverflowWouldOccur() { final PublishSubject a = PublishSubject.create(); @@ -201,247 +169,6 @@ public void onNext(Integer t) { }); } - /** - * Outdated test: throwing from onError handler. - * https://github.com/ReactiveX/RxJava/issues/969 - */ - @Ignore("v2 components should not throw") - @Test - public void onErrorExceptionIsThrown() { - try { - Observable.error(new IllegalArgumentException("original exception")).subscribe(new Observer() { - - @Override - public void onSubscribe(Disposable d) { - - } - - @Override - public void onComplete() { - - } - - @Override - public void onError(Throwable e) { - throw new IllegalStateException("This should be thrown"); - } - - @Override - public void onNext(Object o) { - - } - }); - fail("expecting an exception to be thrown"); - } catch (RuntimeException t) { - CompositeException cause = (CompositeException) t.getCause(); - assertTrue(cause.getExceptions().get(0) instanceof IllegalArgumentException); - assertTrue(cause.getExceptions().get(1) instanceof IllegalStateException); - } - } - - /** - * Outdated test: throwing from onError. - * https://github.com/ReactiveX/RxJava/issues/2998 - * @throws Exception on arbitrary errors - */ - @Ignore("v2 components should not throw") - @Test(expected = RuntimeException.class) - public void onErrorExceptionIsThrownFromGroupBy() throws Exception { - Observable - .just(1) - .groupBy(new Function() { - @Override - public Integer apply(Integer integer) { - throw new RuntimeException(); - } - }) - .subscribe(new Observer>() { - - @Override - public void onSubscribe(Disposable d) { - - } - - @Override - public void onComplete() { - - } - - @Override - public void onError(Throwable e) { - throw new RuntimeException(); - } - - @Override - public void onNext(GroupedObservable integerIntegerGroupedObservable) { - - } - }); - } - - /** - * Outdated test: throwing from onError. - * https://github.com/ReactiveX/RxJava/issues/2998 - * @throws Exception on arbitrary errors - */ - @Ignore("v2 components should not throw") - @Test(expected = RuntimeException.class) - public void onErrorExceptionIsThrownFromOnNext() throws Exception { - Observable - .just(1) - .doOnNext(new Consumer() { - @Override - public void accept(Integer integer) { - throw new RuntimeException(); - } - }) - .subscribe(new Observer() { - - @Override - public void onSubscribe(Disposable d) { - - } - - @Override - public void onComplete() { - - } - - @Override - public void onError(Throwable e) { - throw new RuntimeException(); - } - - @Override - public void onNext(Integer integer) { - - } - }); - } - - @Ignore("v2 components should not throw") - @Test(expected = RuntimeException.class) - public void onErrorExceptionIsThrownFromSubscribe() { - Observable.unsafeCreate(new ObservableSource() { - @Override - public void subscribe(Observer observer1) { - Observable.unsafeCreate(new ObservableSource() { - @Override - public void subscribe(Observer observer2) { - throw new IllegalArgumentException("original exception"); - } - }).subscribe(observer1); - } - } - ).subscribe(new OnErrorFailedSubscriber()); - } - - @Ignore("v2 components should not throw") - @Test(expected = RuntimeException.class) - public void onErrorExceptionIsThrownFromUnsafeSubscribe() { - Observable.unsafeCreate(new ObservableSource() { - @Override - public void subscribe(Observer observer1) { - Observable.unsafeCreate(new ObservableSource() { - @Override - public void subscribe(Observer observer2) { - throw new IllegalArgumentException("original exception"); - } - }).subscribe(observer1); - } - } - ).subscribe(new OnErrorFailedSubscriber()); - } - - @Ignore("v2 components should not throw") - @Test(expected = RuntimeException.class) - public void onErrorExceptionIsThrownFromSingleDoOnSuccess() throws Exception { - Single.just(1) - .doOnSuccess(new Consumer() { - @Override - public void accept(Integer integer) { - throw new RuntimeException(); - } - }) - .toObservable().subscribe(new OnErrorFailedSubscriber()); - } - - @Ignore("v2 components should not throw") - @Test(expected = RuntimeException.class) - public void onErrorExceptionIsThrownFromSingleSubscribe() { - Single.unsafeCreate(new SingleSource() { - @Override - public void subscribe(SingleObserver observer1) { - Single.unsafeCreate(new SingleSource() { - @Override - public void subscribe(SingleObserver observer2) { - throw new IllegalArgumentException("original exception"); - } - }).subscribe(observer1); - } - } - ).toObservable().subscribe(new OnErrorFailedSubscriber()); - } - - @Ignore("v2 components should not throw") - @Test(expected = RuntimeException.class) - public void onErrorExceptionIsThrownFromSingleUnsafeSubscribe() { - Single.unsafeCreate(new SingleSource() { - @Override - public void subscribe(final SingleObserver observer1) { - Single.unsafeCreate(new SingleSource() { - @Override - public void subscribe(SingleObserver observer2) { - throw new IllegalArgumentException("original exception"); - } - }).toFlowable().subscribe(new FlowableSubscriber() { - - @Override - public void onSubscribe(Subscription s) { - s.request(Long.MAX_VALUE); - } - - @Override - public void onComplete() { - } - - @Override - public void onError(Throwable e) { - observer1.onError(e); - } - - @Override - public void onNext(Integer v) { - observer1.onSuccess(v); - } - - }); - } - } - ).toObservable().subscribe(new OnErrorFailedSubscriber()); - } - - private class OnErrorFailedSubscriber implements Observer { - - @Override - public void onSubscribe(Disposable d) { - - } - - @Override - public void onComplete() { - } - - @Override - public void onError(Throwable e) { - throw new RuntimeException(); - } - - @Override - public void onNext(Integer value) { - } - } - @Test public void utilityClass() { TestHelper.checkUtilityClass(Exceptions.class); diff --git a/src/test/java/io/reactivex/exceptions/OnErrorNotImplementedExceptionTest.java b/src/test/java/io/reactivex/exceptions/OnErrorNotImplementedExceptionTest.java index 0ccc74114d..5f20033d8a 100644 --- a/src/test/java/io/reactivex/exceptions/OnErrorNotImplementedExceptionTest.java +++ b/src/test/java/io/reactivex/exceptions/OnErrorNotImplementedExceptionTest.java @@ -24,7 +24,7 @@ import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.testsupport.TestHelper; -public class OnErrorNotImplementedExceptionTest { +public class OnErrorNotImplementedExceptionTest extends RxJavaTest { List errors; diff --git a/src/test/java/io/reactivex/exceptions/OnNextValueTest.java b/src/test/java/io/reactivex/exceptions/OnNextValueTest.java deleted file mode 100644 index 800ac2b55d..0000000000 --- a/src/test/java/io/reactivex/exceptions/OnNextValueTest.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Copyright (c) 2016-present, RxJava Contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.reactivex.exceptions; - -import static org.junit.Assert.*; - -import java.io.*; - -import org.junit.*; - -import io.reactivex.*; -import io.reactivex.disposables.Disposable; -import io.reactivex.functions.Function; - -/** - * ```java - * public OnNextValue(Object value) { - * super("OnError while emitting onNext value: " + value); - * this.value = value; - * } - * ``` - * I know this is probably a helpful error message in some cases but this can be a really costly operation when an objects toString is an expensive call or contains a lot of output. I don't think we should be printing this in any case but if so it should be on demand (overload of getMessage()) rather than eagerly. - *

- * In my case it is causing a toString of a large context object that is normally only used for debugging purposes which makes the exception logs hard to use and they are rolling over the log files very quickly. - *

- * There is an added danger that if there is a bug in the toString method it will cause inconsistent exception creation. If the object throws an exception while rendering a string it will actually end up not seeing the real exception. - */ -public final class OnNextValueTest { - private static final class BadToString { - - private final boolean throwDuringToString; - - private BadToString(boolean throwDuringToString) { - this.throwDuringToString = throwDuringToString; - } - - @Override - public String toString() { - if (throwDuringToString) { - throw new IllegalArgumentException("Error Making toString"); - } else { - return "BadToString"; - } - } - } - - private static class BadToStringObserver implements Observer { - @Override - public void onComplete() { - System.out.println("On Complete"); - fail("OnComplete shouldn't be reached"); - } - - @Override - public void onError(Throwable e) { - String trace = stackTraceAsString(e); - System.out.println("On Error: " + trace); - - assertTrue(trace, trace.contains("OnNextValue")); - - assertNotNull("No Cause on throwable" + e, e.getCause()); -// assertTrue(e.getCause().getClass().getSimpleName() + " no OnNextValue", -// e.getCause() instanceof OnErrorThrowable.OnNextValue); - } - - @Override - public void onNext(BadToString badToString) { - System.out.println("On Next"); - fail("OnNext shouldn't be reached"); - - } - - @Override - public void onSubscribe(Disposable d) { - - } - } - - public static String stackTraceAsString(Throwable e) { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - return sw.toString(); - } - - @Ignore("Not sure what this does") - @Test - public void addOnNextValueExceptionAdded() throws Exception { - Observer observer = new BadToStringObserver(); - - Observable.just(new BadToString(false)) - .map(new Function() { - @Override - public BadToString apply(BadToString badToString) { - throw new IllegalArgumentException("Failure while handling"); - } - }).subscribe(observer); - - } - - @Ignore("Not sure what this does") - @Test - public void addOnNextValueExceptionNotAddedWithBadString() throws Exception { - Observer observer = new BadToStringObserver(); - - Observable.just(new BadToString(true)) - .map(new Function() { - @Override - public BadToString apply(BadToString badToString) { - throw new IllegalArgumentException("Failure while handling"); - } - }).subscribe(observer); - - } - - @Ignore("OnNextValue not ported") - @Test - public void renderInteger() { -// assertEquals("123", OnNextValue.renderValue(123)); - } - - @Ignore("OnNextValue not ported") - @Test - public void renderByte() { -// assertEquals("10", OnNextValue.renderValue((byte) 10)); - } - - @Ignore("OnNextValue not ported") - @Test - public void renderBoolean() { -// assertEquals("true", OnNextValue.renderValue(true)); - } - - @Ignore("OnNextValue not ported") - @Test - public void renderShort() { -// assertEquals("10", OnNextValue.renderValue((short) 10)); - } - - @Ignore("OnNextValue not ported") - @Test - public void renderLong() { -// assertEquals("10", OnNextValue.renderValue(10L)); - } - - @Ignore("OnNextValue not ported") - @Test - public void renderCharacter() { -// assertEquals("10", OnNextValue.renderValue(10L)); - } - - @Ignore("OnNextValue not ported") - @Test - public void renderFloat() { -// assertEquals("10.0", OnNextValue.renderValue(10.0f)); - } - - @Ignore("OnNextValue not ported") - @Test - public void renderDouble() { -// assertEquals("10.0", OnNextValue.renderValue(10.0)); - } - - @Ignore("OnNextValue not ported") - @Test - public void renderVoid() { -// assertEquals("null", OnNextValue.renderValue((Void) null)); - } -}