示例#1
0
        protected internal virtual string deploymentWithBuilder(DeploymentBuilder builder)
        {
            deploymentId = builder.deploy().Id;
            deploymentIds.Add(deploymentId);

            return(deploymentId);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCreateBothJobDefinitionWithParseListenerAndAsynBothInXml()
        public virtual void testCreateBothJobDefinitionWithParseListenerAndAsynBothInXml()
        {
            //given the asyncBefore AND asyncAfter is set in the xml
            string            modelFileName = "jobAsyncBothCreationWithinParseListener.bpmn20.xml";
            Stream            @in           = typeof(JobDefinitionCreationWithParseListenerTest).getResourceAsStream(modelFileName);
            DeploymentBuilder builder       = engineRule.RepositoryService.createDeployment().addInputStream(modelFileName, @in);

            //when the asyncBefore and asyncAfter is set to true in the parse listener
            Deployment deployment = builder.deploy();

            engineRule.manageDeployment(deployment);

            //then there exists two job definitions
            JobDefinitionQuery    query       = engineRule.ManagementService.createJobDefinitionQuery();
            IList <JobDefinition> definitions = query.orderByJobConfiguration().asc().list();

            assertEquals(definitions.Count, 2);

            //asyncAfter
            JobDefinition asyncAfterAfter = definitions[0];

            assertEquals(asyncAfterAfter.ProcessDefinitionKey, "oneTaskProcess");
            assertEquals(asyncAfterAfter.ActivityId, "servicetask1");
            assertEquals(asyncAfterAfter.JobConfiguration, MessageJobDeclaration.ASYNC_AFTER);

            //asyncBefore
            JobDefinition asyncAfterBefore = definitions[1];

            assertEquals(asyncAfterBefore.ProcessDefinitionKey, "oneTaskProcess");
            assertEquals(asyncAfterBefore.ActivityId, "servicetask1");
            assertEquals(asyncAfterBefore.JobConfiguration, MessageJobDeclaration.ASYNC_BEFORE);
        }
示例#3
0
        public virtual void run()
        {
            DeploymentBuilder deploymentbuilder = engine.RepositoryService.createDeployment();

            for (int i = 0; i < modelInstances.Count; i++)
            {
                deploymentbuilder.addModelInstance("process" + i + ".bpmn", modelInstances[i]);
            }

            deploymentbuilder.deploy();
        }
示例#4
0
        public virtual void testParseExternalTaskWithoutTopic()
        {
            DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/external/ExternalTaskParseTest.testParseExternalTaskWithoutTopic.bpmn20.xml");

            try
            {
                deploymentBuilder.deploy();
                fail("exception expected");
            }
            catch (ProcessEngineException e)
            {
                assertTextPresent("External tasks must specify a 'topic' attribute in the camunda namespace", e.Message);
            }
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteJobDefinitionWithParseListenerAndAsyncInXml()
        public virtual void testDeleteJobDefinitionWithParseListenerAndAsyncInXml()
        {
            //given the asyncBefore is set in the xml
            string            modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml";
            Stream            @in           = typeof(JobDefinitionCreationWithParseListenerTest).getResourceAsStream(modelFileName);
            DeploymentBuilder builder       = engineRule.RepositoryService.createDeployment().addInputStream(modelFileName, @in);
            //when the asyncBefore is set to false in the parse listener
            Deployment deployment = builder.deploy();

            engineRule.manageDeployment(deployment);
            //then there exists no job definition
            JobDefinitionQuery query = engineRule.ManagementService.createJobDefinitionQuery();

            assertNull(query.singleResult());
        }
示例#6
0
        protected internal virtual void autoDeployResources(ProcessEngine processEngine)
        {
            if (deploymentResources != null && deploymentResources.Length > 0)
            {
                RepositoryService repositoryService = processEngine.RepositoryService;

                DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering(deployChangedOnly).name(deploymentName).tenantId(deploymentTenantId);

                foreach (Resource resource in deploymentResources)
                {
                    string resourceName = null;

                    if (resource is ContextResource)
                    {
                        resourceName = ((ContextResource)resource).PathWithinContext;
                    }
                    else if (resource is ByteArrayResource)
                    {
                        resourceName = resource.Description;
                    }
                    else
                    {
                        resourceName = getFileResourceName(resource);
                    }

                    try
                    {
                        if (resourceName.EndsWith(".bar", StringComparison.Ordinal) || resourceName.EndsWith(".zip", StringComparison.Ordinal) || resourceName.EndsWith(".jar", StringComparison.Ordinal))
                        {
                            deploymentBuilder.addZipInputStream(new ZipInputStream(resource.InputStream));
                        }
                        else
                        {
                            deploymentBuilder.addInputStream(resourceName, resource.InputStream);
                        }
                    }
                    catch (IOException e)
                    {
                        throw new ProcessEngineException("couldn't auto deploy resource '" + resource + "': " + e.Message, e);
                    }
                }

                deploymentBuilder.deploy();
            }
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCreateJobDefinitionWithParseListenerAndAsyncInXml()
        public virtual void testCreateJobDefinitionWithParseListenerAndAsyncInXml()
        {
            //given the asyncBefore is set in the xml
            string            modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml";
            Stream            @in           = typeof(JobDefinitionCreationWithParseListenerTest).getResourceAsStream(modelFileName);
            DeploymentBuilder builder       = engineRule.RepositoryService.createDeployment().addInputStream(modelFileName, @in);

            //when the asyncBefore is set in the parse listener
            Deployment deployment = builder.deploy();

            engineRule.manageDeployment(deployment);

            //then there exists only one job definition
            JobDefinitionQuery query  = engineRule.ManagementService.createJobDefinitionQuery();
            JobDefinition      jobDef = query.singleResult();

            assertNotNull(jobDef);
            assertEquals(jobDef.ProcessDefinitionKey, "oneTaskProcess");
            assertEquals(jobDef.ActivityId, "servicetask1");
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteNonExistingAndCreateNewJobDefinitionWithParseListener()
        public virtual void testDeleteNonExistingAndCreateNewJobDefinitionWithParseListener()
        {
            //given
            string            modelFileName = "jobCreationWithinParseListener.bpmn20.xml";
            Stream            @in           = typeof(JobDefinitionCreationWithParseListenerTest).getResourceAsStream(modelFileName);
            DeploymentBuilder builder       = engineRule.RepositoryService.createDeployment().addInputStream(modelFileName, @in);

            //when the asyncBefore is set to false and the asyncAfter to true in the parse listener
            Deployment deployment = builder.deploy();

            engineRule.manageDeployment(deployment);

            //then there exists one job definition
            JobDefinitionQuery query  = engineRule.ManagementService.createJobDefinitionQuery();
            JobDefinition      jobDef = query.singleResult();

            assertNotNull(jobDef);
            assertEquals(jobDef.ProcessDefinitionKey, "oneTaskProcess");
            assertEquals(jobDef.ActivityId, "servicetask1");
            assertEquals(jobDef.JobConfiguration, MessageJobDeclaration.ASYNC_AFTER);
        }
示例#9
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);
        }