Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testExecuteJobsForSingleEngine()
        public virtual void testExecuteJobsForSingleEngine()
        {
            // configure and build a process engine
            StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneInMemProcessEngineConfiguration();

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            standaloneProcessEngineConfiguration.ProcessEngineName         = this.GetType().FullName + "-engine1";
            standaloneProcessEngineConfiguration.JdbcUrl                   = "jdbc:h2:mem:jobexecutor-test-engine";
            standaloneProcessEngineConfiguration.JobExecutorActivate       = false;
            standaloneProcessEngineConfiguration.JobExecutor               = jobExecutor;
            standaloneProcessEngineConfiguration.DbMetricsReporterActivate = false;
            ProcessEngine engine = standaloneProcessEngineConfiguration.buildProcessEngine();

            createdProcessEngines.Add(engine);

            engine.RepositoryService.createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();

            jobExecutor.shutdown();

            engine.RuntimeService.startProcessInstanceByKey("intermediateTimerEventExample");

            Assert.assertEquals(1, engine.ManagementService.createJobQuery().count());

            DateTime calendar = new DateTime();

            calendar.add(Field.DAY_OF_YEAR.CalendarField, 6);
            ClockUtil.CurrentTime = calendar;
            jobExecutor.start();
            waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine.ManagementService, true);

            Assert.assertEquals(0, engine.ManagementService.createJobQuery().count());
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testJobAddedGuardForTwoEnginesSameAcquisition() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testJobAddedGuardForTwoEnginesSameAcquisition()
        {
            // configure and build a process engine
            StandaloneProcessEngineConfiguration engineConfiguration1 = new StandaloneInMemProcessEngineConfiguration();

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            engineConfiguration1.ProcessEngineName         = this.GetType().FullName + "-engine1";
            engineConfiguration1.JdbcUrl                   = "jdbc:h2:mem:activiti1";
            engineConfiguration1.JobExecutorActivate       = false;
            engineConfiguration1.JobExecutor               = jobExecutor;
            engineConfiguration1.DbMetricsReporterActivate = false;
            ProcessEngine engine1 = engineConfiguration1.buildProcessEngine();

            createdProcessEngines.Add(engine1);

            // and a second one
            StandaloneProcessEngineConfiguration engineConfiguration2 = new StandaloneInMemProcessEngineConfiguration();

//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
            engineConfiguration2.ProcessEngineName         = this.GetType().FullName + "engine2";
            engineConfiguration2.JdbcUrl                   = "jdbc:h2:mem:activiti2";
            engineConfiguration2.JobExecutorActivate       = false;
            engineConfiguration2.JobExecutor               = jobExecutor;
            engineConfiguration2.DbMetricsReporterActivate = false;
            ProcessEngine engine2 = engineConfiguration2.buildProcessEngine();

            createdProcessEngines.Add(engine2);

            // stop the acquisition
            jobExecutor.shutdown();

            // deploy the processes

            engine1.RepositoryService.createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();

            engine2.RepositoryService.createDeployment().addClasspathResource(PROCESS_RESOURCE).deploy();

            // start one instance for each engine:

            engine1.RuntimeService.startProcessInstanceByKey("intermediateTimerEventExample");
            engine2.RuntimeService.startProcessInstanceByKey("intermediateTimerEventExample");

            DateTime calendar = new DateTime();

            calendar.add(Field.DAY_OF_YEAR.CalendarField, 6);
            ClockUtil.CurrentTime = calendar;

            Assert.assertEquals(1, engine1.ManagementService.createJobQuery().count());
            Assert.assertEquals(1, engine2.ManagementService.createJobQuery().count());

            // assert task completed for the first engine
            jobExecutor.start();
            waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine1.ManagementService, false);

            // assert task completed for the second engine
            jobExecutor.start();
            waitForJobExecutorToProcessAllJobs(10000, 100, jobExecutor, engine2.ManagementService, false);

            Thread.Sleep(2000);

            Assert.assertFalse(((SequentialJobAcquisitionRunnable)jobExecutor.AcquireJobsRunnable).JobAdded);

            Assert.assertEquals(0, engine1.ManagementService.createJobQuery().count());
            Assert.assertEquals(0, engine2.ManagementService.createJobQuery().count());
        }