@Test
public void testFailedTaskWithMultipleSubmitters()
{

    final AtomicInteger successCount = new AtomicInteger();
    final AtomicInteger failureCount = new AtomicInteger();
    final AtomicInteger concurrency = new AtomicInteger();
    final CountDownLatch startLatch = new CountDownLatch(1);
    final CountDownLatch completionLatch = new CountDownLatch(100);
    AsyncSemaphore<Runnable> asyncSemaphore = new AsyncSemaphore<>(2, executor, task -> {
        throw assertFailedConcurrency(concurrency);
    });
    final Queue<ListenableFuture<?>> futures = new ConcurrentLinkedQueue<>();
    for (int i = 0; i < 100; i++) {
        executor.execute(() -> {
            Uninterruptibles.awaitUninterruptibly(startLatch, 1, TimeUnit.MINUTES);
            // Should never execute this
            ListenableFuture<?> future = asyncSemaphore.submit(Assert::fail);
            futures.add(future);
            addCallback(future, completionCallback(successCount, failureCount, completionLatch), directExecutor());
        });
    }
    // Start the submitters;
    startLatch.countDown();
    // Wait for completion
    Uninterruptibles.awaitUninterruptibly(completionLatch, 1, TimeUnit.MINUTES);
    // Make sure they all report failure
    for (ListenableFuture<?> future : futures) {
        try {
            future.get();
            Assert.fail();
        }
        catch (Exception ignored) {
        }
    }
    Assert.assertEquals(successCount.get(), 0);
    Assert.assertEquals(failureCount.get(), 100);
}