@Test
public void dispose() throws Exception {

    ExecutorService exec = Executors.newSingleThreadExecutor();
    try {
        InstantPeriodicTask task = new InstantPeriodicTask(new Runnable() {
            @Override
            public void run() {
                throw new TestException();
            }
        }, exec);
        assertFalse(task.isDisposed());
        task.dispose();
        assertTrue(task.isDisposed());
        task.dispose();
        assertTrue(task.isDisposed());
    } finally {
        exec.shutdownNow();
        RxJavaPlugins.reset();
    }
}