From e016d5dcdac18a74d9e58ae18cfe751d37a2ea69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vav=C5=99=C3=ADk?= Date: Tue, 14 Jan 2025 16:06:17 +0100 Subject: [PATCH] Test creating of released apps/exts with a snapshot Quarkus CLI --- .../cli/QuarkusCliCreateExtensionIT.java | 13 ++---- .../cli/QuarkusCliCreateJvmApplicationIT.java | 40 ++++++++++--------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateExtensionIT.java b/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateExtensionIT.java index 550c96544..5da32d66a 100644 --- a/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateExtensionIT.java +++ b/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateExtensionIT.java @@ -2,24 +2,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue; -import jakarta.inject.Inject; - -import org.junit.jupiter.api.Test; - import io.quarkus.test.bootstrap.QuarkusCliClient; import io.quarkus.test.bootstrap.QuarkusCliDefaultService; +import io.quarkus.test.bootstrap.QuarkusVersionAwareCliClient; import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.scenarios.TestQuarkusCli; import io.quarkus.test.scenarios.annotations.DisabledOnNative; @QuarkusScenario @DisabledOnNative // Only for JVM verification public class QuarkusCliCreateExtensionIT { - @Inject - static QuarkusCliClient cliClient; - - @Test - public void shouldCreateAndBuildExtension() { + @TestQuarkusCli + public void shouldCreateAndBuildExtension(QuarkusVersionAwareCliClient cliClient) { // Create extension QuarkusCliDefaultService app = cliClient.createExtension("extension-abc"); diff --git a/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateJvmApplicationIT.java b/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateJvmApplicationIT.java index 94f07797c..bdd639c8f 100644 --- a/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateJvmApplicationIT.java +++ b/quarkus-cli/src/test/java/io/quarkus/ts/quarkus/cli/QuarkusCliCreateJvmApplicationIT.java @@ -39,7 +39,9 @@ import io.quarkus.logging.Log; import io.quarkus.test.bootstrap.QuarkusCliClient; import io.quarkus.test.bootstrap.QuarkusCliRestService; +import io.quarkus.test.bootstrap.QuarkusVersionAwareCliClient; import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.scenarios.TestQuarkusCli; import io.quarkus.test.scenarios.annotations.DisabledOnNative; import io.quarkus.test.scenarios.annotations.DisabledOnQuarkusVersion; import io.quarkus.test.services.quarkus.model.QuarkusProperties; @@ -66,8 +68,8 @@ public class QuarkusCliCreateJvmApplicationIT { @Tag("QUARKUS-1071") @Tag("QUARKUS-1072") - @Test - public void shouldCreateApplicationOnJvm() { + @TestQuarkusCli + public void shouldCreateApplicationOnJvm(QuarkusVersionAwareCliClient cliClient) { // Create application QuarkusCliRestService app = cliClient.createApplication("app"); @@ -98,9 +100,9 @@ public void shouldCreateAnApplicationForcingJavaVersion21() { } @Tag("QUARKUS-1472") - @Test - public void shouldCreateAnApplicationForcingJavaVersion17() { - CreateApplicationRequest args = defaults().withExtraArgs("--java=" + JDK_17); + @TestQuarkusCli + public void shouldCreateAnApplicationForcingJavaVersion17(QuarkusVersionAwareCliClient cliClient) { + CreateApplicationRequest args = cliClient.getDefaultCreateApplicationRequest().withExtraArgs("--java=" + JDK_17); QuarkusCliRestService app = cliClient.createApplication("app", args); assertExpectedJavaVersion(app.getFileFromApplication("pom.xml"), JDK_17); assertDockerJavaVersion(app.getFileFromApplication(DOCKER_FOLDER, DOCKERFILE_JVM), JDK_17); @@ -115,13 +117,14 @@ public void quarkusCreatedWithJava18ShouldUseJava17() { } @Tag("QUARKUS-1071") - @Test - public void shouldCreateApplicationWithGradleOnJvm() { + @TestQuarkusCli + public void shouldCreateApplicationWithGradleOnJvm(QuarkusVersionAwareCliClient cliClient) { // Create application - QuarkusCliRestService app = cliClient.createApplication("app", defaults().withExtraArgs("--gradle")); + QuarkusCliRestService app = cliClient.createApplication("app", + cliClient.getDefaultCreateApplicationRequest().withExtraArgs("--gradle")); - useQuarkusSnapshotFromSonatypeIfNeeded(app); + useQuarkusSnapshotFromSonatypeIfNeeded(app, cliClient.getQuarkusVersion()); // Run Gradle Daemon to avoid file lock on quarkus-cli-command.out when the daemon is started as part of 'app.buildOnJvm()' runGradleDaemon(app); @@ -145,9 +148,9 @@ public void shouldCreateApplicationWithGradleOnJvm() { stopGradleDaemon(app); } - private static void useQuarkusSnapshotFromSonatypeIfNeeded(QuarkusCliRestService app) { + private static void useQuarkusSnapshotFromSonatypeIfNeeded(QuarkusCliRestService app, String quarkusVersion) { // must match only the 'main' branch snapshot, not 999-SNAPSHOT in other branches as they are not published - boolean is999Snapshot = "999-SNAPSHOT".equals(QuarkusProperties.getVersion()); + boolean is999Snapshot = "999-SNAPSHOT".equals(quarkusVersion); var localRepository = System.getProperty("localRepository"); if (is999Snapshot && localRepository != null) { if (!doesQuarkusSnapshotExistInLocalRepo(localRepository)) { // not adding external repository when not needed @@ -210,12 +213,13 @@ private static void runGradleWrapper(QuarkusCliRestService app, String command) } @Tag("QUARKUS-1071") - @Test + @TestQuarkusCli @DisabledOnQuarkusVersion(version = ".*redhat.*", reason = "https://issues.redhat.com/browse/QUARKUS-3371") - public void shouldCreateApplicationWithJbangOnJvm() { + public void shouldCreateApplicationWithJbangOnJvm(QuarkusVersionAwareCliClient cliClient) { // Create application - QuarkusCliRestService app = cliClient.createApplication("app", defaults().withExtraArgs("--jbang")); + QuarkusCliRestService app = cliClient.createApplication("app", + cliClient.getDefaultCreateApplicationRequest().withExtraArgs("--jbang")); // Should build on Jvm final String repository = System.getProperty("maven.repo.local"); @@ -259,11 +263,11 @@ public void shouldCreateApplicationOnJvmFromMultipleBoms() { } @Tag("QUARKUS-1071") - @Test - public void shouldCreateApplicationWithCodeStarter() { + @TestQuarkusCli + public void shouldCreateApplicationWithCodeStarter(QuarkusVersionAwareCliClient cliClient) { // Create application with Resteasy Jackson + Spring Web (we need both for the app to run) QuarkusCliRestService app = cliClient.createApplication("app", - defaults().withExtensions(REST_JACKSON_EXTENSION, SPRING_WEB_EXTENSION)); + cliClient.getDefaultCreateApplicationRequest().withExtensions(REST_JACKSON_EXTENSION, SPRING_WEB_EXTENSION)); // Verify By default, it installs only "quarkus-rest-jackson" and "quarkus-spring-web" assertInstalledExtensions(app, REST_JACKSON_EXTENSION, SPRING_WEB_EXTENSION); @@ -311,7 +315,7 @@ public void shouldKeepUsingTheSameQuarkusVersionAfterReload() { // Generate application using old community version QuarkusCliRestService app = cliClient.createApplication("app", defaults() .withStream(null) - .withPlatformBom("io.quarkus:quarkus-bom:3.10.2") + .withPlatformBom("io.quarkus:quarkus-bom:3.15.2") .withExtensions(SMALLRYE_HEALTH_EXTENSION, REST_EXTENSION)); // Make sure version and groupId from the TS run is used