Package org.japura.task

Examples of org.japura.task.Task


  Assert.assertEquals(task.hashCode(), task.getId().hashCode());
  }

  @Test
  public void equals() {
  Task task = new Task();
  Task task2 = new Task();
  Assert.assertEquals(false, task.equals(null));
  Assert.assertEquals(false, task.equals(""));
  Assert.assertEquals(false, task.equals(task2));
  Assert.assertEquals(true, task.equals(task));
  }
View Full Code Here


  Assert.assertEquals(true, task.equals(task));
  }

  @Test
  public void initialValues() {
  Task task = new Task();
  Assert.assertEquals(0, task.getBackgroundTimeSpent());
  Assert.assertNull(task.getOwner());
  Assert.assertNull(task.getMessage());
  Assert.assertNull(task.getParentId());
  Assert.assertNull(task.getTaskExecutionUI());
  Assert.assertNull(task.getException());
  Assert.assertEquals("", task.getName());
  Assert.assertEquals(false, task.isWaitForEDT());
  }
View Full Code Here

  Assert.assertEquals(false, task.isWaitForEDT());
  }

  @Test
  public void extra() {
  Task task = new Task();
  task.canceled(new TaskSession());
  Assert.assertNotNull(task.toString());
  }
View Full Code Here

  Assert.assertNotNull(task.toString());
  }

  @Test
  public void changingMessage() {
  Task task = new Task();
  task.setMessage("message");
  Assert.assertNotNull(task.getMessage());
  Assert.assertEquals("message", task.getMessage());
  }
View Full Code Here

  Assert.assertEquals("message", task.getMessage());
  }

  @Test
  public void changingWaitForEDT() {
  Task task = new Task();
  task.setWaitForEDT(true);
  Assert.assertEquals(true, task.isWaitForEDT());
  }
View Full Code Here

    // TODO f
    throw new TaskExeception("");
  }
  int index = queueTasks.size() - 1;
  while (index > -1) {
    Task qt = queueTasks.get(index);
    if (qt.getParentId() != null
      && qt.getParentId().equals(task.getParentId())) {
    break;
    }
    index--;
  }
  queueTasks.add(index + 1, task);
View Full Code Here

  Assert.assertEquals(true, task.isWaitForEDT());
  }

  @Test
  public void changingUI() {
  Task task = new Task();
  TaskExecutionUI ui = new TaskExecutionUIFake();
  task.setTaskExecutionUI(ui);
  Assert.assertNotNull(task.getTaskExecutionUI());
  Assert.assertEquals(ui, task.getTaskExecutionUI());
  }
View Full Code Here

  @Override
  public void run() {
  String previousTaskId = null;
  while (queueTasks.size() > 0) {
    Task task = queueTasks.remove(0);

    runCount++;

    fireBefore(task);

    if (this.cancelToken.isCanceled()) {
    task.cancel();
    }

    run(task);

    // TODO exception, tratar

    fireAfter(task);

    Application.getMessageManager().publish(
      false,
      new TaskExecutionMessage(false, getTaskSession(), task,
        previousTaskId));

    previousTaskId = task.getId();

    Collection<Task> discardedTasks = new ArrayList<Task>();
    if (task.getStatus().equals(TaskStatus.ERROR)) {
    for (Task otherTask : queueTasks) {
      otherTask.registerStatus(TaskStatus.DISCARDED);
      discardedTasks.add(otherTask);
    }
    queueTasks.clear();
    runCount += discardedTasks.size();
    for (Task discardedTask : discardedTasks) {
      fireBefore(discardedTask);
      fireAfter(discardedTask);
      Application.getMessageManager().publish(
        false,
        new TaskEventMessage(discardedTask, getTaskSession(),
          TaskEventType.DISCARDED));
      Application.getMessageManager().publish(
        false,
        new TaskExecutionMessage(false, getTaskSession(), discardedTask,
          previousTaskId));
      previousTaskId = discardedTask.getId();
    }
    }

    Runnable runnable = buildRunnable(task, discardedTasks);

    if (runnable == null) {
    return;
    }

    if (Application.getTaskManager().invokeTaskMethodsOnEDT()) {
    if (task.isWaitForEDT()) {
      try {
      SwingUtilities.invokeAndWait(runnable);
      } catch (InterruptedException e) {
      e.printStackTrace();
      } catch (InvocationTargetException e) {
View Full Code Here

  Assert.assertEquals(ui, task.getTaskExecutionUI());
  }

  @Test
  public void registeringOwner1() {
  Task task = new Task();
  TaskExecutorFake executor = new TaskExecutorFake();
  task.registerOwner(executor);
  Assert.assertNotNull(task.getOwner());
  Assert.assertEquals(executor, task.getOwner());
  }
View Full Code Here

  }

  @Test
  public void registeringOwner2() {
  thrown.expect(TaskExeception.class);
  Task task = new Task();
  task.registerOwner(null);
  }
View Full Code Here

TOP

Related Classes of org.japura.task.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.