public void testDeleteDeploymentSkipCustomListeners() { DeploymentBuilder deploymentBuilder = repositoryService .createDeployment() .addClasspathResource( "org/camunda/bpm/engine/test/api/repository/RepositoryServiceTest.testDeleteProcessInstanceSkipCustomListeners.bpmn20.xml"); String deploymentId = deploymentBuilder.deploy().getId(); runtimeService.startProcessInstanceByKey("testProcess"); repositoryService.deleteDeployment(deploymentId, true, false); assertTrue(TestExecutionListener.collectedEvents.size() == 1); TestExecutionListener.reset(); deploymentId = deploymentBuilder.deploy().getId(); runtimeService.startProcessInstanceByKey("testProcess"); repositoryService.deleteDeployment(deploymentId, true, true); assertTrue(TestExecutionListener.collectedEvents.size() == 0); TestExecutionListener.reset(); }
public void testDeleteDeploymentSkipCustomTaskListeners() { DeploymentBuilder deploymentBuilder = repositoryService .createDeployment() .addClasspathResource( "org/camunda/bpm/engine/test/api/repository/RepositoryServiceTest.testDeleteProcessInstanceSkipCustomTaskListeners.bpmn20.xml"); String deploymentId = deploymentBuilder.deploy().getId(); runtimeService.startProcessInstanceByKey("testProcess"); repositoryService.deleteDeployment(deploymentId, true, false); assertTrue(RecorderTaskListener.getRecordedEvents().size() == 1); RecorderTaskListener.clear(); deploymentId = deploymentBuilder.deploy().getId(); runtimeService.startProcessInstanceByKey("testProcess"); repositoryService.deleteDeployment(deploymentId, true, true); assertTrue(RecorderTaskListener.getRecordedEvents().isEmpty()); RecorderTaskListener.clear(); }
public static String annotationDeploymentSetUp( ProcessEngine processEngine, Class<?> testClass, String methodName, Deployment deploymentAnnotation) { String deploymentId = null; Method method = null; try { method = testClass.getDeclaredMethod(methodName, (Class<?>[]) null); } catch (Exception e) { if (deploymentAnnotation == null) { // we have neither the annotation, nor can look it up from the method return null; } } if (deploymentAnnotation == null) { deploymentAnnotation = method.getAnnotation(Deployment.class); } if (deploymentAnnotation != null) { log.fine( "annotation @Deployment creates deployment for " + ClassNameUtil.getClassNameWithoutPackage(testClass) + "." + methodName); String[] resources = deploymentAnnotation.resources(); if (resources.length == 0 && method != null) { String name = method.getName(); String resource = getBpmnProcessDefinitionResource(testClass, name); resources = new String[] {resource}; } DeploymentBuilder deploymentBuilder = processEngine .getRepositoryService() .createDeployment() .name(ClassNameUtil.getClassNameWithoutPackage(testClass) + "." + methodName); for (String resource : resources) { deploymentBuilder.addClasspathResource(resource); } deploymentId = deploymentBuilder.deploy().getId(); } return deploymentId; }
protected void autoDeployResources(ProcessEngine processEngine) { if (deploymentResources != null && deploymentResources.length > 0) { RepositoryService repositoryService = processEngine.getRepositoryService(); DeploymentBuilder deploymentBuilder = repositoryService .createDeployment() .enableDuplicateFiltering(false) .name(deploymentName) .tenantId(deploymentTenantId); for (Resource resource : deploymentResources) { String resourceName = null; if (resource instanceof ContextResource) { resourceName = ((ContextResource) resource).getPathWithinContext(); } else if (resource instanceof ByteArrayResource) { resourceName = resource.getDescription(); } else { try { resourceName = resource.getFile().getAbsolutePath(); } catch (IOException e) { resourceName = resource.getFilename(); } } try { if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) { deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream())); } else { deploymentBuilder.addInputStream(resourceName, resource.getInputStream()); } } catch (IOException e) { throw new ProcessEngineException( "couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e); } } deploymentBuilder.deploy(); } }