queue.addTask(new ScheduledTaskImpl(100));
queue.getNextTask(true);
}
@Test public void addAndConsumeTasksDelayed() throws Exception {
SchedulerQueue queue = getQueueInstance();
queue.addTask(new ScheduledTaskImpl(100));
queue.addTask(new ScheduledTaskImpl(100));
queue.addTask(new ScheduledTaskImpl(120));
queue.addTask(new ScheduledTaskImpl(110));
Thread.sleep(200);
assertNotNull(queue.getNextTask(false));
assertNotNull(queue.getNextTask(false));
assertNotNull(queue.getNextTask(false));
assertNotNull(queue.getNextTask(false));
assertNull(queue.getNextTask(false));
queue.addTask(new ScheduledTaskImpl(100));
queue.addTask(new ScheduledTaskImpl(100));
queue.addTask(new ScheduledTaskImpl(120));
queue.addTask(new ScheduledTaskImpl(110));
queue.addTask(new ScheduledTaskImpl(150));
LinkedList<ScheduledTask> tasks = new LinkedList<ScheduledTask>();
assertEquals(0, queue.getNextTasks(tasks, 5));
Thread.sleep(200);
assertEquals(3, queue.getNextTasks(tasks, 3));
assertEquals(2, queue.getNextTasks(tasks, 3));
}