use of ubic.gemma.core.job.progress.ProgressData in project Gemma by PavlidisLab.
the class TaskRunningTest method testFailedRun.
@Test
public final void testFailedRun() throws Exception {
// goes to the progress page...handleRequest
TaskCommand taskCommand = new TaskCommand();
// we use this for 'die' in this test.
taskCommand.setPersistJobDetails(false);
String taskId = mockLongJobController.runJob(taskCommand);
assertNotNull(taskId);
// wait for job to run
ProgressData lastResult = null;
long timeout = 5000;
long startTime = System.currentTimeMillis();
wait: while (true) {
Thread.sleep(500);
List<ProgressData> result = progressStatusService.getProgressStatus(taskId);
if (result.size() > 0) {
for (ProgressData lr : result) {
lastResult = lr;
if (lr.isFailed()) {
// yay
return;
}
if (lr.isDone())
break wait;
}
}
log.info("Waiting ..");
if (System.currentTimeMillis() - startTime > timeout)
fail("Test timed out");
}
assertNotNull(lastResult);
assertTrue(lastResult.isFailed());
}
use of ubic.gemma.core.job.progress.ProgressData in project Gemma by PavlidisLab.
the class TaskRunningTest method testSuccessfulRun.
@Test
public final void testSuccessfulRun() throws Exception {
TaskCommand taskCommand = new TaskCommand();
String taskId = mockLongJobController.runJob(taskCommand);
// wait for job to run
long timeout = 5000;
ProgressData lastResult = null;
long startTime = System.currentTimeMillis();
wait: while (true) {
Thread.sleep(500);
List<ProgressData> result = progressStatusService.getProgressStatus(taskId);
if (result.size() > 0) {
for (ProgressData lr : result) {
lastResult = lr;
if (lr.isDone())
break wait;
}
}
log.info("Waiting ..");
if (System.currentTimeMillis() - startTime > timeout)
fail("Test timed out");
}
assertNotNull(lastResult);
assertTrue(!lastResult.isFailed());
}
Aggregations