Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 5_000) public void shouldNotAllowNewJobsAfterBeingStopped()
        public virtual void ShouldNotAllowNewJobsAfterBeingStopped()
        {
            // Given
            IndexSamplingJobTracker jobTracker = new IndexSamplingJobTracker(_config, mock(typeof(JobScheduler)));

            // When
            jobTracker.StopAndAwaitAllJobs();

            // Then
            assertFalse(jobTracker.CanExecuteMoreSamplingJobs());
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 5_000) public void shouldDoNothingWhenUsedAfterBeingStopped()
        public virtual void ShouldDoNothingWhenUsedAfterBeingStopped()
        {
            // Given
            JobScheduler            scheduler  = mock(typeof(JobScheduler));
            IndexSamplingJobTracker jobTracker = new IndexSamplingJobTracker(_config, scheduler);

            jobTracker.StopAndAwaitAllJobs();

            // When
            jobTracker.ScheduleSamplingJob(mock(typeof(IndexSamplingJob)));

            // Then
            verifyZeroInteractions(scheduler);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(timeout = 5_000) public void shouldStopAndWaitForAllJobsToFinish() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldStopAndWaitForAllJobsToFinish()
        {
            // Given
            when(_config.jobLimit()).thenReturn(2);

            JobScheduler jobScheduler = createInitialisedScheduler();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final IndexSamplingJobTracker jobTracker = new IndexSamplingJobTracker(config, jobScheduler);
            IndexSamplingJobTracker jobTracker = new IndexSamplingJobTracker(_config, jobScheduler);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch latch1 = new java.util.concurrent.CountDownLatch(1);
            System.Threading.CountdownEvent latch1 = new System.Threading.CountdownEvent(1);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch latch2 = new java.util.concurrent.CountDownLatch(1);
            System.Threading.CountdownEvent latch2 = new System.Threading.CountdownEvent(1);

            WaitingIndexSamplingJob job1 = new WaitingIndexSamplingJob(IndexId11, latch1);
            WaitingIndexSamplingJob job2 = new WaitingIndexSamplingJob(IndexId22, latch1);

            jobTracker.ScheduleSamplingJob(job1);
            jobTracker.ScheduleSamplingJob(job2);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.concurrent.Future<?> stopping = java.util.concurrent.Executors.newSingleThreadExecutor().submit(() ->
            Future <object> stopping = Executors.newSingleThreadExecutor().submit(() =>
            {
                latch2.Signal();
                jobTracker.StopAndAwaitAllJobs();
            });

            // When
            latch2.await();
            assertFalse(stopping.Done);
            latch1.Signal();
            stopping.get(10, SECONDS);

            // Then
            assertTrue(stopping.Done);
            assertNull(stopping.get());
            assertTrue(job1.Executed);
            assertTrue(job2.Executed);
        }