private Task getCompletedTask(DN taskEntryDN)
throws Exception
{
TaskBackend taskBackend =
(TaskBackend) DirectoryServer.getBackend(DN.decode("cn=tasks"));
Task task = taskBackend.getScheduledTask(taskEntryDN);
if (task == null)
{
long stopWaitingTime = System.currentTimeMillis() + 10000L;
while ((task == null) && (System.currentTimeMillis() < stopWaitingTime))
{
Thread.sleep(10);
task = taskBackend.getScheduledTask(taskEntryDN);
}
}
if (task == null)
{
throw new AssertionError("There is no such task " +
taskEntryDN.toString());
}
if (! TaskState.isDone(task.getTaskState()))
{
long stopWaitingTime = System.currentTimeMillis() + 20000L;
while ((! TaskState.isDone(task.getTaskState())) &&
(System.currentTimeMillis() < stopWaitingTime))
{
Thread.sleep(10);
}
}
if (! TaskState.isDone(task.getTaskState()))
{
throw new AssertionError("Task " + taskEntryDN.toString() +
" did not complete in a timely manner.");
}