private String getApplicationPath(String processDefinitionId) { ProcessDefinition processDefinition = processEngine.getRepositoryService().getProcessDefinition(processDefinitionId); // get the name of the process application that made the deployment String processApplicationName = processEngine .getManagementService() .getProcessApplicationForDeployment(processDefinition.getDeploymentId()); if (processApplicationName == null) { // no a process application deployment return null; } else { ProcessApplicationService processApplicationService = BpmPlatform.getProcessApplicationService(); ProcessApplicationInfo processApplicationInfo = processApplicationService.getProcessApplicationInfo(processApplicationName); String contextPath = processApplicationInfo .getProperties() .get(ProcessApplicationInfo.PROP_SERVLET_CONTEXT_PATH); return contextPath; } }
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testDeleteDeploymentCascadeWithRunningInstances() { List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list(); assertEquals(1, processDefinitions.size()); ProcessDefinition processDefinition = processDefinitions.get(0); runtimeService.startProcessInstanceById(processDefinition.getId()); // Try to delete the deployment, no exception should be thrown repositoryService.deleteDeployment(processDefinition.getDeploymentId(), true); }
protected void assertProcessDeployed(String processKey, String expectedDeploymentName) { ProcessDefinition processDefinition = repositoryService .createProcessDefinitionQuery() .latestVersion() .processDefinitionKey(processKey) .singleResult(); DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery().deploymentId(processDefinition.getDeploymentId()); Assert.assertEquals(expectedDeploymentName, deploymentQuery.singleResult().getName()); }
@Test @ScenarioUnderTest("init.1") public void testCompleteProcessWithUserTask() { // given deployed process with process instance String processDefinitionId = rule.processInstance().getProcessDefinitionId(); ProcessDefinition procDef = rule.getRepositoryService() .createProcessDefinitionQuery() .processDefinitionId(processDefinitionId) .singleResult(); // when deployment is deleted rule.getRepositoryService().deleteDeployment(procDef.getDeploymentId(), true); // then process instance is ended rule.assertScenarioEnded(); }
@Deployment(resources = {"org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml"}) public void testDeleteDeploymentWithRunningInstances() { List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery().list(); assertEquals(1, processDefinitions.size()); ProcessDefinition processDefinition = processDefinitions.get(0); runtimeService.startProcessInstanceById(processDefinition.getId()); // Try to delete the deployment try { repositoryService.deleteDeployment(processDefinition.getDeploymentId()); fail("Exception expected"); } catch (RuntimeException ae) { // Exception expected when deleting deployment with running process } }
/** Test re-deployment of only those resources that have actually changed */ public void testPartialChangesDeployChangedOnly() { BpmnModelInstance model1 = Bpmn.createExecutableProcess("process1").done(); BpmnModelInstance model2 = Bpmn.createExecutableProcess("process2").done(); // create initial deployment ProcessApplicationDeployment deployment1 = repositoryService .createDeployment(processApplication.getReference()) .name("deployment") .addModelInstance("process1.bpmn20.xml", model1) .addModelInstance("process2.bpmn20.xml", model2) .deploy(); BpmnModelInstance changedModel2 = Bpmn.createExecutableProcess("process2").startEvent().done(); // second deployment with partial changes: ProcessApplicationDeployment deployment2 = repositoryService .createDeployment(processApplication.getReference()) .name("deployment") .enableDuplicateFiltering(true) .resumePreviousVersions() .addModelInstance("process1.bpmn20.xml", model1) .addModelInstance("process2.bpmn20.xml", changedModel2) .deploy(); assertEquals(3, repositoryService.createProcessDefinitionQuery().count()); // there is one version of process1 deployed ProcessDefinition processDefinitionModel1 = repositoryService .createProcessDefinitionQuery() .processDefinitionKey("process1") .singleResult(); assertNotNull(processDefinitionModel1); assertEquals(1, processDefinitionModel1.getVersion()); assertEquals(deployment1.getId(), processDefinitionModel1.getDeploymentId()); // there are two versions of process2 deployed List<ProcessDefinition> processDefinitionsModel2 = repositoryService .createProcessDefinitionQuery() .processDefinitionKey("process2") .orderByProcessDefinitionVersion() .asc() .list(); assertEquals(2, processDefinitionsModel2.size()); assertEquals(1, processDefinitionsModel2.get(0).getVersion()); assertEquals(2, processDefinitionsModel2.get(1).getVersion()); // old deployment was resumed ProcessApplicationRegistration registration = deployment2.getProcessApplicationRegistration(); Set<String> deploymentIds = registration.getDeploymentIds(); assertEquals(2, deploymentIds.size()); BpmnModelInstance anotherChangedModel2 = Bpmn.createExecutableProcess("process2").startEvent().endEvent().done(); // testing with a third deployment to ensure the change check is not only performed against // the last version of the deployment ProcessApplicationDeployment deployment3 = repositoryService .createDeployment(processApplication.getReference()) .enableDuplicateFiltering(true) .resumePreviousVersions() .addModelInstance("process1.bpmn20.xml", model1) .addModelInstance("process2.bpmn20.xml", anotherChangedModel2) .name("deployment") .deploy(); // there should still be one version of process 1 assertEquals( 1, repositoryService.createProcessDefinitionQuery().processDefinitionKey("process1").count()); // there should be three versions of process 2 assertEquals( 3, repositoryService.createProcessDefinitionQuery().processDefinitionKey("process2").count()); // old deployments are resumed registration = deployment3.getProcessApplicationRegistration(); deploymentIds = registration.getDeploymentIds(); assertEquals(3, deploymentIds.size()); deleteDeployments(deployment1, deployment2, deployment3); }