@Test
public void testRemove() {

    TestTask task1 = new TestTask();
    TestTask task2 = new TestTask();
    TestTask task3 = new TestTask();
    scheduler.add(task1, 20);
    scheduler.add(task2, 10);
    scheduler.add(task3, 30);
    scheduler.add(task1, 40);
    assertEquals(10, scheduler.nextTimeout(0));
    scheduler.remove(task2);
    assertEquals(20, scheduler.nextTimeout(0));
    scheduler.remove(task1);
    assertEquals(30, scheduler.nextTimeout(0));
    scheduler.remove(task3);
    assertEquals(Long.MAX_VALUE, scheduler.nextTimeout(0));
}