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; }
public static void annotationDeploymentTearDown( ProcessEngine processEngine, String deploymentId, Class<?> testClass, String methodName) { log.fine( "annotation @Deployment deletes deployment for " + ClassNameUtil.getClassNameWithoutPackage(testClass) + "." + methodName); if (deploymentId != null) { processEngine.getRepositoryService().deleteDeployment(deploymentId, true); } }