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,35 @@
/*
* 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.disposables;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Isolated;

import io.reactivex.rxjava4.core.RxJavaTest;
import io.reactivex.rxjava4.testsupport.TestHelper;

@Isolated
public class DisposableIsolatedTest extends RxJavaTest {

@Test
public void disposeRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final Disposable d = Disposable.empty();

Runnable r = d::dispose;

TestHelper.race(r, r);
}
}
}
11 changes: 0 additions & 11 deletions src/test/java/io/reactivex/rxjava4/disposables/DisposableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@ public void fromActionThrows() {

}

@Test
public void disposeRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final Disposable d = Disposable.empty();

Runnable r = d::dispose;

TestHelper.race(r, r);
}
}

@Test
public void fromSubscriptionNull() {
assertThrows(NullPointerException.class, () -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.disposables;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.concurrent.atomic.AtomicInteger;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.parallel.Isolated;

import io.reactivex.rxjava4.core.RxJavaTest;
import io.reactivex.rxjava4.functions.Cancellable;
import io.reactivex.rxjava4.testsupport.TestHelper;

@Isolated
public class CancellableDisposableIsolatedTest extends RxJavaTest {

@Test
public void disposeRace() {

for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final AtomicInteger count = new AtomicInteger();

Cancellable c = count::getAndIncrement;

final CancellableDisposable cd = new CancellableDisposable(c);

Runnable r = cd::dispose;

TestHelper.race(r, r);

assertEquals(1, count.get());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,4 @@ public void cancelThrows() {
assertEquals(1, count.get());
}

@Test
public void disposeRace() {

for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final AtomicInteger count = new AtomicInteger();

Cancellable c = count::getAndIncrement;

final CancellableDisposable cd = new CancellableDisposable(c);

Runnable r = cd::dispose;

TestHelper.race(r, r);

assertEquals(1, count.get());
}
}

}
Loading