Skip to content

Commit

Permalink
Test creating of released apps/exts with a snapshot Quarkus CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik authored and mjurc committed Jan 16, 2025
1 parent 1c5d859 commit e016d5d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e016d5d

Please sign in to comment.