Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void oneOffJobWithExceptionShouldLog() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OneOffJobWithExceptionShouldLog()
        {
            // given
            Log log = mock(typeof(Log));
            RobustJobSchedulerWrapper robustWrapper = new RobustJobSchedulerWrapper(_actualScheduler, log);

            AtomicInteger count = new AtomicInteger();

            System.InvalidOperationException e = new System.InvalidOperationException();

            // when
            JobHandle jobHandle = robustWrapper.Schedule(Group.HZ_TOPOLOGY_HEALTH, 100, () =>
            {
                count.incrementAndGet();
                throw e;
            });

            // then
            assertEventually("run count", count.get, Matchers.equalTo(1), _defaultTimeoutMs, MILLISECONDS);
            jobHandle.WaitTermination();
            verify(log, timeout(_defaultTimeoutMs).times(1)).warn("Uncaught exception", e);
        }