public virtual void TestQueueLimiting() { // Block the underlying fake proxy from actually completing any calls. GenericTestUtils.DelayAnswer delayer = new GenericTestUtils.DelayAnswer(Log); Org.Mockito.Mockito.DoAnswer(delayer).When(mockProxy).Journal(Org.Mockito.Mockito .Any <RequestInfo>(), Org.Mockito.Mockito.Eq(1L), Org.Mockito.Mockito.Eq(1L), Org.Mockito.Mockito .Eq(1), Org.Mockito.Mockito.Same(FakeData)); // Queue up the maximum number of calls. int numToQueue = LimitQueueSizeBytes / FakeData.Length; for (int i = 1; i <= numToQueue; i++) { ch.SendEdits(1L, (long)i, 1, FakeData); } // The accounting should show the correct total number queued. NUnit.Framework.Assert.AreEqual(LimitQueueSizeBytes, ch.GetQueuedEditsSize()); // Trying to queue any more should fail. try { ch.SendEdits(1L, numToQueue + 1, 1, FakeData).Get(1, TimeUnit.Seconds); NUnit.Framework.Assert.Fail("Did not fail to queue more calls after queue was full" ); } catch (ExecutionException ee) { if (!(ee.InnerException is LoggerTooFarBehindException)) { throw; } } delayer.Proceed(); // After we allow it to proceeed, it should chug through the original queue GenericTestUtils.WaitFor(new _Supplier_124(this), 10, 1000); }
public virtual int GetQueuedEditsSize() { return(ch.GetQueuedEditsSize()); }