Search in sources :

Example 1 with Promise

use of org.apache.cassandra.utils.concurrent.Promise in project cassandra by apache.

the class AsyncChannelPromiseTest method testTimeout.

@Test
public void testTimeout() {
    final AtomicInteger initialListeners = new AtomicInteger();
    List<Supplier<Promise<Void>>> suppliers = suppliers(initialListeners, true);
    for (Supplier<Promise<Void>> supplier : suppliers) testOneTimeout(supplier.get());
    Assert.assertEquals(0, initialListeners.get());
}
Also used : AbstractTestAsyncPromise(org.apache.cassandra.utils.concurrent.AbstractTestAsyncPromise) Promise(org.apache.cassandra.utils.concurrent.Promise) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Supplier(java.util.function.Supplier) Test(org.junit.Test)

Example 2 with Promise

use of org.apache.cassandra.utils.concurrent.Promise in project cassandra by apache.

the class AsyncChannelPromiseTest method testFailure.

@Test
public void testFailure() {
    final AtomicInteger initialListeners = new AtomicInteger();
    List<Supplier<Promise<Void>>> suppliers = suppliers(initialListeners, true);
    for (boolean tryOrSet : new boolean[] { false, true }) for (Throwable v : new Throwable[] { null, new NullPointerException() }) for (Supplier<Promise<Void>> supplier : suppliers) testOneFailure(supplier.get(), tryOrSet, v, null);
    Assert.assertEquals(2 * 2 * 2, initialListeners.get());
}
Also used : AbstractTestAsyncPromise(org.apache.cassandra.utils.concurrent.AbstractTestAsyncPromise) Promise(org.apache.cassandra.utils.concurrent.Promise) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Supplier(java.util.function.Supplier) Test(org.junit.Test)

Aggregations

AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Supplier (java.util.function.Supplier)2 AbstractTestAsyncPromise (org.apache.cassandra.utils.concurrent.AbstractTestAsyncPromise)2 Promise (org.apache.cassandra.utils.concurrent.Promise)2 Test (org.junit.Test)2