"</process-definition>"
);
processDefinition = saveAndReload(processDefinition);
ProcessInstance processInstance = new ProcessInstance(processDefinition);
ContextInstance contextInstance = processInstance.getContextInstance();
TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
contextInstance.setVariable("a", "1");
contextInstance.setVariable("b", "2");
contextInstance.setVariable("c", "3");
processInstance.signal();
TaskInstance taskInstance = (TaskInstance) taskMgmtInstance.getTaskInstances().iterator().next();
jbpmContext.save(processInstance);
newTransaction();
processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
contextInstance = processInstance.getContextInstance();
taskMgmtInstance = processInstance.getTaskMgmtInstance();
HashMap expectedVariables = new HashMap();
expectedVariables.put("a", "1");
expectedVariables.put("b", "2");
expectedVariables.put("c", "3");
assertEquals(expectedVariables, taskInstance.getVariables());
taskInstance.setVariable("a", "1 modified");
taskInstance.setVariable("b", "2 modified");
taskInstance.setVariable("c", "3 modified");
jbpmContext.save(processInstance);
newTransaction();
processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
contextInstance = processInstance.getContextInstance();
taskMgmtInstance = processInstance.getTaskMgmtInstance();
expectedVariables = new HashMap();
expectedVariables.put("a", "1 modified");
expectedVariables.put("b", "2 modified");
expectedVariables.put("c", "3 modified");
assertEquals(expectedVariables, taskInstance.getVariables());
newTransaction();
processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
taskInstance = jbpmContext.loadTaskInstance(taskInstance.getId());
contextInstance = processInstance.getContextInstance();
taskMgmtInstance = processInstance.getTaskMgmtInstance();
expectedVariables = new HashMap();
expectedVariables.put("a", "1"); // task instance had local copy for var a
expectedVariables.put("b", "2"); // task instance had local copy for var b
expectedVariables.put("c", "3 modified");
assertEquals(expectedVariables, contextInstance.getVariables());
}