Skip to content

Commit

Permalink
Make AntoraDevModeTest more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Apr 1, 2024
1 parent 67e7a0d commit 6158c53
Showing 1 changed file with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,24 @@ public void edit() throws InterruptedException, IOException {

final Path baseDir = Path.of(".").toAbsolutePath().normalize();
try (DevModeProcess devMode = new DevModeProcess(baseDir)) {
RestAssured
.given()
.contentType(ContentType.HTML)
.get("http://localhost:8080/antora/quarkus-antora/dev/index.html")
.then()
.statusCode(200)
.body(CoreMatchers.containsString("<h1 class=\"page\">Quarkus Antora</h1>"));
{
final ValidatableResponse response = Awaitility.await().atMost(10, TimeUnit.SECONDS).until(
() -> {
try {
return RestAssured
.given()
.contentType(ContentType.HTML)
.get("http://localhost:8080/antora/quarkus-antora/dev/index.html")
.then();
} catch (Exception e) {
/* The reload of the service takes some time */
return null;
}
},
resp -> resp != null && resp.extract().statusCode() == 200);
response
.body(CoreMatchers.containsString("<h1 class=\"page\">Quarkus Antora</h1>"));
}

/* Make sure new.adoc does not exist yet */
RestAssured
Expand Down Expand Up @@ -59,7 +70,7 @@ public void edit() throws InterruptedException, IOException {
return null;
}
},
resp -> resp.extract().statusCode() == 200);
resp -> resp != null && resp.extract().statusCode() == 200);
response.body(CoreMatchers.containsString(uniqueContent));
}

Expand All @@ -79,7 +90,7 @@ public void edit() throws InterruptedException, IOException {
return null;
}
},
resp -> resp.extract().statusCode() == 500);
resp -> resp != null && resp.extract().statusCode() == 500);
response.body(CoreMatchers.containsString("target of xref not found: non-existent-page.adoc"));
}

Expand All @@ -99,7 +110,7 @@ public void edit() throws InterruptedException, IOException {
return null;
}
},
resp -> resp.extract().statusCode() == 200);
resp -> resp != null && resp.extract().statusCode() == 200);
response.body(CoreMatchers.containsString(uniqueContent));
}

Expand All @@ -121,7 +132,7 @@ public void edit() throws InterruptedException, IOException {
return null;
}
},
resp -> resp.extract().statusCode() == 404);
resp -> resp != null && resp.extract().statusCode() == 404);

}
}
Expand Down

0 comments on commit 6158c53

Please sign in to comment.