@Test public void testPlugInOwnCacheImplementation() { // given DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache(); // when Cache<String, ProcessDefinitionEntity> cache = deploymentCache.getProcessDefinitionCache(); // then assertThat(cache, instanceOf(MyCacheImplementation.class)); }
protected ActivityImpl findActivityInDeployedProcessDefinition(String activityId) { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); assertNotNull(processDefinition); ProcessDefinitionEntity cachedProcessDefinition = processEngineConfiguration.getDeploymentCache() .getProcessDefinitionCache() .get(processDefinition.getId()); return cachedProcessDefinition.findActivity(activityId); }
deploymentCache.getProcessDefinitionCache().get(processDefinitionIdZero) == null ? 0 : 1; numberOfProcessesInCache += deploymentCache.getProcessDefinitionCache().get(processDefinitionIdOne) == null ? 0 : 1; numberOfProcessesInCache += deploymentCache.getProcessDefinitionCache().get(processDefinitionIdTwo) == null ? 0 : 1;
@Deployment public void testDeployStartAndIntermediateEventWithSameMessageInSameProcess() { ProcessInstance pi = null; try { runtimeService.startProcessInstanceByMessage("message"); pi = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(pi.isEnded(), is(false)); String deploymentId = repositoryService .createDeployment() .addClasspathResource( "org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageInSameProcess.bpmn") .name("deployment2").deploy().getId(); assertThat(repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(), is(notNullValue())); } finally { // clean db: runtimeService.deleteProcessInstance(pi.getId(), "failure"); List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); for (org.camunda.bpm.engine.repository.Deployment d : deployments) { repositoryService.deleteDeployment(d.getId(), true); } // Workaround for #CAM-4250: remove process definition of failed // deployment from deployment cache processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache().clear(); } }
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageDifferentProcesses.bpmn"}) public void testDeployStartAndIntermediateEventWithSameMessageDifferentProcessesFirstStartEvent() { ProcessInstance pi = null; try { runtimeService.startProcessInstanceByMessage("message"); pi = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(pi.isEnded(), is(false)); String deploymentId = repositoryService .createDeployment() .addClasspathResource( "org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageDifferentProcesses2.bpmn") .name("deployment2").deploy().getId(); assertThat(repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(), is(notNullValue())); } finally { // clean db: runtimeService.deleteProcessInstance(pi.getId(), "failure"); List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); for (org.camunda.bpm.engine.repository.Deployment d : deployments) { repositoryService.deleteDeployment(d.getId(), true); } // Workaround for #CAM-4250: remove process definition of failed // deployment from deployment cache processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache().clear(); } }
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageDifferentProcesses2.bpmn"}) public void testDeployStartAndIntermediateEventWithSameMessageDifferentProcessesFirstIntermediateEvent() { ProcessInstance pi = null; try { runtimeService.startProcessInstanceByKey("Process_2"); pi = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(pi.isEnded(), is(false)); String deploymentId = repositoryService .createDeployment() .addClasspathResource( "org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageDifferentProcesses.bpmn") .name("deployment2").deploy().getId(); assertThat(repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(), is(notNullValue())); } finally { // clean db: runtimeService.deleteProcessInstance(pi.getId(), "failure"); List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); for (org.camunda.bpm.engine.repository.Deployment d : deployments) { repositoryService.deleteDeployment(d.getId(), true); } // Workaround for #CAM-4250: remove process definition of failed // deployment from deployment cache processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache().clear(); } }
public void testSameMessageNameFails() { repositoryService .createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testSingleMessageStartEvent.bpmn20.xml") .deploy() .getId(); try { repositoryService .createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/bpmn/event/message/otherProcessWithNewInvoiceMessage.bpmn20.xml") .deploy(); fail("exception expected"); } catch (ProcessEngineException e) { assertTrue(e.getMessage().contains("there already is a message event subscription for the message with name")); } finally { // clean db: List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); for (org.camunda.bpm.engine.repository.Deployment deployment : deployments) { repositoryService.deleteDeployment(deployment.getId(), true); } // Workaround for #CAM-4250: remove process definition of failed // deployment from deployment cache processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache().clear(); } }
@Test public void testDeleteProcessDefinitionClearsCache() { // given process definition and a process instance BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess("process").startEvent().userTask().endEvent().done(); deployment = repositoryService.createDeployment() .addModelInstance("process.bpmn", bpmnModel) .deploy(); String processDefinitionId = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("process") .singleResult() .getId(); DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache(); // ensure definitions and models are part of the cache assertNotNull(deploymentCache.getProcessDefinitionCache().get(processDefinitionId)); assertNotNull(deploymentCache.getBpmnModelInstanceCache().get(processDefinitionId)); repositoryService.deleteProcessDefinition(processDefinitionId, true); // then the definitions and models are removed from the cache assertNull(deploymentCache.getProcessDefinitionCache().get(processDefinitionId)); assertNull(deploymentCache.getBpmnModelInstanceCache().get(processDefinitionId)); }
@Test public void testDeleteProcessDefinitionAndRefillDeploymentCache() { // given a deployment with two process definitions in one xml model file deployment = repositoryService.createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/repository/twoProcesses.bpmn20.xml") .deploy(); ProcessDefinition processDefinitionOne = repositoryService.createProcessDefinitionQuery().processDefinitionKey("one").singleResult(); ProcessDefinition processDefinitionTwo = repositoryService.createProcessDefinitionQuery().processDefinitionKey("two").singleResult(); String idOne = processDefinitionOne.getId(); //one is deleted from the deployment repositoryService.deleteProcessDefinition(idOne); //when clearing the deployment cache processEngineConfiguration.getDeploymentCache().discardProcessDefinitionCache(); //then creating process instance from the existing process definition ProcessInstanceWithVariables procInst = runtimeService.createProcessInstanceByKey("two").executeWithVariablesInReturn(); assertNotNull(procInst); assertTrue(procInst.getProcessDefinitionId().contains("two")); //should refill the cache Cache cache = processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache(); assertNotNull(cache.get(processDefinitionTwo.getId())); //The deleted process definition should not be recreated after the cache is refilled assertNull(cache.get(processDefinitionOne.getId())); }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/repository/one.cmmn"}) public void testDeleteDeploymentClearsCache() { // fetch definition ids String processDefinitionId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId(); // fetch CMMN model to be placed to in the cache repositoryService.getCmmnModelInstance(caseDefinitionId); DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache(); // ensure definitions and models are part of the cache assertNotNull(deploymentCache.getProcessDefinitionCache().get(processDefinitionId)); assertNotNull(deploymentCache.getBpmnModelInstanceCache().get(processDefinitionId)); assertNotNull(deploymentCache.getCaseDefinitionCache().get(caseDefinitionId)); assertNotNull(deploymentCache.getCmmnModelInstanceCache().get(caseDefinitionId)); // when the deployment is deleted repositoryService.deleteDeployment(deploymentId, true); // then the definitions and models are removed from the cache assertNull(deploymentCache.getProcessDefinitionCache().get(processDefinitionId)); assertNull(deploymentCache.getBpmnModelInstanceCache().get(processDefinitionId)); assertNull(deploymentCache.getCaseDefinitionCache().get(caseDefinitionId)); assertNull(deploymentCache.getCmmnModelInstanceCache().get(caseDefinitionId)); }
public CachePurgeReport purgeCache() { Cache<String, ProcessDefinitionEntity> processDefinitionCache = getProcessDefinitionCache(); if (!processDefinitionCache.isEmpty()) { result.addPurgeInformation(CachePurgeReport.PROCESS_DEF_CACHE, processDefinitionCache.keySet());
public CachePurgeReport purgeCache() { Cache<String, ProcessDefinitionEntity> processDefinitionCache = getProcessDefinitionCache(); if (!processDefinitionCache.isEmpty()) { result.addPurgeInformation(CachePurgeReport.PROCESS_DEF_CACHE, processDefinitionCache.keySet());
@Test public void testPlugInOwnCacheImplementation() { // given DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache(); // when Cache<String, ProcessDefinitionEntity> cache = deploymentCache.getProcessDefinitionCache(); // then assertThat(cache, instanceOf(MyCacheImplementation.class)); }
Cache cache = processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache(); assertNotNull(cache.get(version2.getId())); assertNull(cache.get(version1.getId()));
protected ActivityImpl findActivityInDeployedProcessDefinition(String activityId) { ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); assertNotNull(processDefinition); ProcessDefinitionEntity cachedProcessDefinition = processEngineConfiguration.getDeploymentCache() .getProcessDefinitionCache() .get(processDefinition.getId()); return cachedProcessDefinition.findActivity(activityId); }
@Deployment public void testDeployStartAndIntermediateEventWithSameMessageInSameProcess() { ProcessInstance pi = null; try { runtimeService.startProcessInstanceByMessage("message"); pi = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(pi.isEnded(), is(false)); String deploymentId = repositoryService .createDeployment() .addClasspathResource( "org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageInSameProcess.bpmn") .name("deployment2").deploy().getId(); assertThat(repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(), is(notNullValue())); } finally { // clean db: runtimeService.deleteProcessInstance(pi.getId(), "failure"); List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); for (org.camunda.bpm.engine.repository.Deployment d : deployments) { repositoryService.deleteDeployment(d.getId(), true); } // Workaround for #CAM-4250: remove process definition of failed // deployment from deployment cache processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache().clear(); } }
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageDifferentProcesses.bpmn"}) public void testDeployStartAndIntermediateEventWithSameMessageDifferentProcessesFirstStartEvent() { ProcessInstance pi = null; try { runtimeService.startProcessInstanceByMessage("message"); pi = runtimeService.createProcessInstanceQuery().singleResult(); assertThat(pi.isEnded(), is(false)); String deploymentId = repositoryService .createDeployment() .addClasspathResource( "org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testDeployStartAndIntermediateEventWithSameMessageDifferentProcesses2.bpmn") .name("deployment2").deploy().getId(); assertThat(repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(), is(notNullValue())); } finally { // clean db: runtimeService.deleteProcessInstance(pi.getId(), "failure"); List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); for (org.camunda.bpm.engine.repository.Deployment d : deployments) { repositoryService.deleteDeployment(d.getId(), true); } // Workaround for #CAM-4250: remove process definition of failed // deployment from deployment cache processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache().clear(); } }
public void testSameMessageNameFails() { repositoryService .createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/bpmn/event/message/MessageStartEventTest.testSingleMessageStartEvent.bpmn20.xml") .deploy() .getId(); try { repositoryService .createDeployment() .addClasspathResource("org/camunda/bpm/engine/test/bpmn/event/message/otherProcessWithNewInvoiceMessage.bpmn20.xml") .deploy(); fail("exception expected"); } catch (ProcessEngineException e) { assertTrue(e.getMessage().contains("there already is a message event subscription for the message with name")); } finally { // clean db: List<org.camunda.bpm.engine.repository.Deployment> deployments = repositoryService.createDeploymentQuery().list(); for (org.camunda.bpm.engine.repository.Deployment deployment : deployments) { repositoryService.deleteDeployment(deployment.getId(), true); } // Workaround for #CAM-4250: remove process definition of failed // deployment from deployment cache processEngineConfiguration.getDeploymentCache().getProcessDefinitionCache().clear(); } }
@Test public void testDeleteProcessDefinitionClearsCache() { // given process definition and a process instance BpmnModelInstance bpmnModel = Bpmn.createExecutableProcess("process").startEvent().userTask().endEvent().done(); deployment = repositoryService.createDeployment() .addModelInstance("process.bpmn", bpmnModel) .deploy(); String processDefinitionId = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("process") .singleResult() .getId(); DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache(); // ensure definitions and models are part of the cache assertNotNull(deploymentCache.getProcessDefinitionCache().get(processDefinitionId)); assertNotNull(deploymentCache.getBpmnModelInstanceCache().get(processDefinitionId)); repositoryService.deleteProcessDefinition(processDefinitionId, true); // then the definitions and models are removed from the cache assertNull(deploymentCache.getProcessDefinitionCache().get(processDefinitionId)); assertNull(deploymentCache.getBpmnModelInstanceCache().get(processDefinitionId)); }
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml", "org/camunda/bpm/engine/test/repository/one.cmmn"}) public void testDeleteDeploymentClearsCache() { // fetch definition ids String processDefinitionId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId(); // fetch CMMN model to be placed to in the cache repositoryService.getCmmnModelInstance(caseDefinitionId); DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache(); // ensure definitions and models are part of the cache assertNotNull(deploymentCache.getProcessDefinitionCache().get(processDefinitionId)); assertNotNull(deploymentCache.getBpmnModelInstanceCache().get(processDefinitionId)); assertNotNull(deploymentCache.getCaseDefinitionCache().get(caseDefinitionId)); assertNotNull(deploymentCache.getCmmnModelInstanceCache().get(caseDefinitionId)); // when the deployment is deleted repositoryService.deleteDeployment(deploymentId, true); // then the definitions and models are removed from the cache assertNull(deploymentCache.getProcessDefinitionCache().get(processDefinitionId)); assertNull(deploymentCache.getBpmnModelInstanceCache().get(processDefinitionId)); assertNull(deploymentCache.getCaseDefinitionCache().get(caseDefinitionId)); assertNull(deploymentCache.getCmmnModelInstanceCache().get(caseDefinitionId)); }