@Test
public void testLogErrorMsgAndThrowableWaitDefaultExceedsMaxCount() throws Exception {

  final String expectedErrorMessage = "This is a test error message that should only repeat once!";
  final Exception expectedException = new Exception("test exception");
  EasyMockSupport mockSupport =
    new EasyMockSupport();
  Logger loggerMock =
    mockSupport.createMock(Logger.class);
  AtomicInteger testAtomicInteger = new AtomicInteger(0);
  Capture<Exception> exceptionCaptureOne = EasyMock.newCapture();
  Capture<Exception> exceptionCaptureTwo = EasyMock.newCapture();
  // expect that the the call to the logger is only
  // executed twice in this test
  loggerMock.error(eq(expectedErrorMessage), capture(exceptionCaptureOne));
  loggerMock.error(eq(expectedErrorMessage), capture(exceptionCaptureTwo));
  mockSupport.replayAll();
  for (int i = 0; i < 2000; i++) {
    Utils.logErrorMessageWithThrowableWithCounter(loggerMock, testAtomicInteger, expectedErrorMessage, expectedException);
  }
  assertSame("Exception passed to Logger should have been the same instance passed into the Utils method",
    expectedException, exceptionCaptureOne.getValue());
  assertSame("Exception passed to Logger should have been the same instance passed into the Utils method",
    expectedException, exceptionCaptureTwo.getValue());
  mockSupport.verifyAll();
}