}
public void testReceiveTask() throws Exception {
KnowledgeBase kbase = createKnowledgeBase("BPMN2-ReceiveTask.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
ReceiveTaskHandler receiveTaskHandler = new ReceiveTaskHandler(ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Receive Task", receiveTaskHandler);
WorkflowProcessInstance processInstance = (WorkflowProcessInstance)
ksession.startProcess("ReceiveTask");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
ksession = restoreSession(ksession, true);
receiveTaskHandler.messageReceived("HelloMessage", "Hello john!");
assertProcessInstanceCompleted(processInstance.getId(), ksession);
}