From 9d85cc87036be6212513db62642fc217b81ce96d Mon Sep 17 00:00:00 2001 From: Jakub Jedlicka Date: Tue, 14 May 2024 14:29:28 +0200 Subject: [PATCH] Enable TODO app --- examples/external-applications/pom.xml | 5 ++ .../io/quarkus/qe/OpenShiftTodoDemoIT.java | 4 -- .../test/java/io/quarkus/qe/TodoDemoIT.java | 58 +++++++++++++++---- .../src/test/resources/test.properties | 1 + 4 files changed, 53 insertions(+), 15 deletions(-) diff --git a/examples/external-applications/pom.xml b/examples/external-applications/pom.xml index e37802879..b22eead58 100644 --- a/examples/external-applications/pom.xml +++ b/examples/external-applications/pom.xml @@ -29,5 +29,10 @@ quarkus-test-openshift test + + io.quarkus.qe + quarkus-test-service-database + test + diff --git a/examples/external-applications/src/test/java/io/quarkus/qe/OpenShiftTodoDemoIT.java b/examples/external-applications/src/test/java/io/quarkus/qe/OpenShiftTodoDemoIT.java index 7767b1190..7f8bc8bc0 100644 --- a/examples/external-applications/src/test/java/io/quarkus/qe/OpenShiftTodoDemoIT.java +++ b/examples/external-applications/src/test/java/io/quarkus/qe/OpenShiftTodoDemoIT.java @@ -1,12 +1,8 @@ package io.quarkus.qe; -import org.junit.jupiter.api.Disabled; - import io.quarkus.test.scenarios.OpenShiftScenario; import io.quarkus.test.scenarios.annotations.DisabledOnNative; -// TODO: enable when Quarkus TODO app migrates to Quarkus 3 -@Disabled("Disabled until Quarkus TODO app migrates to Quarkus 3") @DisabledOnNative(reason = "Native + s2i not supported") @OpenShiftScenario public class OpenShiftTodoDemoIT extends TodoDemoIT { diff --git a/examples/external-applications/src/test/java/io/quarkus/qe/TodoDemoIT.java b/examples/external-applications/src/test/java/io/quarkus/qe/TodoDemoIT.java index a85a0373a..399353ea4 100644 --- a/examples/external-applications/src/test/java/io/quarkus/qe/TodoDemoIT.java +++ b/examples/external-applications/src/test/java/io/quarkus/qe/TodoDemoIT.java @@ -1,48 +1,84 @@ package io.quarkus.qe; +import static org.hamcrest.Matchers.is; + import org.apache.http.HttpStatus; -import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import io.quarkus.test.bootstrap.PostgresqlService; import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.QuarkusScenario; import io.quarkus.test.scenarios.annotations.DisabledOnNative; +import io.quarkus.test.services.Container; import io.quarkus.test.services.GitRepositoryQuarkusApplication; +import io.restassured.http.ContentType; -// TODO: enable when Quarkus QuickStarts migrates to Quarkus 3 -@Disabled("Disabled until Quarkus 3 is released and TODO application migrates to it") @DisabledOnNative(reason = "This scenario is using uber-jar, so it's incompatible with Native") @QuarkusScenario +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) public class TodoDemoIT { private static final String REPO = "https://github.com/quarkusio/todo-demo-app.git"; private static final String DEFAULT_ARGS = "-DskipTests=true -Dquarkus.platform.group-id=${QUARKUS_PLATFORM_GROUP-ID} -Dquarkus.platform.version=${QUARKUS_PLATFORM_VERSION} "; private static final String UBER = "-Dquarkus.package.jar.type=uber-jar "; + private static final String NO_SUFFIX = "-Dquarkus.package.jar.add-runner-suffix=false"; + + @Container(image = "${postgresql.image}", port = 5432, expectedLog = "is ready") + static PostgresqlService database = new PostgresqlService() + // store data in /tmp/psql as in OpenShift we don't have permissions to /var/lib/postgresql/data + .withProperty("PGDATA", "/tmp/psql"); @GitRepositoryQuarkusApplication(repo = REPO, mavenArgs = DEFAULT_ARGS + UBER) - static final RestService app = new RestService(); + static final RestService app = new RestService() + .withProperty("quarkus.datasource.username", database.getUser()) + .withProperty("quarkus.datasource.password", database.getPassword()) + .withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl); @GitRepositoryQuarkusApplication(repo = REPO, artifact = "todo-backend-1.0-SNAPSHOT-runner.jar", mavenArgs = DEFAULT_ARGS + UBER) - static final RestService explicit = new RestService(); - - private static final String NO_SUFFIX = "-Dquarkus.package.add-runner-suffix=false"; + static final RestService explicit = new RestService() + .withProperty("quarkus.datasource.username", database.getUser()) + .withProperty("quarkus.datasource.password", database.getPassword()) + .withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl); @GitRepositoryQuarkusApplication(repo = REPO, artifact = "todo-backend-1.0-SNAPSHOT.jar", mavenArgs = DEFAULT_ARGS + UBER + NO_SUFFIX) - static final RestService unsuffixed = new RestService(); + static final RestService unsuffixed = new RestService() + .withProperty("quarkus.datasource.username", database.getUser()) + .withProperty("quarkus.datasource.password", database.getPassword()) + .withProperty("quarkus.datasource.jdbc.url", database::getJdbcUrl); @Test + @Order(1) public void verify() { - app.given().get().then().statusCode(HttpStatus.SC_OK); + app.given() + .contentType(ContentType.JSON) + .body("{\"title\": \"Use Quarkus\", \"order\": 1, \"url\": \"https://quarkus.io\"}") + .post("/api") + .then() + .statusCode(HttpStatus.SC_CREATED); } @Test + @Order(2) public void verifyExplicitArtifact() { - explicit.given().get().then().statusCode(HttpStatus.SC_OK); + explicit.given() + .accept(ContentType.JSON) + .get("/api/1") + .then() + .statusCode(HttpStatus.SC_OK) + .body("title", is("Use Quarkus")); } @Test + @Order(3) public void verifyNoSuffix() { - unsuffixed.given().get().then().statusCode(HttpStatus.SC_OK); + unsuffixed.given() + .pathParam("id", 1) + .delete("/api/{id}") + .then() + .statusCode(HttpStatus.SC_NO_CONTENT); } } diff --git a/examples/external-applications/src/test/resources/test.properties b/examples/external-applications/src/test/resources/test.properties index e534d2db6..0cd99677c 100644 --- a/examples/external-applications/src/test/resources/test.properties +++ b/examples/external-applications/src/test/resources/test.properties @@ -1 +1,2 @@ ts.appuberjar.openshift.template=/uber-jar-quarkus-s2i-source-build-template.yml +ts.database.openshift.use-internal-service-as-url=true