public void testCatchSignalAndMessageAndTimer() {
runtimeService.startProcessInstanceByKey("catchSignal");
assertEquals(2, createEventSubscriptionQuery().count());
EventSubscriptionQueryImpl messageEventSubscriptionQuery = createEventSubscriptionQuery().eventType("message");
assertEquals(1, messageEventSubscriptionQuery.count());
assertEquals(1, createEventSubscriptionQuery().eventType("signal").count());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
assertEquals(1, managementService.createJobQuery().count());
// we can query for an execution with has both a signal AND message subscription
Execution execution = runtimeService.createExecutionQuery()
.messageEventSubscriptionName("newInvoice")
.signalEventSubscriptionName("alert")
.singleResult();
assertNotNull(execution);
processEngineConfiguration.getClock().setCurrentTime(new Date(processEngineConfiguration.getClock().getCurrentTime().getTime() + 10000));
try {
EventSubscriptionEntity messageEventSubscription = messageEventSubscriptionQuery.singleResult();
runtimeService.messageEventReceived(messageEventSubscription.getEventName(), messageEventSubscription.getExecutionId());
assertEquals(0, createEventSubscriptionQuery().count());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
assertEquals(0, managementService.createJobQuery().count());