@Test
public void countSuppressedExceptions() {

    try {
        CompletionExceptionLogHelper.forceSetMaxSuppressedCountForTesting(0);
        final Exception base = createRuntimeException();
        Exception e0 = createCompletionException(base);
        Exception e1 = createCompletionException(base);
        assertEquals(base, FDBExceptions.wrapException(e0));
        assertEquals(base, FDBExceptions.wrapException(e1));
        Throwable[] suppressedExceptions = base.getSuppressed();
        assertEquals(1, suppressedExceptions.length);
        assertThat(Arrays.asList(suppressedExceptions), not(anyOf(Matchers.<Throwable>hasItem(e0), hasItem(e1))));
        Throwable countException = suppressedExceptions[0];
        assertThat(countException, instanceOf(CompletionExceptionLogHelper.IgnoredSuppressedExceptionCount.class));
        assertEquals(2, ((CompletionExceptionLogHelper.IgnoredSuppressedExceptionCount)countException).getCount());
    } finally {
        CompletionExceptionLogHelper.forceSetMaxSuppressedCountForTesting(Integer.MAX_VALUE); //cleanup
    }
}