Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCapExcessiveComExceptionLogging() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCapExcessiveComExceptionLogging()
        {
            OngoingStubbing <Response <Void> > updatePullStubbing = when(_master.pullUpdates(any(typeof(RequestContext))));

            updatePullStubbing.thenThrow(new ComException());

            for (int i = 0; i < SlaveUpdatePuller.LogCap + 20; i++)
            {
                _updatePuller.pullUpdates();
            }

            _logProvider.assertContainsThrowablesMatching(0, Repeat(new ComException(), SlaveUpdatePuller.LogCap));

            // And we should be able to recover afterwards
            updatePullStubbing.thenReturn(Response.empty()).thenThrow(new ComException());

            _updatePuller.pullUpdates();               // This one will succeed and unlock the circuit breaker
            _updatePuller.pullUpdates();               // And then we log another exception

            _logProvider.assertContainsThrowablesMatching(0, Repeat(new ComException(), SlaveUpdatePuller.LogCap + 1));
        }