diff --git a/example/javalib/web/6-hello-quarkus/build.mill b/example/javalib/web/6-hello-quarkus/build.mill new file mode 100644 index 00000000000..2d609420f4b --- /dev/null +++ b/example/javalib/web/6-hello-quarkus/build.mill @@ -0,0 +1,36 @@ +package build +import mill._, javalib._ + +object `package` extends RootModule with JavaModule { + def ivyDeps = Agg( + ivy"io.quarkus:quarkus-core:3.17.7", + ivy"io.quarkus:quarkus-resteasy:3.17.7", + ivy"io.quarkus:quarkus-arc:3.17.7", + ivy"io.quarkus:quarkus-rest:3.17.7" + ) + + object test extends JavaTests with TestModule.Junit5 { + def ivyDeps = super.ivyDeps() ++ Agg( + ivy"io.quarkus:quarkus-junit5:3.17.7", + ivy"io.rest-assured:rest-assured:5.5.0" + ) + } +} + +// This example demonstrates how to set up a simple Quarkus webserver, +// able to handle a single HTTP request at `/` and reply with a single response. + +/** Usage + +> ./mill compile quarkus dev + +> ./mill test + +> mill runBackground + +> curl http://localhost:8050 +...Hello, Quarkus!... + +> mill clean runBackground + +*/ diff --git a/example/javalib/web/6-hello-quarkus/resources/application.properties b/example/javalib/web/6-hello-quarkus/resources/application.properties new file mode 100644 index 00000000000..fd447343e62 --- /dev/null +++ b/example/javalib/web/6-hello-quarkus/resources/application.properties @@ -0,0 +1,2 @@ +# Application configuration file +quarkus.http.port=8050 diff --git a/example/javalib/web/6-hello-quarkus/src/com/example/HelloQuarkus.java b/example/javalib/web/6-hello-quarkus/src/com/example/HelloQuarkus.java new file mode 100644 index 00000000000..59127259aad --- /dev/null +++ b/example/javalib/web/6-hello-quarkus/src/com/example/HelloQuarkus.java @@ -0,0 +1,16 @@ +package com.example; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/hello") +public class HelloQuarkus { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + return "Hello, Quarkus!"; + } +} diff --git a/example/javalib/web/6-hello-quarkus/test/src/com/example/HelloQuarkusTest.java b/example/javalib/web/6-hello-quarkus/test/src/com/example/HelloQuarkusTest.java new file mode 100644 index 00000000000..6c790a025c0 --- /dev/null +++ b/example/javalib/web/6-hello-quarkus/test/src/com/example/HelloQuarkusTest.java @@ -0,0 +1,15 @@ +package com.example; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class HelloQuarkusTest { + @Test + void testHelloEndpoint() { + given().when().get("/hello").then().statusCode(200).body(is("Hello, Quarkus!")); + } +}