diff --git a/src/test/java/io/reactivex/rxjava4/internal/subscribers/FutureSubscriberIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/subscribers/FutureSubscriberIsolatedTest.java new file mode 100644 index 0000000000..cfae1064ba --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/subscribers/FutureSubscriberIsolatedTest.java @@ -0,0 +1,76 @@ +/* + * 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.subscribers; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.parallel.Isolated; + +import io.reactivex.rxjava4.core.RxJavaTest; +import io.reactivex.rxjava4.exceptions.TestException; +import io.reactivex.rxjava4.internal.subscriptions.BooleanSubscription; +import io.reactivex.rxjava4.testsupport.SuppressUndeliverable; +import io.reactivex.rxjava4.testsupport.TestHelper; + +@Isolated +public class FutureSubscriberIsolatedTest extends RxJavaTest { + + @Test + public void cancelRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + final FutureSubscriber fs = new FutureSubscriber<>(); + + Runnable r = () -> fs.cancel(false); + + TestHelper.race(r, r); + } + } + + @Test + @SuppressUndeliverable + public void onErrorCancelRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + final FutureSubscriber fs = new FutureSubscriber<>(); + + final TestException ex = new TestException(); + + Runnable r1 = () -> fs.cancel(false); + + Runnable r2 = () -> fs.onError(ex); + + TestHelper.race(r1, r2); + } + } + + @Test + @SuppressUndeliverable + public void onCompleteCancelRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + final FutureSubscriber fs = new FutureSubscriber<>(); + + if (i % 3 == 0) { + fs.onSubscribe(new BooleanSubscription()); + } + + if (i % 2 == 0) { + fs.onNext(1); + } + + Runnable r1 = () -> fs.cancel(false); + + Runnable r2 = fs::onComplete; + + TestHelper.race(r1, r2); + } + } +} diff --git a/src/test/java/io/reactivex/rxjava4/internal/subscribers/FutureSubscriberTest.java b/src/test/java/io/reactivex/rxjava4/internal/subscribers/FutureSubscriberTest.java index 0607719c95..6b73184e48 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/subscribers/FutureSubscriberTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/subscribers/FutureSubscriberTest.java @@ -125,17 +125,6 @@ public void onSubscribe() throws Exception { } } - @Test - public void cancelRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - final FutureSubscriber fs = new FutureSubscriber<>(); - - Runnable r = () -> fs.cancel(false); - - TestHelper.race(r, r); - } - } - @Test public void await() throws Exception { Schedulers.single().scheduleDirect(() -> { @@ -146,44 +135,6 @@ public void await() throws Exception { assertEquals(1, fs.get(5, TimeUnit.SECONDS).intValue()); } - @Test - @SuppressUndeliverable - public void onErrorCancelRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - final FutureSubscriber fs = new FutureSubscriber<>(); - - final TestException ex = new TestException(); - - Runnable r1 = () -> fs.cancel(false); - - Runnable r2 = () -> fs.onError(ex); - - TestHelper.race(r1, r2); - } - } - - @Test - @SuppressUndeliverable - public void onCompleteCancelRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - final FutureSubscriber fs = new FutureSubscriber<>(); - - if (i % 3 == 0) { - fs.onSubscribe(new BooleanSubscription()); - } - - if (i % 2 == 0) { - fs.onNext(1); - } - - Runnable r1 = () -> fs.cancel(false); - - Runnable r2 = fs::onComplete; - - TestHelper.race(r1, r2); - } - } - @Test @SuppressUndeliverable public void onErrorOnComplete() throws Exception {