use of io.reactivex.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class ScheduledRunnableTest method crashReported.
@Test
public void crashReported() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
CompositeDisposable set = new CompositeDisposable();
final ScheduledRunnable run = new ScheduledRunnable(new Runnable() {
@Override
public void run() {
throw new TestException("First");
}
}, set);
set.add(run);
run.run();
assertTrue(run.isDisposed());
assertEquals(0, set.size());
TestHelper.assertUndeliverable(errors, 0, TestException.class, "First");
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class ScheduledRunnableTest method disposeRun.
@Test
public void disposeRun() {
CompositeDisposable set = new CompositeDisposable();
ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, set);
set.add(run);
assertFalse(run.isDisposed());
run.dispose();
run.dispose();
assertTrue(run.isDisposed());
}
use of io.reactivex.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class ScheduledRunnableTest method pluginCrash.
@Test
public void pluginCrash() {
Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
throw new TestException("Second");
}
});
CompositeDisposable set = new CompositeDisposable();
final ScheduledRunnable run = new ScheduledRunnable(new Runnable() {
@Override
public void run() {
throw new TestException("First");
}
}, set);
set.add(run);
try {
run.run();
fail("Should have thrown!");
} catch (TestException ex) {
assertEquals("Second", ex.getMessage());
} finally {
Thread.currentThread().setUncaughtExceptionHandler(null);
}
assertTrue(run.isDisposed());
assertEquals(0, set.size());
}
use of io.reactivex.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class ScheduledRunnableTest method setFutureRunRace.
@Test
public void setFutureRunRace() {
for (int i = 0; i < 500; i++) {
CompositeDisposable set = new CompositeDisposable();
final ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, set);
set.add(run);
final FutureTask<Object> ft = new FutureTask<Object>(Functions.EMPTY_RUNNABLE, 0);
Runnable r1 = new Runnable() {
@Override
public void run() {
run.setFuture(ft);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
run.run();
}
};
TestHelper.race(r1, r2);
assertEquals(0, set.size());
}
}
use of io.reactivex.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class ScheduledRunnableTest method disposeRace.
@Test
public void disposeRace() {
for (int i = 0; i < 500; i++) {
CompositeDisposable set = new CompositeDisposable();
final ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, set);
set.add(run);
Runnable r1 = new Runnable() {
@Override
public void run() {
run.dispose();
}
};
TestHelper.race(r1, r1);
assertEquals(0, set.size());
}
}
Aggregations