@Deployment(resources="org/camunda/bpm/engine/test/bpmn/subprocess/InterruptingEventSubProcessTest.testCancelEventSubscriptions.bpmn")
public void testCancelEventSubscriptionsWhenReceivingAMessage() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
TaskQuery taskQuery = taskService.createTaskQuery();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery();
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskBeforeInterruptingEventSuprocess", task.getTaskDefinitionKey());
List<EventSubscription> eventSubscriptions = eventSubscriptionQuery.list();
assertEquals(2, eventSubscriptions.size());
runtimeService.messageEventReceived("newMessage", pi.getId());
task = taskQuery.singleResult();
assertNotNull(task);
assertEquals("taskAfterMessageStartEvent", task.getTaskDefinitionKey());
assertEquals(0, eventSubscriptionQuery.count());