diff --git a/lifecycle-application/pom.xml b/lifecycle-application/pom.xml index 97dbf2080..db1b019df 100644 --- a/lifecycle-application/pom.xml +++ b/lifecycle-application/pom.xml @@ -40,7 +40,7 @@ - 2.13.4.Final + 2.13.6.Final diff --git a/lifecycle-application/src/main/java/io/quarkus/ts/lifecycle/Main.java b/lifecycle-application/src/main/java/io/quarkus/ts/lifecycle/Main.java index c9481585b..f17ea7343 100644 --- a/lifecycle-application/src/main/java/io/quarkus/ts/lifecycle/Main.java +++ b/lifecycle-application/src/main/java/io/quarkus/ts/lifecycle/Main.java @@ -16,6 +16,10 @@ private Main() { public static void main(String... args) { LOG.info(ARGUMENTS_FROM_MAIN + String.join(",", args)); - Quarkus.run(args); + if (args.length > 0 && "cli".equals(args[0])) { + return; + } else { + Quarkus.run(args); + } } } diff --git a/lifecycle-application/src/test/java/io/quarkus/ts/lifecycle/AlphabeticallyFirstTest.java b/lifecycle-application/src/test/java/io/quarkus/ts/lifecycle/AlphabeticallyFirstTest.java new file mode 100644 index 000000000..08cc13c44 --- /dev/null +++ b/lifecycle-application/src/test/java/io/quarkus/ts/lifecycle/AlphabeticallyFirstTest.java @@ -0,0 +1,27 @@ +package io.quarkus.ts.lifecycle; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.is; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +/** + * The name of the test is crucial to make it run before HelloMainTest. + * See comments to the issue for the explanation. + */ +@QuarkusTest +@Tag("QUARKUS-2789") +public class AlphabeticallyFirstTest { + + @Test + public void shouldBeOk() { + given() + .when().get("/args") + .then() + .statusCode(200) + .body(is("")); + } +} diff --git a/lifecycle-application/src/test/java/io/quarkus/ts/lifecycle/HelloMainTest.java b/lifecycle-application/src/test/java/io/quarkus/ts/lifecycle/HelloMainTest.java new file mode 100644 index 000000000..f231912ba --- /dev/null +++ b/lifecycle-application/src/test/java/io/quarkus/ts/lifecycle/HelloMainTest.java @@ -0,0 +1,29 @@ +package io.quarkus.ts.lifecycle; + +import java.util.List; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.main.Launch; +import io.quarkus.test.junit.main.LaunchResult; +import io.quarkus.test.junit.main.QuarkusMainTest; + +@QuarkusMainTest +public class HelloMainTest { + + @Test + @Launch({ "cli", "Hello", "World" }) + public void annotatedLaunch(LaunchResult result) { + List outputStream = result.getOutputStream(); + String args = null; + for (String output : outputStream) { + if (output.contains("Received arguments:")) { + args = output; + } + } + Assertions.assertNotNull(args); + Assertions.assertTrue(args.contains("Hello"), "No 'Hello' in the output!"); + Assertions.assertTrue(args.contains("World"), "No 'World' in the output!"); + } +}