Based off example jBPM included in JBDS, run this as a JUnit:
**********************************************************************************************************************
HashMap<String,Object> params = new HashMap<String, Object>();
params.put("AString", new String("AString_value"));
params.put("AnotherString", new String("AnotherString_value"));
// Extract a process definition from the processdefinition.xml file.
ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("simple/processdefinition.xml");
// Create an instance of the process definition.
ProcessInstance instance = new ProcessInstance(processDefinition, params);
instance.getContextInstance().setVariable("userId", new String("userId_Value"));
String var1 = (String)instance.getContextInstance().getVariables().get("userId");
assertEquals("Process Variable didn't match as expected",
"userId_Value", var1);
instance.setKey("MyKey"); // Uh-oh! This causes trouble
String var2 = (String)instance.getContextInstance().getVariables().get("userId"); // same test that passed a moment ago...
assertEquals("Process Variable didn't match as expected",
"userId_Value", var2);
**************************************************************************************************************************