コード例 #1
0
 // Run this test twice to demonstrate we're not leaking state across tests.
 // If we _are_ leaking state across tests we'll get an exception on the
 // second test because there will already be a task with the given name.
 private void doTest() throws InterruptedException {
   QueueFactory.getDefaultQueue().add(TaskOptions.Builder.withTaskName("task29"));
   // Give the task time to execute if tasks are actually enabled (which they
   // aren't, but that's part of the test).
   Thread.sleep(1000);
   LocalTaskQueue ltq = LocalTaskQueueTestConfig.getLocalTaskQueue();
   QueueStateInfo qsi = ltq.getQueueStateInfo().get(QueueFactory.getDefaultQueue().getQueueName());
   assertEquals(1, qsi.getTaskInfo().size());
   assertEquals("task29", qsi.getTaskInfo().get(0).getTaskName());
 }
コード例 #2
0
 private void executeTasksUntilEmpty(String queueName) throws Exception {
   while (true) {
     // We have to reacquire task list every time, because local implementation returns a copy.
     List<TaskStateInfo> taskInfo = taskQueue.getQueueStateInfo().get(queueName).getTaskInfo();
     if (taskInfo.isEmpty()) {
       break;
     }
     TaskStateInfo taskStateInfo = taskInfo.get(0);
     taskQueue.deleteTask(queueName, taskStateInfo.getTaskName());
     executeTask(queueName, taskStateInfo);
   }
 }