getProcessServer().getProcessFacade().begin();
TokenContext tc = createToken();
getProcessServer().getProcessFacade().prepareTokenForScheduler(tc);
getProcessServer().getProcessFacade().commit();
ProcessJobDescriptor job1 = new ProcessJobDescriptor();
job1.setJobName("job1");
job1.setJobGroup("SchedulerTest");
job1.setTokenContext(tc);
job1.setPositionRef(STARTREF);
// For this test case, we will execute the job directly within the job handler.
// In an application, you should rather use the asynchronous execution mode using the execution thread pool.
job1.setExecutionMode(ProcessJobDescriptor.EXECUTION_MODE_SYNCHRONOUS);
HashMap inputValues = new HashMap();
inputValues.put("StringParam", TEST_PARAM_VALUE);
job1.setInputValues(inputValues);
// Start in 5 sec.
Trigger t1 = new SimpleTrigger("trigger1", "SchedulerTest");
long currentTime = System.currentTimeMillis();
Date d1 = new Date(currentTime + 5000L);
t1.setStartTime(d1);
scheduler.scheduleProcess(job1, t1);
// Wait 10 sec
Object v1 = wait(SIGNAL1, 10);
assertEquals(TEST_PARAM_VALUE, v1);
// The process has been executed as desired. The execution of the process stopped
// at the wait state node.
// The next job will resume the workflow from its current position.
ProcessJobDescriptor job2 = new ProcessJobDescriptor();
job2.setJobName("job2");
job2.setJobGroup("SchedulerTest");
job2.setTokenContext(tc);
job2.setPositionRef("Continue");
job2.setStartMode(ProcessJobDescriptor.START_MODE_RESUME);
// For this test case, we will execute the job directly within the job handler.
// In an application, you should rather use the asynchronous execution mode using the execution thread pool.
job2.setExecutionMode(ProcessJobDescriptor.EXECUTION_MODE_SYNCHRONOUS);
// Again, 5 sec. delay
Trigger t2 = new SimpleTrigger("trigger2", "SchedulerTest");
currentTime = System.currentTimeMillis();
Date d2 = new Date(currentTime + 5000L);