use of io.vertx.junit5.Checkpoint in project vertx-examples by vert-x3.
the class SampleVerticleTest method countThreeTicksWithCheckpoints.
@Test
@DisplayName("⏱ Count 3 timer ticks, with a checkpoint")
void countThreeTicksWithCheckpoints(Vertx vertx, VertxTestContext testContext) {
Checkpoint checkpoint = testContext.checkpoint(3);
vertx.setPeriodic(100, id -> checkpoint.flag());
}
use of io.vertx.junit5.Checkpoint in project vertx-examples by vert-x3.
the class SampleVerticleTest method useSampleVerticle.
@Test
@DisplayName("🚀 Deploy a HTTP service verticle and make 10 requests")
void useSampleVerticle(Vertx vertx, VertxTestContext testContext) {
WebClient webClient = WebClient.create(vertx);
Checkpoint deploymentCheckpoint = testContext.checkpoint();
Checkpoint requestCheckpoint = testContext.checkpoint(10);
vertx.deployVerticle(new SampleVerticle(), testContext.succeeding(id -> {
deploymentCheckpoint.flag();
for (int i = 0; i < 10; i++) {
webClient.get(11981, "localhost", "/").as(BodyCodec.string()).send(testContext.succeeding(resp -> {
testContext.verify(() -> {
assertThat(resp.statusCode()).isEqualTo(200);
assertThat(resp.body()).contains("Yo!");
requestCheckpoint.flag();
});
}));
}
}));
}
Aggregations