use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class ResourceObserverTest method addResources.
@Test
public void addResources() {
TestResourceObserver<Integer> ro = new TestResourceObserver<Integer>();
assertFalse(ro.isDisposed());
Disposable d = Disposables.empty();
ro.add(d);
assertFalse(d.isDisposed());
ro.dispose();
assertTrue(ro.isDisposed());
assertTrue(d.isDisposed());
ro.dispose();
assertTrue(ro.isDisposed());
assertTrue(d.isDisposed());
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class ResourceObserverTest method onErrorCleansUp.
@Test
public void onErrorCleansUp() {
TestResourceObserver<Integer> ro = new TestResourceObserver<Integer>();
assertFalse(ro.isDisposed());
Disposable d = Disposables.empty();
ro.add(d);
assertFalse(d.isDisposed());
ro.onError(new TestException());
assertTrue(ro.isDisposed());
assertTrue(d.isDisposed());
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class ResourceObserverTest method dispose.
@Test
public void dispose() {
TestResourceObserver<Integer> tc = new TestResourceObserver<Integer>();
tc.dispose();
Disposable d = Disposables.empty();
tc.onSubscribe(d);
assertTrue(d.isDisposed());
assertEquals(0, tc.start);
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class ResourceSingleObserverTest method onSuccessCleansUp.
@Test
public void onSuccessCleansUp() {
TestResourceSingleObserver<Integer> rso = new TestResourceSingleObserver<Integer>();
assertFalse(rso.isDisposed());
Disposable d = Disposables.empty();
rso.add(d);
assertFalse(d.isDisposed());
rso.onSuccess(1);
assertTrue(rso.isDisposed());
assertTrue(d.isDisposed());
}
use of io.reactivex.disposables.Disposable in project RxJava by ReactiveX.
the class ResourceSingleObserverTest method startOnce.
@Test
public void startOnce() {
List<Throwable> error = TestHelper.trackPluginErrors();
try {
TestResourceSingleObserver<Integer> rso = new TestResourceSingleObserver<Integer>();
rso.onSubscribe(Disposables.empty());
Disposable d = Disposables.empty();
rso.onSubscribe(d);
assertTrue(d.isDisposed());
assertEquals(1, rso.start);
TestHelper.assertError(error, 0, IllegalStateException.class, "Disposable already set!");
} finally {
RxJavaPlugins.reset();
}
}
Aggregations