From 38c053f85ca79e179715c0ef8b87988d8cf58801 Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Thu, 4 Jan 2024 00:46:29 +0100 Subject: [PATCH] Make the ServerDevModeTest more robust to also pass on fast multicore machines --- extensions/core/deployment/pom.xml | 5 ++++ .../deployment/test/ServerDevModeTest.java | 30 ++++++++++++------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/extensions/core/deployment/pom.xml b/extensions/core/deployment/pom.xml index 72eca727d..bb332cbd9 100644 --- a/extensions/core/deployment/pom.xml +++ b/extensions/core/deployment/pom.xml @@ -110,6 +110,11 @@ ${assertj.version} test + + org.awaitility + awaitility + test + diff --git a/extensions/core/deployment/src/test/java/io/quarkiverse/cxf/deployment/test/ServerDevModeTest.java b/extensions/core/deployment/src/test/java/io/quarkiverse/cxf/deployment/test/ServerDevModeTest.java index 2cd903d82..f4afc84c3 100644 --- a/extensions/core/deployment/src/test/java/io/quarkiverse/cxf/deployment/test/ServerDevModeTest.java +++ b/extensions/core/deployment/src/test/java/io/quarkiverse/cxf/deployment/test/ServerDevModeTest.java @@ -7,7 +7,9 @@ import java.io.StringWriter; import java.io.Writer; import java.util.Properties; +import java.util.concurrent.TimeUnit; +import org.awaitility.Awaitility; import org.hamcrest.CoreMatchers; import org.hamcrest.Matchers; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -66,14 +68,14 @@ void changePath() { private void assertWsdl(RestAssuredConfig config, String path) { given() .config(config) - .when().get(path + "?wsdl") + .when().get("/soap" + path + "?wsdl") .then() .statusCode(200) .body( Matchers.hasXPath( anyNs("definitions", "service", "port", "address") + "/@*[local-name() = 'location']", CoreMatchers.is( - "http://localhost:8080" + path))); + "http://localhost:8080/soap" + path))); } private void assertCount(RestAssuredConfig config, String path, int expectedStatus, String expectedCount) { @@ -86,13 +88,21 @@ private void assertCount(RestAssuredConfig config, String path, int expectedStat " \n" + ""; - final ValidatableResponse response = given() - .config(config) - .body(requestBody) - .when() - .post(path) - .then() - .statusCode(expectedStatus); + final ValidatableResponse response = Awaitility.await().atMost(10, TimeUnit.SECONDS).until( + () -> { + try { + return given() + .config(config) + .body(requestBody) + .when() + .post("/soap" + path) + .then(); + } catch (Exception e) { + /* The reload of the service takes some time */ + return null; + } + }, + resp -> resp != null); if (expectedStatus >= 200 && expectedStatus < 300) { response.body( @@ -105,7 +115,7 @@ private void assertCount(RestAssuredConfig config, String path, int expectedStat public static Asset applicationProperties() { Writer writer = new StringWriter(); Properties props = new Properties(); - props.setProperty("quarkus.cxf.path", "/"); + props.setProperty("quarkus.cxf.path", "/soap"); props.setProperty("quarkus.cxf.endpoint.\"/fruit\".implementor", io.quarkiverse.cxf.deployment.test.FruitWebServiceImpl.class.getName()); try {