Example #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNoticeBadHealthBeforeBeingClosed()
        public virtual void ShouldNoticeBadHealthBeforeBeingClosed()
        {
            // GIVEN
            TaskExecutor <Void> executor = new DynamicTaskExecutor <Void>(1, 2, 2, _park, "test");
            Exception           panic    = new Exception("My failure");

            // WHEN
            executor.ReceivePanic(panic);

            try
            {
                // THEN
                executor.AssertHealthy();
                fail("Should have failed");
            }
            catch (TaskExecutionPanicException e)
            {
                assertSame(panic, e.InnerException);
            }

            // and WHEN
            executor.Close();

            try
            {
                // THEN
                executor.AssertHealthy();
                fail("Should have failed");
            }
            catch (TaskExecutionPanicException e)
            {
                assertSame(panic, e.InnerException);
            }
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSurfaceTaskErrorInAssertHealthy() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSurfaceTaskErrorInAssertHealthy()
        {
            // GIVEN
            TaskExecutor <Void> executor  = new DynamicTaskExecutor <Void>(2, 0, 10, _park, this.GetType().Name);
            IOException         exception = new IOException("Failure");

            // WHEN
            FailingTask failingTask = new FailingTask(exception);

            executor.Submit(failingTask);
            failingTask.Latch.await();
            failingTask.Latch.release();

            // WHEN
            for (int i = 0; i < 5; i++)
            {
                try
                {
                    executor.AssertHealthy();
                    // OK, so the executor hasn't executed the finally block after task was done yet
                    Thread.Sleep(100);
                }
                catch (Exception e)
                {
                    assertTrue(Exceptions.contains(e, exception.Message, exception.GetType()));
                    return;
                }
            }
            fail("Should not be considered healthy after failing task");
        }