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);
}
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);
}
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());
}
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();
}
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(), ""));
}
Aggregations