Java源码示例:org.activiti.engine.runtime.Job
示例1
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialCallActivityWithTimer.bpmn20.xml",
"org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testSequentialCallActivityWithTimer() {
String procId = runtimeService.startProcessInstanceByKey("miSequentialCallActivityWithTimer").getId();
// Complete first subprocess
List<Task> tasks = taskService.createTaskQuery().orderByTaskName().asc().list();
assertEquals(2, tasks.size());
assertEquals("task one", tasks.get(0).getName());
assertEquals("task two", tasks.get(1).getName());
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
// Fire timer
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
Task taskAfterTimer = taskService.createTaskQuery().singleResult();
assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
taskService.complete(taskAfterTimer.getId());
assertProcessEnded(procId);
}
示例2
@Deployment
public void testParallelSubProcessWithTimer() {
String procId = runtimeService.startProcessInstanceByKey("miParallelSubprocessWithTimer").getId();
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(6, tasks.size());
// Complete two tasks
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
// Fire timer
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
Task taskAfterTimer = taskService.createTaskQuery().singleResult();
assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
taskService.complete(taskAfterTimer.getId());
assertProcessEnded(procId);
}
示例3
@Deployment
public void testCycleTimer() {
List<Job> jobs = this.managementService.createTimerJobQuery().list();
assertThat("One job is scheduled", jobs.size(), is(1));
assertThat("Job must be scheduled by custom business calendar to Date(0)", jobs.get(0).getDuedate(), is(new Date(0)));
managementService.moveTimerToExecutableJob(jobs.get(0).getId());
managementService.executeJob(jobs.get(0).getId());
jobs = this.managementService.createTimerJobQuery().list();
assertThat("One job is scheduled (repetition is 2x)", jobs.size(), is(1));
assertThat("Job must be scheduled by custom business calendar to Date(0)", jobs.get(0).getDuedate(), is(new Date(0)));
managementService.moveTimerToExecutableJob(jobs.get(0).getId());
managementService.executeJob(jobs.get(0).getId());
jobs = this.managementService.createTimerJobQuery().list();
assertThat("There must be no job.", jobs.isEmpty());
}
示例4
@Deployment
public void testTimerOnConcurrentTasks() {
String procId = runtimeService.startProcessInstanceByKey("nonInterruptingOnConcurrentTasks").getId();
assertEquals(2, taskService.createTaskQuery().count());
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
assertEquals(3, taskService.createTaskQuery().count());
// Complete task that was reached by non interrupting timer
Task task = taskService.createTaskQuery().taskDefinitionKey("timerFiredTask").singleResult();
taskService.complete(task.getId());
assertEquals(2, taskService.createTaskQuery().count());
// Complete other tasks
for (Task t : taskService.createTaskQuery().list()) {
taskService.complete(t.getId());
}
assertProcessEnded(procId);
}
示例5
@Deployment(resources = { "org/activiti5/engine/test/bpmn/multiinstance/MultiInstanceTest.testSequentialCallActivityWithTimer.bpmn20.xml",
"org/activiti5/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testSequentialCallActivityWithTimer() {
String procId = runtimeService.startProcessInstanceByKey("miSequentialCallActivityWithTimer").getId();
// Complete first subprocess
List<Task> tasks = taskService.createTaskQuery().orderByTaskName().asc().list();
assertEquals(2, tasks.size());
assertEquals("task one", tasks.get(0).getName());
assertEquals("task two", tasks.get(1).getName());
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
// Fire timer
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
Task taskAfterTimer = taskService.createTaskQuery().singleResult();
assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
taskService.complete(taskAfterTimer.getId());
assertProcessEnded(procId);
}
示例6
@ApiOperation(value = "Get the exception stacktrace for a deadletter job", tags = {"Jobs"})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indicates the requested job was not found and the stacktrace has been returned. The response contains the raw stacktrace and always has a Content-type of text/plain."),
@ApiResponse(code = 404, message = "Indicates the requested job was not found or the job doesn’t have an exception stacktrace. Status-description contains additional information about the error.")
})
@RequestMapping(value = "/management/deadletter-jobs/{jobId}/exception-stacktrace", method = RequestMethod.GET)
public String getDeadLetterJobStacktrace(@ApiParam(name = "jobId") @PathVariable String jobId, HttpServletResponse response) {
Job job = managementService.createDeadLetterJobQuery().jobId(jobId).singleResult();
if (job == null) {
throw new ActivitiObjectNotFoundException("Could not find a job with id '" + jobId + "'.", Job.class);
}
String stackTrace = managementService.getDeadLetterJobExceptionStacktrace(job.getId());
if (stackTrace == null) {
throw new ActivitiObjectNotFoundException("Suspended job with id '" + job.getId() + "' doesn't have an exception stacktrace.", String.class);
}
response.setContentType("text/plain");
return stackTrace;
}
示例7
@Deployment
public void testInterruptingBoundaryEvent() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("deleteReasonProcess");
Task task = taskService.createTaskQuery().singleResult();
assertEquals("A", task.getName());
taskService.complete(task.getId());
// Timer firing should delete all tasks
Job timerJob = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timerJob.getId());
managementService.executeJob(timerJob.getId());
assertHistoricTasksDeleteReason(processInstance, null, "A");
assertHistoricTasksDeleteReason(processInstance, DeleteReason.BOUNDARY_EVENT_INTERRUPTING, "B", "C", "D");
assertHistoricActivitiesDeleteReason(processInstance, null, "A");
assertHistoricActivitiesDeleteReason(processInstance, DeleteReason.BOUNDARY_EVENT_INTERRUPTING, "B", "C", "D", "theSubprocess");
}
示例8
@Deployment(resources = { "org/activiti/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testSetJobRetries() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exceptionInJobExecution");
// The execution is waiting in the first usertask. This contains a boundary timer event.
Job timerJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
Date duedate = timerJob.getDuedate();
assertNotNull("No job found for process instance", timerJob);
assertEquals(processEngineConfiguration.getAsyncExecutorNumberOfRetries(), timerJob.getRetries());
managementService.setTimerJobRetries(timerJob.getId(), 5);
timerJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals(5, timerJob.getRetries());
assertEquals(duedate, timerJob.getDuedate());
}
示例9
protected JobEntity getJobToDelete(CommandContext commandContext) {
if (jobId == null) {
throw new ActivitiIllegalArgumentException("jobId is null");
}
if (log.isDebugEnabled()) {
log.debug("Deleting job {}", jobId);
}
JobEntity job = commandContext.getJobEntityManager().findById(jobId);
if (job == null) {
throw new ActivitiObjectNotFoundException("No job found with id '" + jobId + "'", Job.class);
}
// We need to check if the job was locked, ie acquired by the job acquisition thread
// This happens if the the job was already acquired, but not yet executed.
// In that case, we can't allow to delete the job.
if (job.getLockOwner() != null) {
throw new ActivitiException("Cannot delete job when the job is being executed. Try again later.");
}
return job;
}
示例10
@Deployment(resources = {"org/activiti5/engine/test/bpmn/event/timer/BoundaryTimerNonInterruptingEventTest.testTimerOnConcurrentTasks.bpmn20.xml"})
public void testTimerOnConcurrentTasks2() {
String procId = runtimeService.startProcessInstanceByKey("nonInterruptingOnConcurrentTasks").getId();
assertEquals(2, taskService.createTaskQuery().count());
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
assertEquals(3, taskService.createTaskQuery().count());
// Complete 2 tasks that will trigger the join
Task task = taskService.createTaskQuery().taskDefinitionKey("firstTask").singleResult();
taskService.complete(task.getId());
task = taskService.createTaskQuery().taskDefinitionKey("secondTask").singleResult();
taskService.complete(task.getId());
assertEquals(1, taskService.createTaskQuery().count());
// Finally, complete the task that was created due to the timer
task = taskService.createTaskQuery().taskDefinitionKey("timerFiredTask").singleResult();
taskService.complete(task.getId());
assertProcessEnded(procId);
}
示例11
@Deployment
public void testParallelUserTasksWithTimer() {
String procId = runtimeService.startProcessInstanceByKey("miParallelUserTasksWithTimer").getId();
List<Task> tasks = taskService.createTaskQuery().list();
taskService.complete(tasks.get(0).getId());
// Fire timer
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
Task taskAfterTimer = taskService.createTaskQuery().singleResult();
assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
taskService.complete(taskAfterTimer.getId());
assertProcessEnded(procId);
}
示例12
@Deployment(resources = "org/activiti5/engine/test/api/event/JobEventsTest.testJobEntityEvents.bpmn20.xml")
public void testActivityTimeOutEvent(){
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testJobEvents");
Job theJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(theJob);
// Force timer to fire
Calendar tomorrow = Calendar.getInstance();
tomorrow.add(Calendar.DAY_OF_YEAR, 1);
processEngineConfiguration.getClock().setCurrentTime(tomorrow.getTime());
waitForJobExecutorToProcessAllJobsAndExecutableTimerJobs(2000, 100);
// Check timeout has been dispatched
assertEquals(1, listener.getEventsReceived().size());
ActivitiEvent activitiEvent = listener.getEventsReceived().get(0);
assertEquals("ACTIVITY_CANCELLED event expected", ActivitiEventType.ACTIVITY_CANCELLED, activitiEvent.getType());
ActivitiActivityCancelledEvent cancelledEvent = (ActivitiActivityCancelledEvent) activitiEvent;
assertTrue("TIMER is the cause of the cancellation", cancelledEvent.getCause() instanceof JobEntity);
}
示例13
@ApiOperation(value = "Get the exception stacktrace for a job", tags = {"Jobs"})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Indicates the requested job was not found and the stacktrace has been returned. The response contains the raw stacktrace and always has a Content-type of text/plain."),
@ApiResponse(code = 404, message = "Indicates the requested job was not found or the job doesn’t have an exception stacktrace. Status-description contains additional information about the error.")
})
@RequestMapping(value = "/management/jobs/{jobId}/exception-stacktrace", method = RequestMethod.GET)
public String getJobStacktrace(@ApiParam(name = "jobId", value="Id of the job to get the stacktrace for.") @PathVariable String jobId, HttpServletResponse response) {
Job job = managementService.createJobQuery().jobId(jobId).singleResult();
if (job == null) {
throw new ActivitiObjectNotFoundException("Could not find a job with id '" + jobId + "'.", Job.class);
}
String stackTrace = managementService.getJobExceptionStacktrace(job.getId());
if (stackTrace == null) {
throw new ActivitiObjectNotFoundException("Job with id '" + job.getId() + "' doesn't have an exception stacktrace.", String.class);
}
response.setContentType("text/plain");
return stackTrace;
}
示例14
private ProcessInstance startProcessInstanceWithFailingJob(String processInstanceByKey) {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processInstanceByKey);
List<Job> jobList = managementService.createJobQuery()
.processInstanceId(processInstance.getId())
.list();
for(Job job : jobList){
try {
managementService.executeJob(job.getId());
fail("RuntimeException");
} catch(RuntimeException re) {
}
}
return processInstance;
}
示例15
public void testTimerRestoreOnDeploymentDelete2() {
String deploymentId1 = deployTimerProcess();
String deploymentId2 = deployProcessWithoutTimers(); // Process has same key
String deploymentId3 = deployTimerProcess();
String deploymentId4 = deployProcessWithoutTimers();
assertTimerJobs(0);
repositoryService.deleteDeployment(deploymentId3, true);
assertTimerJobs(0);
repositoryService.deleteDeployment(deploymentId2, true);
assertTimerJobs(0);
repositoryService.deleteDeployment(deploymentId4, true);
assertTimerJobs(1);
Job job = managementService.createTimerJobQuery().singleResult();
assertEquals(repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId1).singleResult().getId(), job.getProcessDefinitionId());
cleanup(deploymentId1);
}
示例16
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.sequentialUserTasks.bpmn20.xml" })
public void testSequentialUserTasksWithTimer() {
String procId = runtimeService.startProcessInstanceByKey("miSequentialUserTasks", CollectionUtil.singletonMap(NR_OF_LOOPS_KEY, 3)).getId();
// Complete 1 tasks
taskService.complete(taskService.createTaskQuery().singleResult().getId());
// Fire timer
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
Task taskAfterTimer = taskService.createTaskQuery().singleResult();
assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
taskService.complete(taskAfterTimer.getId());
assertProcessEnded(procId);
}
示例17
@Deployment(resources={"org/activiti5/engine/test/db/oneJobProcess.bpmn20.xml"})
public void testJobsNotVisisbleToAcquisitionIfInstanceSuspended() {
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance pi = runtimeService.startProcessInstanceByKey(pd.getKey());
// now there is one job:
Job job = managementService.createTimerJobQuery().singleResult();
assertNotNull(job);
makeSureJobDue(job);
// suspend the process instance:
runtimeService.suspendProcessInstanceById(pi.getId());
job = managementService.createTimerJobQuery().singleResult();
assertNull(job);
assertEquals(1, managementService.createSuspendedJobQuery().processInstanceId(pi.getId()).count());
}
示例18
@Deployment
public void testFailingAsyncServiceTimer() {
// start process
runtimeService.startProcessInstanceByKey("asyncService");
// now there should be one job in the database, and it is a message
assertEquals(1, managementService.createJobQuery().count());
Job job = managementService.createJobQuery().singleResult();
if (!JobEntity.JOB_TYPE_MESSAGE.equals(job.getJobType())) {
fail("the job must be a message");
}
try {
managementService.executeJob(job.getId());
fail();
} catch (Exception e) {
// exception expected
}
// the service failed: the execution is still sitting in the service task:
Execution execution = runtimeService.createExecutionQuery().singleResult();
assertNotNull(execution);
assertEquals("service", runtimeService.getActiveActivityIds(execution.getId()).get(0));
// there is still a single job because the timer was created in the same transaction as the
// service was executed (which rolled back)
assertEquals(1, managementService.createTimerJobQuery().count());
runtimeService.deleteProcessInstance(execution.getId(), "dead");
}
示例19
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testNestedSequentialCallActivityWithTimer.bpmn20.xml",
"org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.externalSubProcess.bpmn20.xml" })
public void testNestedSequentialCallActivityWithTimer() {
String procId = runtimeService.startProcessInstanceByKey("miNestedSequentialCallActivityWithTimer").getId();
// first instance
List<Task> tasks = taskService.createTaskQuery().orderByTaskName().asc().list();
assertEquals(2, tasks.size());
assertEquals("task one", tasks.get(0).getName());
assertEquals("task two", tasks.get(1).getName());
taskService.complete(tasks.get(0).getId());
taskService.complete(tasks.get(1).getId());
// one task of second instance
tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
taskService.complete(tasks.get(0).getId());
// Fire timer
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
Task taskAfterTimer = taskService.createTaskQuery().singleResult();
assertEquals("taskAfterTimer", taskAfterTimer.getTaskDefinitionKey());
taskService.complete(taskAfterTimer.getId());
assertProcessEnded(procId);
}
示例20
@Deployment
public void testCustomDurationTimerCalendar() {
ProcessInstance processInstance = this.runtimeService.startProcessInstanceByKey("testCustomDurationCalendar");
List<Job> jobs = this.managementService.createTimerJobQuery().list();
assertThat("One job is scheduled", jobs.size(), is(1));
assertThat("Job must be scheduled by custom business calendar to Date(0)", jobs.get(0).getDuedate(), is(new Date(0)));
this.managementService.moveTimerToExecutableJob(jobs.get(0).getId());
this.managementService.executeJob(jobs.get(0).getId());
waitForJobExecutorToProcessAllJobsAndExecutableTimerJobs(10000, 200);
this.runtimeService.trigger(processInstance.getId());
}
示例21
@Deployment
public void testAct901() {
Clock clock = processEngineConfiguration.getClock();
clock.reset();
Date startTime = clock.getCurrentTime();
processEngineConfiguration.setClock(clock);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("multiInstanceSubProcess");
List<Task> tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).orderByTaskName().asc().list();
clock.setCurrentTime(new Date(startTime.getTime() + 61000L));
processEngineConfiguration.setClock(clock); // timer is set to one minute
List<Job> timers = managementService.createTimerJobQuery().list();
assertEquals(5, timers.size());
// Execute all timers one by one (single thread vs thread pool of job executor, which leads to optimisticlockingexceptions!)
for (Job timer : timers) {
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
}
// All tasks should be canceled
tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).orderByTaskName().asc().list();
assertEquals(0, tasks.size());
processEngineConfiguration.resetClock();
}
示例22
public void testDeleteJobUnexistingJob() {
try {
managementService.deleteJob("unexistingjob");
fail("ActivitiException expected");
} catch (ActivitiObjectNotFoundException ae) {
assertTextPresent("No job found with id", ae.getMessage());
assertEquals(Job.class, ae.getObjectClass());
}
}
示例23
@Override
public boolean executeAsyncJob(Job job) {
logger.info("About to execute job " + job.getId());
counter.incrementAndGet();
boolean success = super.executeAsyncJob(job);
logger.info("Handed off job " + job.getId() + " to async executor (retries=" + job.getRetries() + ")");
return success;
}
示例24
@Deployment
public void testLoop() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testLoop");
// After looping 3 times, the process should end
for (int i = 0; i < 3; i++) {
Job timer = managementService.createTimerJobQuery().singleResult();
managementService.moveTimerToExecutableJob(timer.getId());
managementService.executeJob(timer.getId());
}
assertProcessEnded(processInstance.getId());
}
示例25
protected void scheduleEventAsync(Object payload) {
final CommandContext commandContext = Context.getCommandContext();
JobEntity message = new JobEntity();
message.setJobType(Job.JOB_TYPE_MESSAGE);
message.setRevision(1);
message.setJobHandlerType(ProcessEventJobHandler.TYPE);
message.setJobHandlerConfiguration(id);
message.setTenantId(getTenantId());
message.setProcessDefinitionId(getProcessDefinitionId());
message.setExecutionId(getExecutionId());
message.setProcessInstanceId(getProcessInstanceId());
if (Context.getProcessEngineConfiguration().getAsyncExecutor().isActive()) {
GregorianCalendar expireCal = new GregorianCalendar();
ProcessEngineConfiguration processEngineConfig = Context.getCommandContext().getProcessEngineConfiguration();
expireCal.setTime(processEngineConfig.getClock().getCurrentTime());
expireCal.add(Calendar.SECOND, processEngineConfig.getLockTimeAsyncJobWaitTime());
message.setLockExpirationTime(expireCal.getTime());
}
// TODO: support payload
// if(payload != null) {
// message.setEventPayload(payload);
// }
commandContext.getJobEntityManager().send(message);
}
示例26
@SuppressWarnings("unchecked")
public List<Job> findJobsByTypeAndProcessDefinitionKeyAndTenantId(String jobHandlerType, String processDefinitionKey, String tenantId) {
Map<String, String> params = new HashMap<String, String>(3);
params.put("handlerType", jobHandlerType);
params.put("processDefinitionKey", processDefinitionKey);
params.put("tenantId", tenantId);
return getDbSqlSession().selectList("selectJobByTypeAndProcessDefinitionKeyAndTenantId", params);
}
示例27
@SuppressWarnings("unchecked")
public List<Job> findJobsByTypeAndProcessDefinitionId(String jobHandlerType, String processDefinitionId) {
Map<String, String> params = new HashMap<String, String>(2);
params.put("handlerType", jobHandlerType);
params.put("processDefinitionId", processDefinitionId);
return getDbSqlSession().selectList("selectJobByTypeAndProcessDefinitionId", params);
}
示例28
@SuppressWarnings("unchecked")
public List<Job> findSuspendedJobsByTypeAndProcessDefinitionKeyNoTenantId(String jobHandlerType, String processDefinitionKey) {
Map<String, String> params = new HashMap<String, String>(2);
params.put("handlerType", jobHandlerType);
params.put("processDefinitionKey", processDefinitionKey);
return getDbSqlSession().selectList("selectSuspendedJobByTypeAndProcessDefinitionKeyNoTenantId", params);
}
示例29
@SuppressWarnings("unchecked")
public List<Job> findSuspendedJobsByTypeAndProcessDefinitionId(String jobHandlerType, String processDefinitionId) {
Map<String, String> params = new HashMap<String, String>(2);
params.put("handlerType", jobHandlerType);
params.put("processDefinitionId", processDefinitionId);
return getDbSqlSession().selectList("selectSuspendedJobByTypeAndProcessDefinitionId", params);
}
示例30
@Deployment(resources = { "org/activiti5/engine/test/api/mgmt/timerOnTask.bpmn20.xml" })
public void testDeleteJobThatWasAlreadyAcquired() {
Clock clock = processEngineConfiguration.getClock();
processEngineConfiguration.resetClock();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
Job timerJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
// We need to move time at least one hour to make the timer executable
clock.setCurrentTime(new Date(processEngineConfiguration.getClock().getCurrentTime().getTime() + 7200000L));
processEngineConfiguration.setClock(clock);
// Acquire job by running the acquire command manually
AcquireTimerJobsCmd acquireJobsCmd = new AcquireTimerJobsCmd(processEngineConfiguration.getAsyncExecutor());
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
commandExecutor.execute(acquireJobsCmd);
// Try to delete the job. This should fail.
try {
managementService.deleteJob(timerJob.getId());
fail();
} catch (ActivitiException e) {
// Exception is expected
}
// Clean up
managementService.moveTimerToExecutableJob(timerJob.getId());
managementService.executeJob(timerJob.getId());
processEngineConfiguration.resetClock();
}