// the listener should execute successfully
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
taskService.setAssignee(task.getId(), "john doe");
Execution execution = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).singleResult();
Assert.assertNotNull(runtimeService.getVariable(execution.getId(), "listener"));
runtimeService.removeVariable(execution.getId(), "listener");
taskService.complete(task.getId());
Assert.assertNotNull(runtimeService.getVariable(execution.getId(), "listener"));
// the delegate expression listener should execute successfully
runtimeService.removeVariable(execution.getId(), "listener");
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
taskService.setAssignee(task.getId(), "john doe");
Assert.assertNotNull(runtimeService.getVariable(execution.getId(), "listener"));
runtimeService.removeVariable(execution.getId(), "listener");
taskService.complete(task.getId());
Assert.assertNotNull(runtimeService.getVariable(execution.getId(), "listener"));
}