diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeAmbIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeAmbIsolatedTest.java new file mode 100644 index 0000000000..36e1ff554b --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeAmbIsolatedTest.java @@ -0,0 +1,89 @@ +/* + * 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.rxjava4.internal.operators.maybe; + +import java.util.*; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Isolated; + +import io.reactivex.rxjava4.core.*; +import io.reactivex.rxjava4.exceptions.TestException; +import io.reactivex.rxjava4.observers.TestObserver; +import io.reactivex.rxjava4.plugins.RxJavaPlugins; +import io.reactivex.rxjava4.processors.PublishProcessor; +import io.reactivex.rxjava4.subjects.*; +import io.reactivex.rxjava4.testsupport.TestHelper; + +@Isolated +public class MaybeAmbIsolatedTest extends RxJavaTest { + + @Test + public void innerErrorRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + List errors = TestHelper.trackPluginErrors(); + try { + final PublishProcessor pp0 = PublishProcessor.create(); + final PublishProcessor pp1 = PublishProcessor.create(); + + final TestObserver to = Maybe.amb(Arrays.asList(pp0.singleElement(), pp1.singleElement())) + .test(); + + final TestException ex = new TestException(); + + Runnable r1 = () -> pp0.onError(ex); + + Runnable r2 = () -> pp1.onError(ex); + + TestHelper.race(r1, r2); + + to.assertFailure(TestException.class); + + if (!errors.isEmpty()) { + TestHelper.assertUndeliverable(errors, 0, TestException.class); + } + } finally { + RxJavaPlugins.reset(); + } + } + } + + @Test + public void nullSourceSuccessRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + List errors = TestHelper.trackPluginErrors(); + + try { + + final Subject ps = ReplaySubject.create(); + ps.onNext(1); + + final Maybe source = Maybe.ambArray(ps.singleElement(), + Maybe.never(), Maybe.never(), null); + + Runnable r1 = source::test; + + Runnable r2 = ps::onComplete; + + TestHelper.race(r1, r2); + + if (!errors.isEmpty()) { + TestHelper.assertError(errors, 0, NullPointerException.class); + } + } finally { + RxJavaPlugins.reset(); + } + } + } +} diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeAmbTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeAmbTest.java index 1f99c0d207..1cd69f1cca 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeAmbTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeAmbTest.java @@ -27,7 +27,6 @@ import io.reactivex.rxjava4.functions.Consumer; import io.reactivex.rxjava4.internal.functions.Functions; import io.reactivex.rxjava4.observers.TestObserver; -import io.reactivex.rxjava4.plugins.RxJavaPlugins; import io.reactivex.rxjava4.processors.PublishProcessor; import io.reactivex.rxjava4.schedulers.Schedulers; import io.reactivex.rxjava4.subjects.*; @@ -74,36 +73,6 @@ public void dispose() { assertFalse(pp2.hasSubscribers()); } - @Test - public void innerErrorRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - List errors = TestHelper.trackPluginErrors(); - try { - final PublishProcessor pp0 = PublishProcessor.create(); - final PublishProcessor pp1 = PublishProcessor.create(); - - final TestObserver to = Maybe.amb(Arrays.asList(pp0.singleElement(), pp1.singleElement())) - .test(); - - final TestException ex = new TestException(); - - Runnable r1 = () -> pp0.onError(ex); - - Runnable r2 = () -> pp1.onError(ex); - - TestHelper.race(r1, r2); - - to.assertFailure(TestException.class); - - if (!errors.isEmpty()) { - TestHelper.assertUndeliverable(errors, 0, TestException.class); - } - } finally { - RxJavaPlugins.reset(); - } - } - } - @Test public void disposeNoFurtherSignals() { var to = Maybe.ambArray(new Maybe<>() /* NFI */ { @@ -190,34 +159,6 @@ public void noWinnerCompleteDispose() throws Exception { } } - @Test - public void nullSourceSuccessRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - List errors = TestHelper.trackPluginErrors(); - - try { - - final Subject ps = ReplaySubject.create(); - ps.onNext(1); - - final Maybe source = Maybe.ambArray(ps.singleElement(), - Maybe.never(), Maybe.never(), null); - - Runnable r1 = source::test; - - Runnable r2 = ps::onComplete; - - TestHelper.race(r1, r2); - - if (!errors.isEmpty()) { - TestHelper.assertError(errors, 0, NullPointerException.class); - } - } finally { - RxJavaPlugins.reset(); - } - } - } - @Test public void maybeSourcesInIterable() { MaybeSource source = observer -> Maybe.just(1).subscribe(observer); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatArrayIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatArrayIsolatedTest.java new file mode 100644 index 0000000000..00649c1292 --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatArrayIsolatedTest.java @@ -0,0 +1,54 @@ +/* + * 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.rxjava4.internal.operators.maybe; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Isolated; + +import io.reactivex.rxjava4.core.*; +import io.reactivex.rxjava4.core.config.StandardBufferedConfig; +import io.reactivex.rxjava4.subscribers.TestSubscriber; +import io.reactivex.rxjava4.testsupport.TestHelper; + +@Isolated +public class MaybeConcatArrayIsolatedTest extends RxJavaTest { + + @Test + public void requestCancelRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + final TestSubscriber ts = Maybe.concatArray(Maybe.just(1), Maybe.just(2)) + .test(0L); + + Runnable r1 = ts::cancel; + + Runnable r2 = () -> ts.request(1); + + TestHelper.race(r1, r2); + } + } + + @Test + public void requestCancelRaceDelayError() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + final TestSubscriber ts = Maybe.concatArray(StandardBufferedConfig.DELAY_ERRORS, Maybe.just(1), Maybe.just(2)) + .test(0L); + + Runnable r1 = ts::cancel; + + Runnable r2 = () -> ts.request(1); + + TestHelper.race(r1, r2); + } + } +} diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatArrayTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatArrayTest.java index ce088eb11a..1ed8357725 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatArrayTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatArrayTest.java @@ -79,34 +79,6 @@ public void backpressureDelayError() { ts.assertResult(1, 2); } - @Test - public void requestCancelRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - final TestSubscriber ts = Maybe.concatArray(Maybe.just(1), Maybe.just(2)) - .test(0L); - - Runnable r1 = ts::cancel; - - Runnable r2 = () -> ts.request(1); - - TestHelper.race(r1, r2); - } - } - - @Test - public void requestCancelRaceDelayError() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - final TestSubscriber ts = Maybe.concatArray(StandardBufferedConfig.DELAY_ERRORS, Maybe.just(1), Maybe.just(2)) - .test(0L); - - Runnable r1 = ts::cancel; - - Runnable r2 = () -> ts.request(1); - - TestHelper.race(r1, r2); - } - } - @Test public void errorAfterTermination() { List errors = TestHelper.trackPluginErrors(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatIterableIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatIterableIsolatedTest.java new file mode 100644 index 0000000000..433a136c35 --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatIterableIsolatedTest.java @@ -0,0 +1,47 @@ +/* + * 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.rxjava4.internal.operators.maybe; + +import java.util.Collections; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Isolated; + +import io.reactivex.rxjava4.core.*; +import io.reactivex.rxjava4.processors.PublishProcessor; +import io.reactivex.rxjava4.subscribers.TestSubscriber; +import io.reactivex.rxjava4.testsupport.TestHelper; + +@Isolated +public class MaybeConcatIterableIsolatedTest extends RxJavaTest { + + @Test + public void successCancelRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + + final PublishProcessor pp = PublishProcessor.create(); + + final TestSubscriber ts = Maybe.concat(Collections.singletonList(pp.singleElement())) + .test(); + + pp.onNext(1); + + Runnable r1 = ts::cancel; + + Runnable r2 = pp::onComplete; + + TestHelper.race(r1, r2); + } + } +} diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatIterableTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatIterableTest.java index 642805a9ca..b6d8f7c414 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatIterableTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeConcatIterableTest.java @@ -24,9 +24,7 @@ import io.reactivex.rxjava4.exceptions.TestException; import io.reactivex.rxjava4.functions.Function; import io.reactivex.rxjava4.internal.util.CrashingMappedIterable; -import io.reactivex.rxjava4.processors.PublishProcessor; import io.reactivex.rxjava4.subjects.MaybeSubject; -import io.reactivex.rxjava4.subscribers.TestSubscriber; import io.reactivex.rxjava4.testsupport.TestHelper; public class MaybeConcatIterableTest extends RxJavaTest { @@ -55,25 +53,6 @@ public void error() { .assertFailure(TestException.class, 1); } - @Test - public void successCancelRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - - final PublishProcessor pp = PublishProcessor.create(); - - final TestSubscriber ts = Maybe.concat(Collections.singletonList(pp.singleElement())) - .test(); - - pp.onNext(1); - - Runnable r1 = ts::cancel; - - Runnable r2 = pp::onComplete; - - TestHelper.race(r1, r2); - } - } - @Test public void hasNextThrows() { Maybe.concat(new CrashingMappedIterable<>(100, 1, 100, _ -> Maybe.just(1)))