Example #1
0
        public virtual void testDeleteJobThatWasAlreadyAcquired()
        {
            ClockUtil.CurrentTime = DateTime.Now;

            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
            Job             timerJob        = managementService.createJobQuery().processInstanceId(processInstance.Id).singleResult();

            // We need to move time at least one hour to make the timer executable
            ClockUtil.CurrentTime = new DateTime(ClockUtil.CurrentTime.Ticks + 7200000L);

            // Acquire job by running the acquire command manually
            ProcessEngineImpl processEngineImpl = (ProcessEngineImpl)processEngine;
            JobExecutor       jobExecutor       = processEngineImpl.ProcessEngineConfiguration.JobExecutor;
            AcquireJobsCmd    acquireJobsCmd    = new AcquireJobsCmd(jobExecutor);
            CommandExecutor   commandExecutor   = processEngineImpl.ProcessEngineConfiguration.CommandExecutorTxRequired;

            commandExecutor.execute(acquireJobsCmd);

            // Try to delete the job. This should fail.
            try
            {
                managementService.deleteJob(timerJob.Id);
                fail();
            }
            catch (ProcessEngineException)
            {
                // Exception is expected
            }

            // Clean up
            managementService.executeJob(timerJob.Id);
        }
            public override AcquiredJobs Execute(CommandContext commandContext)
            {
                Monitor.Sync(); // Wait till makeContinue() is called from test thread

                var acquiredJobs = new AcquireJobsCmd(_outerInstance, _numJobsToAcquire).Execute(commandContext);

                Monitor.Sync(); // Wait till makeContinue() is called from test thread

                return(acquiredJobs);
            }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void initCommand()
        public virtual void initCommand()
        {
            JobExecutor jobExecutor = mock(typeof(JobExecutor));

            when(jobExecutor.MaxJobsPerAcquisition).thenReturn(3);
            when(jobExecutor.LockOwner).thenReturn("test");
            when(jobExecutor.LockTimeInMillis).thenReturn(5 * 60 * 1000);

            acquireJobsCmd = new AcquireJobsCmd(jobExecutor);

            commandContext = mock(typeof(CommandContext));

            DbEntityManager dbEntityManager = mock(typeof(DbEntityManager));

            when(commandContext.DbEntityManager).thenReturn(dbEntityManager);

            jobManager = mock(typeof(JobManager));
            when(commandContext.JobManager).thenReturn(jobManager);
        }
        public void InitCommand()
        {
            try
            {
                var jobExecutor = Substitute.For <ESS.FW.Bpm.Engine.Impl.JobExecutor.JobExecutor>();
                jobExecutor.MaxJobsPerAcquisition.Returns(3);
                jobExecutor.LockOwner.Returns("test");
                jobExecutor.LockTimeInMillis.Returns(5 * 60 * 1000);

                acquireJobsCmd = new AcquireJobsCmd(jobExecutor);

                commandContext = Substitute.For <CommandContext>();

                jobManager = Substitute.For <IJobManager>();
                commandContext.JobManager.Returns(jobManager);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }