*
* @throws InterruptedException
*/
@Test
public void testTodoTaskSuccess() throws InterruptedException {
final Task t = new Task();
t.setStatus(TaskConsumer.STATUS_TODO);
final List<Task> taskList = new ArrayList<Task>();
taskList.add(t);
final TaskConsumerWrap consumer = new TaskConsumerWrap() {
@Override
protected boolean updateTodoToDoing(Task todo) {
super.updateTodoToDoing(todo);
return true;
}
@Override
protected boolean processTask(Task doing) {
super.processTask(doing);
return true;
}
@Override
protected boolean updateDoingToDone(Task doing) {
super.updateDoingToDone(doing);
t.setStatus(TaskConsumer.STATUS_DONE);
return true;
}
@Override
protected Task findTodoTask() {
super.findTodoTask();
return taskList.size() == 0 ? null : taskList.remove(0);
}
};
new Thread(consumer).start();
while (!consumer.isStopped()) {
Thread.sleep(10);
}
Assert.assertEquals("[1, 8, 7, 10, 3, 1, 8, 4]", Arrays.toString(consumer.replayer.toArray()));
Assert.assertEquals(TaskConsumer.STATUS_DONE, t.getStatus());
}