diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCacheIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCacheIsolatedTest.java new file mode 100644 index 0000000000..2422d122d0 --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCacheIsolatedTest.java @@ -0,0 +1,57 @@ +/* + * 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.observers.TestObserver; +import io.reactivex.rxjava4.processors.PublishProcessor; +import io.reactivex.rxjava4.testsupport.TestHelper; + +@Isolated +public class MaybeCacheIsolatedTest extends RxJavaTest { + + @Test + public void addAddRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + PublishProcessor pp = PublishProcessor.create(); + + final Maybe source = pp.singleElement().cache(); + + Runnable r = source::test; + + TestHelper.race(r, r); + } + } + + @Test + public void removeRemoveRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + PublishProcessor pp = PublishProcessor.create(); + + final Maybe source = pp.singleElement().cache(); + + final TestObserver to1 = source.test(); + final TestObserver to2 = source.test(); + + Runnable r1 = to1::dispose; + + Runnable r2 = to2::dispose; + + TestHelper.race(r1, r2); + } + } +} diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCacheTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCacheTest.java index 65f5a3ee0b..86c5162334 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCacheTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeCacheTest.java @@ -25,7 +25,6 @@ import io.reactivex.rxjava4.observers.TestObserver; import io.reactivex.rxjava4.processors.PublishProcessor; import io.reactivex.rxjava4.subscribers.TestSubscriber; -import io.reactivex.rxjava4.testsupport.TestHelper; public class MaybeCacheTest extends RxJavaTest { @@ -206,37 +205,6 @@ public void crossCancelOnComplete() { ts.assertEmpty(); } - @Test - public void addAddRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - PublishProcessor pp = PublishProcessor.create(); - - final Maybe source = pp.singleElement().cache(); - - Runnable r = source::test; - - TestHelper.race(r, r); - } - } - - @Test - public void removeRemoveRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - PublishProcessor pp = PublishProcessor.create(); - - final Maybe source = pp.singleElement().cache(); - - final TestObserver to1 = source.test(); - final TestObserver to2 = source.test(); - - Runnable r1 = to1::dispose; - - Runnable r2 = to2::dispose; - - TestHelper.race(r1, r2); - } - } - @Test public void doubleDispose() { PublishProcessor pp = PublishProcessor.create(); diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUnsubscribeOnIsolatedTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUnsubscribeOnIsolatedTest.java new file mode 100644 index 0000000000..a350743a40 --- /dev/null +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUnsubscribeOnIsolatedTest.java @@ -0,0 +1,62 @@ +/* + * 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.disposables.Disposable; +import io.reactivex.rxjava4.processors.PublishProcessor; +import io.reactivex.rxjava4.schedulers.Schedulers; +import io.reactivex.rxjava4.testsupport.TestHelper; + +@Isolated +public class MaybeUnsubscribeOnIsolatedTest extends RxJavaTest { + + @Test + public void disposeRace() { + for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { + PublishProcessor pp = PublishProcessor.create(); + + final Disposable[] ds = { null }; + pp.singleElement().unsubscribeOn(Schedulers.computation()) + .subscribe(new MaybeObserver<>() /* NFI */ { + @Override + public void onSubscribe(Disposable d) { + ds[0] = d; + } + + @Override + public void onSuccess(Integer value) { + + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + + Runnable r = () -> ds[0].dispose(); + + TestHelper.race(r, r); + } + } +} diff --git a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUnsubscribeOnTest.java b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUnsubscribeOnTest.java index c0bdb6776c..fe137131b2 100644 --- a/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUnsubscribeOnTest.java +++ b/src/test/java/io/reactivex/rxjava4/internal/operators/maybe/MaybeUnsubscribeOnTest.java @@ -93,38 +93,4 @@ public void doubleOnSubscribe() { TestHelper.checkDoubleOnSubscribeMaybe(v -> v.unsubscribeOn(Schedulers.single())); } - @Test - public void disposeRace() { - for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) { - PublishProcessor pp = PublishProcessor.create(); - - final Disposable[] ds = { null }; - pp.singleElement().unsubscribeOn(Schedulers.computation()) - .subscribe(new MaybeObserver<>() /* NFI */ { - @Override - public void onSubscribe(Disposable d) { - ds[0] = d; - } - - @Override - public void onSuccess(Integer value) { - - } - - @Override - public void onError(Throwable e) { - - } - - @Override - public void onComplete() { - - } - }); - - Runnable r = () -> ds[0].dispose(); - - TestHelper.race(r, r); - } - } }