@Deployment
public void testVersionUpgradeShouldCancelJobs() throws Exception {
ClockUtil.setCurrentTime(new Date());
// After process start, there should be timer created
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
// we deploy new process version, with some small change
InputStream in = getClass().getResourceAsStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml");
String process = new String(IoUtil.readInputStream(in, "")).replaceAll("beforeChange", "changed");
IoUtil.closeSilently(in);
in = new ByteArrayInputStream(process.getBytes());
String id = repositoryService.createDeployment().addInputStream("StartTimerEventTest.testVersionUpgradeShouldCancelJobs.bpmn20.xml", in).deploy().getId();
IoUtil.closeSilently(in);
assertEquals(1, jobQuery.count());
moveByMinutes(5);
executeAllJobs();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").singleResult();
String pi = processInstance.getProcessInstanceId();
assertEquals("changed", runtimeService.getActiveActivityIds(pi).get(0));
assertEquals(1, jobQuery.count());
cleanDB();
repositoryService.deleteDeployment(id, true);
}