Search in sources :

Example 1 with TupleListFutureStore

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

the class TestTupleListFuture method testFiftyFutures.

@Test(timeout = 60000)
public void testFiftyFutures() throws InterruptedException, RejectedException {
    final TupleListFutureStore tupleListFutureStore = new TupleListFutureStore();
    final List<TestTupleListFuture> futures = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
        final TestTupleListFuture testFuture = new TestTupleListFuture();
        tupleListFutureStore.put(testFuture);
        futures.add(testFuture);
    }
    System.out.println("Wait for completion");
    tupleListFutureStore.waitForCompletion();
    System.out.println("Shutdown...");
    tupleListFutureStore.shutdown();
    final boolean hasNonFinishedIterators = futures.stream().anyMatch(f -> f.getIteratorCalls() != TestTupleListFuture.ELEMENTS);
    Assert.assertFalse(hasNonFinishedIterators);
}
Also used : ArrayList(java.util.ArrayList) TupleListFutureStore(org.bboxdb.network.client.tools.TupleListFutureStore) Test(org.junit.Test)

Example 2 with TupleListFutureStore

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

the class TestTupleListFuture method testOneFuture.

@Test(timeout = 60000)
public void testOneFuture() throws InterruptedException, RejectedException {
    final TupleListFutureStore tupleListFutureStore = new TupleListFutureStore();
    final TestTupleListFuture testFuture = new TestTupleListFuture();
    Assert.assertEquals(testFuture.getIteratorCalls(), 0);
    tupleListFutureStore.put(testFuture);
    System.out.println("Wait for completion");
    tupleListFutureStore.waitForCompletion();
    System.out.println("Shutdown...");
    tupleListFutureStore.shutdown();
    Assert.assertEquals(testFuture.getIteratorCalls(), TestTupleListFuture.ELEMENTS);
}
Also used : TupleListFutureStore(org.bboxdb.network.client.tools.TupleListFutureStore) Test(org.junit.Test)

Example 3 with TupleListFutureStore

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

the class TestTupleListFuture method testEmptyFutureStoreWait.

@Test(timeout = 1000)
public void testEmptyFutureStoreWait() throws InterruptedException {
    final TupleListFutureStore tupleListFutureStore = new TupleListFutureStore();
    Assert.assertTrue(tupleListFutureStore.getServiceState().isInRunningState());
    tupleListFutureStore.waitForCompletion();
    tupleListFutureStore.shutdown();
    Assert.assertTrue(tupleListFutureStore.getServiceState().isInShutdownState());
}
Also used : TupleListFutureStore(org.bboxdb.network.client.tools.TupleListFutureStore) Test(org.junit.Test)

Example 4 with TupleListFutureStore

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

the class TestTupleListFuture method testDefaultValues.

@Test(timeout = 60000)
public void testDefaultValues() {
    final TupleListFutureStore tupleListFutureStore = new TupleListFutureStore();
    Assert.assertEquals(TupleListFutureStore.DEFAULT_MAX_QUEUE_SIZE, tupleListFutureStore.getMaxQueueSize());
    Assert.assertEquals(TupleListFutureStore.DEFAULT_REQUEST_WORKER, tupleListFutureStore.getRequestWorker());
    tupleListFutureStore.shutdown();
}
Also used : TupleListFutureStore(org.bboxdb.network.client.tools.TupleListFutureStore) Test(org.junit.Test)

Example 5 with TupleListFutureStore

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

the class TestTupleListFuture method testRejectedExeption.

@Test(expected = RejectedException.class)
public void testRejectedExeption() throws InterruptedException, RejectedException {
    final TupleListFutureStore tupleListFutureStore = new TupleListFutureStore();
    tupleListFutureStore.shutdown();
    final BBoxDBConnection connection = Mockito.mock(BBoxDBConnection.class);
    final Supplier<NetworkRequestPackage> supplier = () -> (null);
    final NetworkOperationFuture networkOperationFuture = new NetworkOperationFuture(connection, supplier);
    tupleListFutureStore.put(new TupleListFuture(networkOperationFuture, new DoNothingDuplicateResolver(), ""));
}
Also used : NetworkRequestPackage(org.bboxdb.network.packages.NetworkRequestPackage) TupleListFuture(org.bboxdb.network.client.future.TupleListFuture) NetworkOperationFuture(org.bboxdb.network.client.future.NetworkOperationFuture) DoNothingDuplicateResolver(org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver) BBoxDBConnection(org.bboxdb.network.client.BBoxDBConnection) TupleListFutureStore(org.bboxdb.network.client.tools.TupleListFutureStore) Test(org.junit.Test)

Aggregations

TupleListFutureStore (org.bboxdb.network.client.tools.TupleListFutureStore)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)1 BBoxDBConnection (org.bboxdb.network.client.BBoxDBConnection)1 NetworkOperationFuture (org.bboxdb.network.client.future.NetworkOperationFuture)1 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)1 NetworkRequestPackage (org.bboxdb.network.packages.NetworkRequestPackage)1 DoNothingDuplicateResolver (org.bboxdb.storage.sstable.duplicateresolver.DoNothingDuplicateResolver)1