//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 10_000) public void scheduledTasksThatThrowsMustPropagateException() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ScheduledTasksThatThrowsMustPropagateException() { CentralJobScheduler scheduler = new CentralJobScheduler(); scheduler.Init(); Exception boom = new Exception("boom"); AtomicInteger triggerCounter = new AtomicInteger(); ThreadStart job = () => { triggerCounter.incrementAndGet(); throw boom; }; JobHandle handle = scheduler.ScheduleRecurring(Group.INDEX_POPULATION, job, 1, TimeUnit.MILLISECONDS); try { handle.WaitTermination(); fail("waitTermination should have failed."); } catch (ExecutionException e) { assertThat(e.InnerException, @is(boom)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(timeout = 10_000) public void scheduledTasksThatThrowsShouldStop() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ScheduledTasksThatThrowsShouldStop() { CentralJobScheduler scheduler = new CentralJobScheduler(); scheduler.Init(); BinaryLatch triggerLatch = new BinaryLatch(); Exception boom = new Exception("boom"); AtomicInteger triggerCounter = new AtomicInteger(); ThreadStart job = () => { triggerCounter.incrementAndGet(); triggerLatch.Release(); throw boom; }; scheduler.ScheduleRecurring(Group.INDEX_POPULATION, job, 1, TimeUnit.MILLISECONDS); triggerLatch.Await(); Thread.Sleep(50); assertThat(triggerCounter.get(), @is(1)); }