Search in sources :

Example 1 with FixedSizeFutureStore

use of org.bboxdb.network.client.tools.FixedSizeFutureStore in project bboxdb by jnidzwetzki.

the class TestFixedFutureStore method testTupleStore3.

/**
 * Add more futures in failed state and count failed callbacks
 * @throws InterruptedException
 */
@Test(timeout = 5000)
public void testTupleStore3() throws InterruptedException {
    final FixedSizeFutureStore futureStore = new FixedSizeFutureStore(10);
    final AtomicInteger atomicInteger = new AtomicInteger(0);
    futureStore.addFailedFutureCallback(c -> {
        atomicInteger.incrementAndGet();
    });
    for (int i = 0; i < 20; i++) {
        final NetworkOperationFuture networkOperationFuture = TestFuture.getFailingNetworkFuture();
        final EmptyResultFuture future = new EmptyResultFuture(networkOperationFuture);
        futureStore.put(future);
    }
    futureStore.waitForCompletion();
    Assert.assertTrue(true);
    Assert.assertEquals(20, atomicInteger.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) FixedSizeFutureStore(org.bboxdb.network.client.tools.FixedSizeFutureStore) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 2 with FixedSizeFutureStore

use of org.bboxdb.network.client.tools.FixedSizeFutureStore in project bboxdb by jnidzwetzki.

the class TestFixedFutureStore method testTupleStore2.

/**
 * Add more futures in done state
 */
@Test(timeout = 5000)
public void testTupleStore2() {
    final FixedSizeFutureStore futureStore = new FixedSizeFutureStore(10);
    // Fail test on failed callback
    futureStore.addFailedFutureCallback(c -> {
        Assert.assertTrue(false);
    });
    for (int i = 0; i < 20; i++) {
        final EmptyResultFuture future = new EmptyResultFuture(() -> (new ArrayList<>()));
        futureStore.put(future);
    }
    Assert.assertTrue(true);
}
Also used : ArrayList(java.util.ArrayList) FixedSizeFutureStore(org.bboxdb.network.client.tools.FixedSizeFutureStore) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Example 3 with FixedSizeFutureStore

use of org.bboxdb.network.client.tools.FixedSizeFutureStore in project bboxdb by jnidzwetzki.

the class TestFixedFutureStore method testTupleStore1.

/**
 * Add more futures in failed state
 */
@Test(timeout = 5000)
public void testTupleStore1() {
    final FixedSizeFutureStore futureStore = new FixedSizeFutureStore(10);
    for (int i = 0; i < 20; i++) {
        final EmptyResultFuture future = new EmptyResultFuture(() -> (new ArrayList<>()));
        futureStore.put(future);
    }
}
Also used : ArrayList(java.util.ArrayList) FixedSizeFutureStore(org.bboxdb.network.client.tools.FixedSizeFutureStore) EmptyResultFuture(org.bboxdb.network.client.future.EmptyResultFuture) Test(org.junit.Test)

Aggregations

EmptyResultFuture (org.bboxdb.network.client.future.EmptyResultFuture)3 FixedSizeFutureStore (org.bboxdb.network.client.tools.FixedSizeFutureStore)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)1