예제 #1
0
        protected internal virtual string deployment(DeploymentBuilder deploymentBuilder, params string[] resources)
        {
            for (int i = 0; i < resources.Length; i++)
            {
                deploymentBuilder.addClasspathResource(resources[i]);
            }

            return(deploymentWithBuilder(deploymentBuilder));
        }
예제 #2
0
        protected internal virtual DeploymentWithDefinitions deploy(DeploymentBuilder deploymentBuilder, IList <BpmnModelInstance> bpmnModelInstances, IList <string> resources)
        {
            int i = 0;

            foreach (BpmnModelInstance bpmnModelInstance in bpmnModelInstances)
            {
                deploymentBuilder.addModelInstance(i + "_" + DEFAULT_BPMN_RESOURCE_NAME, bpmnModelInstance);
                i++;
            }

            foreach (string resource in resources)
            {
                deploymentBuilder.addClasspathResource(resource);
            }

            return(deploy(deploymentBuilder));
        }
예제 #3
0
        public static string annotationDeploymentSetUp(ProcessEngine processEngine, Type testClass, string methodName, Deployment deploymentAnnotation)
        {
            string deploymentId = null;

            System.Reflection.MethodInfo method = null;
            bool onMethod = true;

            try
            {
                method = getMethod(testClass, methodName);
            }
            catch (Exception)
            {
                if (deploymentAnnotation == null)
                {
                    // we have neither the annotation, nor can look it up from the method
                    return(null);
                }
            }

            if (deploymentAnnotation == null)
            {
                deploymentAnnotation = method.getAnnotation(typeof(Deployment));
            }
            // if not found on method, try on class level
            if (deploymentAnnotation == null)
            {
                onMethod = false;
                Type lookForAnnotationClass = testClass;
                while (lookForAnnotationClass != typeof(object))
                {
                    deploymentAnnotation = lookForAnnotationClass.getAnnotation(typeof(Deployment));
                    if (deploymentAnnotation != null)
                    {
                        testClass = lookForAnnotationClass;
                        break;
                    }
                    lookForAnnotationClass = lookForAnnotationClass.BaseType;
                }
            }

            if (deploymentAnnotation != null)
            {
                LOG.debug("annotation @Deployment creates deployment for {}.{}", ClassNameUtil.getClassNameWithoutPackage(testClass), methodName);
                string[] resources = deploymentAnnotation.resources();
                if (resources.Length == 0 && method != null)
                {
                    string name     = onMethod ? method.Name : null;
                    string resource = getBpmnProcessDefinitionResource(testClass, name);
                    resources = new string[] { resource };
                }

                DeploymentBuilder deploymentBuilder = processEngine.RepositoryService.createDeployment().name(ClassNameUtil.getClassNameWithoutPackage(testClass) + "." + methodName);

                foreach (string resource in resources)
                {
                    deploymentBuilder.addClasspathResource(resource);
                }

                deploymentId = deploymentBuilder.deploy().Id;
            }

            return(deploymentId);
        }