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,42 @@
/*
* 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.Maybe;
import io.reactivex.rxjava4.core.RxJavaTest;
import io.reactivex.rxjava4.observers.TestObserver;
import io.reactivex.rxjava4.processors.PublishProcessor;
import io.reactivex.rxjava4.testsupport.TestHelper;

@Isolated
public class MaybeSwitchIfEmptyIsolatedTest extends RxJavaTest {

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

final TestObserver<Integer> to = pp.singleElement().switchIfEmpty(Maybe.just(2)).test();

Runnable r1 = pp::onComplete;

Runnable r2 = to::dispose;

TestHelper.race(r1, r2);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.RxJavaTest;
import io.reactivex.rxjava4.core.Single;
import io.reactivex.rxjava4.observers.TestObserver;
import io.reactivex.rxjava4.processors.PublishProcessor;
import io.reactivex.rxjava4.testsupport.TestHelper;

@Isolated
public class MaybeSwitchIfEmptySingleIsolatedTest extends RxJavaTest {

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

final TestObserver<Integer> to = pp.singleElement().switchIfEmpty(Single.just(2)).test();

Runnable r1 = pp::onComplete;

Runnable r2 = to::dispose;

TestHelper.race(r1, r2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,6 @@ public void doubleOnSubscribe() {
TestHelper.checkDoubleOnSubscribeMaybeToSingle((Function<Maybe<Integer>, Single<Integer>>) f -> f.switchIfEmpty(Single.just(2)));
}

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

final TestObserver<Integer> to = pp.singleElement().switchIfEmpty(Single.just(2)).test();

Runnable r1 = pp::onComplete;

Runnable r2 = to::dispose;

TestHelper.race(r1, r2);
}
}

@SuppressWarnings("rawtypes")
@Test
public void source() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,4 @@ public void isDisposed() {
public void doubleOnSubscribe() {
TestHelper.checkDoubleOnSubscribeMaybe((Function<Maybe<Integer>, Maybe<Integer>>) f -> f.switchIfEmpty(Maybe.just(2)));
}

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

final TestObserver<Integer> to = pp.singleElement().switchIfEmpty(Maybe.just(2)).test();

Runnable r1 = pp::onComplete;

Runnable r2 = to::dispose;

TestHelper.race(r1, r2);
}
}
}
Loading