use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testJoinSucceeded.
private void testJoinSucceeded(BiFunction<Future<String>, Future<Integer>, CompositeFuture> join) {
Future<String> f1 = Future.future();
Future<Integer> f2 = Future.future();
CompositeFuture composite = join.apply(f1, f2);
Checker<CompositeFuture> checker = new Checker<>(composite);
checker.assertNotCompleted();
f1.complete("foo");
checker.assertNotCompleted();
f2.complete();
checker.assertSucceeded(composite);
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testJoinFailed3.
private void testJoinFailed3(BiFunction<Future<String>, Future<Integer>, CompositeFuture> join) {
Future<String> f1 = Future.future();
Future<Integer> f2 = Future.future();
CompositeFuture composite = join.apply(f1, f2);
Checker<CompositeFuture> checker = new Checker<>(composite);
checker.assertNotCompleted();
Throwable cause1 = new Throwable();
f1.fail(cause1);
checker.assertNotCompleted();
Throwable cause2 = new Throwable();
f2.fail(cause2);
assertSame(cause1, checker.assertFailed());
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testAnyLargeList.
private void testAnyLargeList(int size) {
List<Future> list = new ArrayList<>();
for (int i = 0; i < size; i++) {
list.add(Future.failedFuture(new Exception()));
}
CompositeFuture composite = CompositeFuture.any(list);
Checker<CompositeFuture> checker = new Checker<>(composite);
checker.assertFailed();
for (int i = 0; i < size; i++) {
list.clear();
for (int j = 0; j < size; j++) {
list.add(i == j ? Future.succeededFuture() : Future.failedFuture(new RuntimeException()));
}
composite = CompositeFuture.any(list);
checker = new Checker<>(composite);
checker.assertSucceeded(composite);
for (int j = 0; j < size; j++) {
if (i == j) {
assertTrue(composite.succeeded(j));
} else {
assertTrue(composite.failed(j));
}
}
}
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testAnyFailed.
private void testAnyFailed(BiFunction<Future<String>, Future<Integer>, CompositeFuture> any) {
Future<String> f1 = Future.future();
Future<Integer> f2 = Future.future();
CompositeFuture composite = any.apply(f1, f2);
Checker<CompositeFuture> checker = new Checker<>(composite);
f1.fail("failure");
checker.assertNotCompleted();
Throwable cause = new Exception();
f2.fail(cause);
checker.assertFailed(cause);
}
use of io.vertx.core.CompositeFuture in project vert.x by eclipse.
the class FutureTest method testAnyWithEmptyList.
@Test
public void testAnyWithEmptyList() {
CompositeFuture composite = CompositeFuture.any(Collections.emptyList());
assertTrue(composite.isComplete());
}
Aggregations