//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAcceptMoreJobsThanAllowed() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAcceptMoreJobsThanAllowed() { // given when(_config.jobLimit()).thenReturn(1); 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 org.neo4j.test.DoubleLatch latch = new org.neo4j.test.DoubleLatch(); DoubleLatch latch = new DoubleLatch(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.test.DoubleLatch waitingLatch = new org.neo4j.test.DoubleLatch(); DoubleLatch waitingLatch = new DoubleLatch(); // when assertTrue(jobTracker.CanExecuteMoreSamplingJobs()); jobTracker.ScheduleSamplingJob(new IndexSamplingJobAnonymousInnerClass2(this, latch)); // then latch.WaitForAllToStart(); assertFalse(jobTracker.CanExecuteMoreSamplingJobs()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean waiting = new java.util.concurrent.atomic.AtomicBoolean(false); AtomicBoolean waiting = new AtomicBoolean(false); (new Thread(() => { waiting.set(true); waitingLatch.StartAndWaitForAllToStart(); jobTracker.WaitUntilCanExecuteMoreSamplingJobs(); waiting.set(false); waitingLatch.Finish(); })).Start(); waitingLatch.WaitForAllToStart(); assertTrue(waiting.get()); latch.Finish(); waitingLatch.WaitForAllToFinish(); assertFalse(waiting.get()); // eventually we accept new jobs while (!jobTracker.CanExecuteMoreSamplingJobs()) { Thread.yield(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotRunASampleJobWhichIsAlreadyRunning() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotRunASampleJobWhichIsAlreadyRunning() { // given when(_config.jobLimit()).thenReturn(2); JobScheduler jobScheduler = createInitialisedScheduler(); IndexSamplingJobTracker jobTracker = new IndexSamplingJobTracker(_config, jobScheduler); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.test.DoubleLatch latch = new org.neo4j.test.DoubleLatch(); DoubleLatch latch = new DoubleLatch(); // when //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicInteger count = new java.util.concurrent.atomic.AtomicInteger(0); AtomicInteger count = new AtomicInteger(0); assertTrue(jobTracker.CanExecuteMoreSamplingJobs()); IndexSamplingJob job = new IndexSamplingJobAnonymousInnerClass(this, latch, count); jobTracker.ScheduleSamplingJob(job); jobTracker.ScheduleSamplingJob(job); latch.StartAndWaitForAllToStart(); latch.WaitForAllToFinish(); assertEquals(1, count.get()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 5_000) public void shouldAcceptNewJobWhenRunningJobFinishes() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldAcceptNewJobWhenRunningJobFinishes() { // Given when(_config.jobLimit()).thenReturn(1); 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 org.neo4j.test.DoubleLatch latch = new org.neo4j.test.DoubleLatch(); DoubleLatch latch = new DoubleLatch(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean lastJobExecuted = new java.util.concurrent.atomic.AtomicBoolean(); AtomicBoolean lastJobExecuted = new AtomicBoolean(); jobTracker.ScheduleSamplingJob(new IndexSamplingJobAnonymousInnerClass3(this, latch)); // When Executors.newSingleThreadExecutor().execute(() => { jobTracker.WaitUntilCanExecuteMoreSamplingJobs(); jobTracker.ScheduleSamplingJob(new IndexSamplingJobAnonymousInnerClass4(this, latch, lastJobExecuted)); }); assertFalse(jobTracker.CanExecuteMoreSamplingJobs()); latch.StartAndWaitForAllToStart(); latch.WaitForAllToFinish(); // Then assertTrue(lastJobExecuted.get()); }
//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()); }