Esempio n. 1
0
 public static void AnnotationDeploymentTearDown(IProcessEngine processEngine, string deploymentId,
                                                 Type testClass, string methodName)
 {
     Debug.WriteLine("annotation Deployment deletes deployment for {0}.{1}",
                     ClassNameUtil.GetClassNameWithoutPackage(testClass), methodName);
     DeleteDeployment(processEngine, deploymentId);
 }
Esempio n. 2
0
        public virtual void TestDeleteJobDefinitionWithParseListenerAndAsyncBothInXml()
        {
            //given the asyncBefore AND asyncAfter is set in the xml
            //var modelFileName = "jobexecutor/jobAsyncBothCreationWithinParseListener.bpmn20.xml";
            //var @in = ReflectUtil.GetResourceAsStream(modelFileName);
            //var builder = EngineRule.RepositoryService.CreateDeployment().AddInputStream(modelFileName, @in);

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

            var deployment = EngineRule.RepositoryService.CreateDeployment()
                             .Name(ClassNameUtil.GetClassNameWithoutPackage(this.GetType()) + "." + TestContext.CurrentContext.Test.Name)
                             .AddClasspathResource("resources/jobexecutor/jobAsyncBothCreationWithinParseListener.bpmn20.xml").Deploy();

            EngineRule.ManageDeployment(deployment);

            //then there exists one job definition
            var query  = EngineRule.ManagementService.CreateJobDefinitionQuery();
            var jobDef = query.First();

            Assert.NotNull(jobDef);
            Assert.AreEqual(jobDef.ProcessDefinitionKey, "oneTaskProcess");
            Assert.AreEqual(jobDef.ActivityId, "servicetask1");
            Assert.AreEqual(jobDef.JobConfiguration, MessageJobDeclaration.AsyncAfter);
        }
Esempio n. 3
0
        public virtual void TestCreateBothAsyncJobDefinitionWithParseListener()
        {
            //given
            //var modelFileName = "jobexecutor/jobCreationWithinParseListener.bpmn20.xml";
            //var @in = ReflectUtil.GetResourceAsStream(modelFileName);
            //var builder = EngineRule.RepositoryService.CreateDeployment().AddInputStream(modelFileName, @in);
            ////when the asyncBefore and asyncAfter is set to true in the parse listener
            //var deployment = builder.Deploy();

            var deployment = EngineRule.RepositoryService.CreateDeployment()
                             .Name(ClassNameUtil.GetClassNameWithoutPackage(this.GetType()) + "." + TestContext.CurrentContext.Test.Name)
                             .AddClasspathResource("resources/jobexecutor/jobCreationWithinParseListener.bpmn20.xml").Deploy();

            EngineRule.ManageDeployment(deployment);

            //then there exists two job definitions
            var query       = EngineRule.ManagementService.CreateJobDefinitionQuery();
            var definitions = query.OrderBy(c => c.JobConfiguration).ToList();

            Assert.AreEqual(definitions.Count, 2);

            //asyncAfter
            var asyncAfterAfter = definitions[0];

            Assert.AreEqual(asyncAfterAfter.ProcessDefinitionKey, "oneTaskProcess");
            Assert.AreEqual(asyncAfterAfter.ActivityId, "servicetask1");
            Assert.AreEqual(asyncAfterAfter.JobConfiguration, MessageJobDeclaration.AsyncAfter);

            //asyncBefore
            var asyncAfterBefore = definitions[1];

            Assert.AreEqual(asyncAfterBefore.ProcessDefinitionKey, "oneTaskProcess");
            Assert.AreEqual(asyncAfterBefore.ActivityId, "servicetask1");
            Assert.AreEqual(asyncAfterBefore.JobConfiguration, MessageJobDeclaration.AsyncBefore);
        }
Esempio n. 4
0
        private string getStatement(Type persistentObjectClass, IDictionary <Type, string> cachedStatements, string prefix)
        {
            string statement = cachedStatements[persistentObjectClass];

            if (!string.ReferenceEquals(statement, null))
            {
                return(statement);
            }
            statement = prefix + ClassNameUtil.getClassNameWithoutPackage(persistentObjectClass);
            statement = statement.Substring(0, statement.Length - 6);     // "Entity".length() = 6
            cachedStatements[persistentObjectClass] = statement;
            return(statement);
        }
        public virtual void TestDeleteNonExistingJobDefinitionWithParseListener()
        {
            ////given
            //var modelFileName = "jobexecutor/jobCreationWithinParseListener.bpmn20.xml";
            //var @in = ReflectUtil.GetResourceAsStream(modelFileName);
            //var builder = EngineRule.RepositoryService.CreateDeployment().AddInputStream(modelFileName, @in);
            ////when the asyncBefore is set to false in the parse listener
            //var deployment = builder.Deploy();

            var deployment = EngineRule.RepositoryService.CreateDeployment()
                             .Name(ClassNameUtil.GetClassNameWithoutPackage(this.GetType()) + "." + TestContext.CurrentContext.Test.Name)
                             .AddClasspathResource("resources/jobexecutor/jobCreationWithinParseListener.bpmn20.xml").Deploy();

            EngineRule.ManageDeployment(deployment);
            //then there exists no job definition
            var query = EngineRule.ManagementService.CreateJobDefinitionQuery();

            Assert.IsNull(query.SingleOrDefault());
        }
        public virtual void ExecuteDatabaseOperation(string operationType, object parameter)
        {
            if (DebugEnabled)
            {
                string message;
                if (parameter != null)
                {
                    message = parameter.ToString();
                }
                else
                {
                    message = "null";
                }

                if (parameter is IDbEntity)
                {
                    var dbEntity = (IDbEntity)parameter;
                    message = ClassNameUtil.GetClassNameWithoutPackage(dbEntity) + "[id=" + dbEntity.Id + "]";
                }

                LogDebug("009", "SQL operation: '{0}'; Entity: '{1}'", operationType, message);
            }
        }
        public virtual void TestCreateJobDefinitionWithParseListener()
        {
            ////given
            //var modelFileName = "jobexecutor/jobCreationWithinParseListener.bpmn20.xml";
            //var @in = ReflectUtil.GetResourceAsStream(modelFileName);
            //var builder = EngineRule.RepositoryService.CreateDeployment().AddInputStream(modelFileName, @in);
            ////when the asyncBefore is set in the parse listener
            //var deployment = builder.Deploy();

            var deployment = EngineRule.RepositoryService.CreateDeployment()
                             .Name(ClassNameUtil.GetClassNameWithoutPackage(this.GetType()) + "." + TestContext.CurrentContext.Test.Name)
                             .AddClasspathResource("resources/jobexecutor/jobCreationWithinParseListener.bpmn20.xml").Deploy();

            EngineRule.ManageDeployment(deployment);

            //then there exists a new job definition
            var query  = EngineRule.ManagementService.CreateJobDefinitionQuery();
            var jobDef = query.SingleOrDefault();

            Assert.NotNull(jobDef);
            Assert.AreEqual(jobDef.ProcessDefinitionKey, "oneTaskProcess");
            Assert.AreEqual(jobDef.ActivityId, "servicetask1");
        }
Esempio n. 8
0
        public static string AnnotationDeploymentSetUp(IProcessEngine processEngine, Type testClass, string methodName,
                                                       DeploymentAttribute deploymentAnnotation)
        {
            string     deploymentId = null;
            MethodInfo method       = null;
            var        onMethod     = true;

            try
            {
                method = GetMethod(testClass, methodName);
            }
            catch (System.Exception)
            {
                if (deploymentAnnotation == null)
                {
                    return(null);
                }
            }

            if (deploymentAnnotation == null)
            {
                deploymentAnnotation = method.GetCustomAttribute <DeploymentAttribute>(true);
            }
            // if not found on method, try on class level
            if (deploymentAnnotation == null)
            {
                onMethod = false;
                var lookForAnnotationClass = testClass;
                while (lookForAnnotationClass != typeof(object))
                {
                    deploymentAnnotation = lookForAnnotationClass.GetCustomAttribute <DeploymentAttribute>();
                    if (deploymentAnnotation != null)
                    {
                        testClass = lookForAnnotationClass;
                        break;
                    }
                    lookForAnnotationClass = lookForAnnotationClass.BaseType;
                }
            }

            if (deploymentAnnotation != null)
            {
                Debug.WriteLine("annotation Deployment creates deployment for {0}.{1}",
                                ClassNameUtil.GetClassNameWithoutPackage(testClass), methodName);
                var resources = deploymentAnnotation.Resources;
                if ((resources.Length == 0) && (method != null))
                {
                    var name     = onMethod ? method.Name : null;
                    var resource = GetBpmnProcessDefinitionResource(testClass, name);
                    resources = new[] { resource };
                }
                if (methodName.IndexOf("_") > -1)
                {
                    methodName = methodName.Split('_')[1];
                }
                var deploymentBuilder =
                    processEngine.RepositoryService.CreateDeployment()
                    .Name(ClassNameUtil.GetClassNameWithoutPackage(testClass) + "." + methodName);

                foreach (var resource in resources)
                {
                    Log.LogDebug("加载资源文件:", resource);
                    deploymentBuilder.AddClasspathResource(resource);
                }


                deploymentId = deploymentBuilder.Deploy().Id;
            }

            return(deploymentId);
        }
Esempio n. 9
0
 public override string ToString()
 {
     return(operationType + " " + ClassNameUtil.GetClassNameWithoutPackage(entity) + "[" + entity.Id + "]");
 }
Esempio n. 10
0
 public virtual void debugFinishingCommand <T1>(Command <T1> cmd)
 {
     logDebug("006", "Finishing command -------------------- {} ----------------------", ClassNameUtil.getClassNameWithoutPackage(cmd));
 }
Esempio n. 11
0
 public virtual void DebugFinishingCommand <T1>(ICommand <T1> cmd)
 {
     LogDebug("006", "Finishing command -------------------- {0} ----------------------",
              ClassNameUtil.GetClassNameWithoutPackage(cmd));
 }
Esempio n. 12
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);
        }
Esempio n. 13
0
 public static void annotationDeploymentTearDown(ProcessEngine processEngine, string deploymentId, Type testClass, string methodName)
 {
     LOG.debug("annotation @Deployment deletes deployment for {}.{}", ClassNameUtil.getClassNameWithoutPackage(testClass), methodName);
     deleteDeployment(processEngine, deploymentId);
 }