Search in sources :

Example 1 with JobExecutor

use of com.evolveum.midpoint.task.quartzimpl.run.JobExecutor in project midpoint by Evolveum.

the class TestTaskManagerBasic method test260LightweightSubtasksSuspension.

@Test
public void test260LightweightSubtasksSuspension() throws Exception {
    given();
    OperationResult result = createOperationResult();
    when();
    add(TASK_WITH_THREADS_TO_SUSPEND, result);
    waitForTaskStart(TASK_WITH_THREADS_TO_SUSPEND.oid, result, 15000, 500);
    TaskQuartzImpl task = getTaskWithResult(TASK_WITH_THREADS_TO_SUSPEND.oid, result);
    displayDumpable("taskAfterStart", task);
    // assertEquals(TaskExecutionStateType.RUNNING, task.getExecutionState()); // todo
    assertEquals(TaskSchedulingStateType.READY, task.getSchedulingState());
    // check the thread
    JobExecutionContext found = findJobForTask(task);
    JobExecutor executor = (JobExecutor) found.getJobInstance();
    assertNotNull("No job executor", executor);
    Thread thread = executor.getExecutingThread();
    assertNotNull("No executing thread", thread);
    // now let us suspend it - the handler should stop, as well as the subtasks
    boolean stopped = taskManager.suspendTask(task, 10000L, result);
    then();
    task.refresh(result);
    assertTrue("Task is not stopped", stopped);
    assertSuspended(task);
    Collection<? extends RunningLightweightTask> subtasks = mockParallelTaskHandler.getLastTaskExecuted().getLightweightAsynchronousSubtasks();
    assertEquals("Wrong number of subtasks", MockParallelTaskHandler.NUM_SUBTASKS, subtasks.size());
    for (RunningLightweightTask subtask : subtasks) {
        assertEquals("Wrong subtask state", TaskExecutionStateType.CLOSED, subtask.getExecutionState());
        MockParallelTaskHandler.MyLightweightTaskHandler handler = (MockParallelTaskHandler.MyLightweightTaskHandler) subtask.getLightweightTaskHandler();
        assertTrue("Handler has not run", handler.hasRun());
        assertTrue("Handler has not exited", handler.hasExited());
    }
}
Also used : JobExecutor(com.evolveum.midpoint.task.quartzimpl.run.JobExecutor) RunningLightweightTask(com.evolveum.midpoint.task.api.RunningLightweightTask) JobExecutionContext(org.quartz.JobExecutionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 RunningLightweightTask (com.evolveum.midpoint.task.api.RunningLightweightTask)1 JobExecutor (com.evolveum.midpoint.task.quartzimpl.run.JobExecutor)1 JobExecutionContext (org.quartz.JobExecutionContext)1 Test (org.testng.annotations.Test)1