use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class ResourceSingleObserverTest method onErrorCleansUp.
@Test
public void onErrorCleansUp() {
TestResourceSingleObserver<Integer> rso = new TestResourceSingleObserver<Integer>();
assertFalse(rso.isDisposed());
Disposable d = Disposables.empty();
rso.add(d);
assertFalse(d.isDisposed());
rso.onError(new TestException());
assertTrue(rso.isDisposed());
assertTrue(d.isDisposed());
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class ResourceCompletableObserverTest method dispose.
@Test
public void dispose() {
TestResourceCompletableObserver rco = new TestResourceCompletableObserver();
rco.dispose();
Disposable d = Disposables.empty();
rco.onSubscribe(d);
assertTrue(d.isDisposed());
assertEquals(0, rco.start);
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class ResourceCompletableObserverTest method startOnce.
@Test
public void startOnce() {
List<Throwable> error = TestHelper.trackPluginErrors();
try {
TestResourceCompletableObserver rco = new TestResourceCompletableObserver();
rco.onSubscribe(Disposables.empty());
Disposable d = Disposables.empty();
rco.onSubscribe(d);
assertTrue(d.isDisposed());
assertEquals(1, rco.start);
TestHelper.assertError(error, 0, IllegalStateException.class, "Disposable already set!");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class SchedulerTest method defaultPeriodicTask.
@Test
public void defaultPeriodicTask() {
final int[] count = { 0 };
TestScheduler scheduler = new TestScheduler();
Disposable d = scheduler.schedulePeriodicallyDirect(new Runnable() {
@Override
public void run() {
count[0]++;
}
}, 100, 100, TimeUnit.MILLISECONDS);
assertEquals(0, count[0]);
assertFalse(d.isDisposed());
scheduler.advanceTimeBy(200, TimeUnit.MILLISECONDS);
assertEquals(2, count[0]);
d.dispose();
assertTrue(d.isDisposed());
scheduler.advanceTimeBy(200, TimeUnit.MILLISECONDS);
assertEquals(2, count[0]);
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class SchedulerTest method periodicDirectTaskRaceIO.
@Test
public void periodicDirectTaskRaceIO() throws Exception {
final Scheduler scheduler = Schedulers.io();
for (int i = 0; i < 100; i++) {
final Disposable d = scheduler.schedulePeriodicallyDirect(Functions.EMPTY_RUNNABLE, 0, 0, TimeUnit.MILLISECONDS);
Thread.sleep(1);
d.dispose();
}
}
Aggregations