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.SetProcessEngineName(GetType().FullName + "-engine1"); //standaloneProcessEngineConfiguration.JdbcUrl = "jdbc:h2:mem:jobexecutor-test-engine"; standaloneProcessEngineConfiguration.SetJobExecutorActivate(false); standaloneProcessEngineConfiguration.SetJobExecutor(_jobExecutor); standaloneProcessEngineConfiguration.SetDbMetricsReporterActivate(false); var engine = standaloneProcessEngineConfiguration.BuildProcessEngine(); _createdProcessEngines.Add(engine); engine.RepositoryService.CreateDeployment().AddClasspathResource(ProcessResource).Deploy(); _jobExecutor.Shutdown(); engine.RuntimeService.StartProcessInstanceByKey("intermediateTimerEventExample"); Assert.AreEqual(1, engine.ManagementService.CreateJobQuery().Count()); ClockUtil.CurrentTime = DateTime.Now.AddDays(6); _jobExecutor.Start(); WaitForJobExecutorToProcessAllJobs(10000, 100, _jobExecutor, engine.RuntimeService, true); Assert.AreEqual(0, engine.ManagementService.CreateJobQuery().Count()); }
private IProcessEngine CreateProcessEngine(string name) { StandaloneInMemProcessEngineConfiguration processEngineConfiguration = new StandaloneInMemProcessEngineConfiguration(); processEngineConfiguration.SetProcessEngineName(name); processEngineConfiguration.JdbcUrl = string.Format("jdbc:h2:mem:{0}", name); return(processEngineConfiguration.BuildProcessEngine()); }
public virtual void TestExecuteJobsForTwoEnginesSameAcquisition() { // 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.SetProcessEngineName(GetType().FullName + "-engine1"); //engineConfiguration1.JdbcUrl = "jdbc:h2:mem:activiti1"; engineConfiguration1.SetJobExecutorActivate(false); engineConfiguration1.SetJobExecutor(_jobExecutor); engineConfiguration1.SetDbMetricsReporterActivate(false); var 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.SetProcessEngineName(GetType().FullName + "engine2"); //engineConfiguration2.JdbcUrl = "jdbc:h2:mem:activiti2"; engineConfiguration2.SetJobExecutorActivate(false); engineConfiguration2.SetJobExecutor(_jobExecutor); engineConfiguration2.SetDbMetricsReporterActivate(false); var engine2 = engineConfiguration2.BuildProcessEngine(); _createdProcessEngines.Add(engine2); // stop the acquisition _jobExecutor.Shutdown(); // deploy the processes engine1.RepositoryService.CreateDeployment().AddClasspathResource(ProcessResource).Deploy(); engine2.RepositoryService.CreateDeployment().AddClasspathResource(ProcessResource).Deploy(); // start one instance for each engine: var procinst1 = engine1.RuntimeService.StartProcessInstanceByKey("intermediateTimerEventExample"); var procinst2 = engine2.RuntimeService.StartProcessInstanceByKey("intermediateTimerEventExample"); Assert.AreEqual(1, engine1.ManagementService.CreateJobQuery().Count(c => c.ProcessInstanceId == procinst1.Id)); Assert.AreEqual(1, engine2.ManagementService.CreateJobQuery().Count(c => c.ProcessInstanceId == procinst2.Id)); ClockUtil.CurrentTime = DateTime.Now.AddDays(6); _jobExecutor.Start(); // Assert task completed for the first engine WaitForJobExecutorToProcessAllJobs(10000, 100, _jobExecutor, engine1.RuntimeService, true); _jobExecutor.Start(); // Assert task completed for the second engine WaitForJobExecutorToProcessAllJobs(10000, 100, _jobExecutor, engine2.RuntimeService, true); Assert.AreEqual(0, engine1.ManagementService.CreateJobQuery().Count(c => c.ProcessInstanceId == procinst1.Id)); Assert.AreEqual(0, engine2.ManagementService.CreateJobQuery().Count(c => c.ProcessInstanceId == procinst2.Id)); }