public virtual void testCompetingJobAcquisitions()
        {
            runtimeService.StartProcessInstanceByKey("CompetingJobAcquisitionProcess");

            Debug.WriteLine("test thread starts thread one");
            JobAcquisitionThread threadOne = new JobAcquisitionThread(this);

            threadOne.startAndWaitUntilControlIsReturned();

            Debug.WriteLine("test thread continues to start thread two");
            JobAcquisitionThread threadTwo = new JobAcquisitionThread(this);

            threadTwo.startAndWaitUntilControlIsReturned();

            Debug.WriteLine("test thread notifies thread 1");
            threadOne.proceedAndWaitTillDone();
            Assert.IsNull(threadOne.exception);
            // the job was acquired
            Assert.AreEqual(1, threadOne.jobs.Size());

            Debug.WriteLine("test thread notifies thread 2");
            threadTwo.proceedAndWaitTillDone();
            // the acquisition did NOT Assert.Fail
            Assert.IsNull(threadTwo.exception);
            // but the job was not acquired
            Assert.AreEqual(0, threadTwo.jobs.Size());
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testCompetingJobAcquisitions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testCompetingJobAcquisitions()
        {
            runtimeService.startProcessInstanceByKey("CompetingJobAcquisitionProcess");

            LOG.debug("test thread starts thread one");
            JobAcquisitionThread threadOne = new JobAcquisitionThread(this);

            threadOne.startAndWaitUntilControlIsReturned();

            LOG.debug("test thread continues to start thread two");
            JobAcquisitionThread threadTwo = new JobAcquisitionThread(this);

            threadTwo.startAndWaitUntilControlIsReturned();

            LOG.debug("test thread notifies thread 1");
            threadOne.proceedAndWaitTillDone();
            assertNull(threadOne.exception);
            // the job was acquired
            assertEquals(1, threadOne.jobs.size());

            LOG.debug("test thread notifies thread 2");
            threadTwo.proceedAndWaitTillDone();
            // the acquisition did NOT fail
            assertNull(threadTwo.exception);
            // but the job was not acquired
            assertEquals(0, threadTwo.jobs.size());
        }
예제 #3
0
        public virtual void testCompletingSuspendJobDuringAcquisition()
        {
            testRule.Deploy(SIMPLE_ASYNC_PROCESS);

            runtimeService.StartProcessInstanceByKey("simpleAsyncProcess");

            // given a waiting acquisition and a waiting suspension
            JobAcquisitionThread acquisitionThread = new JobAcquisitionThread(this);

            acquisitionThread.startAndWaitUntilControlIsReturned();

            JobSuspensionThread jobSuspensionThread = new JobSuspensionThread(this, "simpleAsyncProcess");

            jobSuspensionThread.startAndWaitUntilControlIsReturned();

            // first complete suspension:
            jobSuspensionThread.proceedAndWaitTillDone();
            acquisitionThread.proceedAndWaitTillDone();

            // then the acquisition will not Assert.Fail with optimistic locking
            Assert.IsNull(jobSuspensionThread.exception);
            Assert.IsNull(acquisitionThread.exception);
            // but the job will also not be acquired
            Assert.AreEqual(0, acquisitionThread.acquiredJobs.Size());

            //--------------------------------------------

            // given a waiting acquisition and a waiting suspension
            acquisitionThread = new JobAcquisitionThread(this);
            acquisitionThread.startAndWaitUntilControlIsReturned();

            jobSuspensionThread = new JobSuspensionThread(this, "simpleAsyncProcess");
            jobSuspensionThread.startAndWaitUntilControlIsReturned();

            // first complete acquisition:
            acquisitionThread.proceedAndWaitTillDone();
            jobSuspensionThread.proceedAndWaitTillDone();

            // then there are no optimistic locking exceptions
            Assert.IsNull(jobSuspensionThread.exception);
            Assert.IsNull(acquisitionThread.exception);
        }
예제 #4
0
 protected override void StartExecutingJobs()
 {
     JobAcquisitionThread.Start();
 }