Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<Integer> pp = PublishProcessor.create();

final Maybe<Integer> 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<Integer> pp = PublishProcessor.create();

final Maybe<Integer> source = pp.singleElement().cache();

final TestObserver<Integer> to1 = source.test();
final TestObserver<Integer> to2 = source.test();

Runnable r1 = to1::dispose;

Runnable r2 = to2::dispose;

TestHelper.race(r1, r2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -206,37 +205,6 @@ public void crossCancelOnComplete() {
ts.assertEmpty();
}

@Test
public void addAddRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
PublishProcessor<Integer> pp = PublishProcessor.create();

final Maybe<Integer> 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<Integer> pp = PublishProcessor.create();

final Maybe<Integer> source = pp.singleElement().cache();

final TestObserver<Integer> to1 = source.test();
final TestObserver<Integer> to2 = source.test();

Runnable r1 = to1::dispose;

Runnable r2 = to2::dispose;

TestHelper.race(r1, r2);
}
}

@Test
public void doubleDispose() {
PublishProcessor<Integer> pp = PublishProcessor.create();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Integer> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer> 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);
}
}
}
Loading