diff --git a/devtools/cli/src/main/java/io/quarkus/cli/ProjectExtensionsAdd.java b/devtools/cli/src/main/java/io/quarkus/cli/ProjectExtensionsAdd.java index 3b1266ecdae524..4d3e1572d771ce 100644 --- a/devtools/cli/src/main/java/io/quarkus/cli/ProjectExtensionsAdd.java +++ b/devtools/cli/src/main/java/io/quarkus/cli/ProjectExtensionsAdd.java @@ -17,7 +17,7 @@ public class ProjectExtensionsAdd extends BaseBuildCommand implements Callable extensions; @Override diff --git a/devtools/cli/src/test/java/io/quarkus/cli/CliProjectExtensionsAddTest.java b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectExtensionsAddTest.java new file mode 100644 index 00000000000000..8b8769e52fc28b --- /dev/null +++ b/devtools/cli/src/test/java/io/quarkus/cli/CliProjectExtensionsAddTest.java @@ -0,0 +1,111 @@ +package io.quarkus.cli; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import io.quarkus.devtools.testing.RegistryClientTestHelper; +import picocli.CommandLine; + +public class CliProjectExtensionsAddTest { + + static final Path testProjectRoot = Paths.get(System.getProperty("user.dir")).toAbsolutePath() + .resolve("target/test-project/"); + static final Path workspaceRoot = testProjectRoot.resolve("CliProjectExtensionsAddTest"); + Path project; + + @BeforeAll + public static void setupTestRegistry() { + RegistryClientTestHelper.enableRegistryClientTestConfig(); + } + + @AfterAll + public static void cleanupTestRegistry() { + RegistryClientTestHelper.disableRegistryClientTestConfig(); + } + + @BeforeEach + public void setupTestDirectories() throws Exception { + CliDriver.deleteDir(workspaceRoot); + } + + @Test + public void testAddExtensionsCommas() throws Exception { + CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "app", "-e", "-B", "--verbose", + "org.acme:quarkus-add-extensions-commas"); + Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result); + Assertions.assertTrue(result.stdout.contains("SUCCESS"), + "Expected confirmation that the project has been created." + result); + + Path project = workspaceRoot.resolve("quarkus-add-extensions-commas"); + Path projectPom = project.resolve("pom.xml"); + Assertions.assertTrue(Files.exists(projectPom), "pom.xml should exist"); + + String pomContent = Files.readString(projectPom); + Assertions.assertTrue(pomContent.contains("quarkus-resteasy-reactive"), + "pom.xml should contain quarkus-resteasy-reactive:\n" + pomContent); + + // Check the extensions are not there yet + Assertions.assertFalse(pomContent.contains("quarkus-resteasy-reactive-jackson"), + "pom.xml should not contain quarkus-resteasy-reactive-jackson:\n" + pomContent); + Assertions.assertFalse(pomContent.contains("quarkus-resteasy-reactive-jsonb"), + "pom.xml should not contain quarkus-resteasy-reactive-jsonb:\n" + pomContent); + + // Add the extensions + result = CliDriver.execute(project, "extension", "add", + "quarkus-resteasy-reactive-jackson,quarkus-resteasy-reactive-jsonb"); + Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result); + Assertions.assertTrue(result.stdout.contains("SUCCESS"), + "Expected confirmation that the project has been created." + result); + + // Check that they have been added + pomContent = Files.readString(projectPom); + Assertions.assertTrue(pomContent.contains("quarkus-resteasy-reactive-jackson"), + "pom.xml should contain quarkus-resteasy-reactive-jackson:\n" + pomContent); + Assertions.assertTrue(pomContent.contains("quarkus-resteasy-reactive-jsonb"), + "pom.xml should contain quarkus-resteasy-reactive-jsonb:\n" + pomContent); + } + + @Test + public void testAddExtensionsSpaces() throws Exception { + CliDriver.Result result = CliDriver.execute(workspaceRoot, "create", "app", "-e", "-B", "--verbose", + "org.acme:quarkus-add-extensions-spaces"); + Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result); + Assertions.assertTrue(result.stdout.contains("SUCCESS"), + "Expected confirmation that the project has been created." + result); + + Path project = workspaceRoot.resolve("quarkus-add-extensions-spaces"); + Path projectPom = project.resolve("pom.xml"); + Assertions.assertTrue(Files.exists(projectPom), "pom.xml should exist"); + + String pomContent = Files.readString(projectPom); + Assertions.assertTrue(pomContent.contains("quarkus-resteasy-reactive"), + "pom.xml should contain quarkus-resteasy-reactive:\n" + pomContent); + + // Check the extensions are not there yet + Assertions.assertFalse(pomContent.contains("quarkus-resteasy-reactive-jackson"), + "pom.xml should not contain quarkus-resteasy-reactive-jackson:\n" + pomContent); + Assertions.assertFalse(pomContent.contains("quarkus-resteasy-reactive-jsonb"), + "pom.xml should not contain quarkus-resteasy-reactive-jsonb:\n" + pomContent); + + // Add the extensions + result = CliDriver.execute(project, "extension", "add", "quarkus-resteasy-reactive-jackson", + "quarkus-resteasy-reactive-jsonb"); + Assertions.assertEquals(CommandLine.ExitCode.OK, result.exitCode, "Expected OK return code." + result); + Assertions.assertTrue(result.stdout.contains("SUCCESS"), + "Expected confirmation that the project has been created." + result); + + // Check that they have been added + pomContent = Files.readString(projectPom); + Assertions.assertTrue(pomContent.contains("quarkus-resteasy-reactive-jackson"), + "pom.xml should contain quarkus-resteasy-reactive-jackson:\n" + pomContent); + Assertions.assertTrue(pomContent.contains("quarkus-resteasy-reactive-jsonb"), + "pom.xml should contain quarkus-resteasy-reactive-jsonb:\n" + pomContent); + } +} diff --git a/independent-projects/tools/devtools-testing/src/main/resources/fake-catalog.json b/independent-projects/tools/devtools-testing/src/main/resources/fake-catalog.json index b6e8a6310329c6..5c65f2a6f30478 100644 --- a/independent-projects/tools/devtools-testing/src/main/resources/fake-catalog.json +++ b/independent-projects/tools/devtools-testing/src/main/resources/fake-catalog.json @@ -75,6 +75,62 @@ "io.quarkus:quarkus-fake-bom:999-FAKE:json:999-FAKE" ] }, + { + "name" : "RESTEasy Reactive Jackson", + "description" : "Jackson serialization support for RESTEasy Reactive. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it", + "metadata" : { + "codestart" : { + "name" : "resteasy-reactive", + "kind" : "core", + "languages" : [ "java", "kotlin", "scala" ], + "artifact" : "io.quarkus:quarkus-project-core-extension-codestarts::jar:3.6.1" + }, + "minimum-java-version" : "11", + "status" : "stable", + "config" : [ "quarkus.resteasy-reactive.", "quarkus.jackson." ], + "built-with-quarkus-core" : "3.6.1", + "scm-url" : "https://github.com/quarkus-release/release", + "short-name" : "resteasy-reactive-jackson", + "capabilities" : { + "provides" : [ "io.quarkus.rest.jackson", "io.quarkus.resteasy.reactive.json.jackson" ] + }, + "categories" : [ "web", "reactive" ], + "extension-dependencies" : [ "io.quarkus:quarkus-resteasy-reactive", "io.quarkus:quarkus-resteasy-reactive-common", "io.quarkus:quarkus-mutiny", "io.quarkus:quarkus-smallrye-context-propagation", "io.quarkus:quarkus-vertx", "io.quarkus:quarkus-netty", "io.quarkus:quarkus-vertx-http", "io.quarkus:quarkus-core", "io.quarkus:quarkus-jsonp", "io.quarkus:quarkus-virtual-threads", "io.quarkus:quarkus-arc", "io.quarkus:quarkus-resteasy-reactive-jackson-common", "io.quarkus:quarkus-jackson" ], + "keywords" : [ "rest-jackson", "quarkus-resteasy-reactive-json", "jaxrs-json", "rest", "jaxrs", "json", "jackson", "jakarta-rest" ] + }, + "artifact" : "io.quarkus:quarkus-resteasy-reactive-jackson::jar:999-FAKE", + "origins": [ + "io.quarkus:quarkus-fake-bom:999-FAKE:json:999-FAKE" + ] + }, + { + "name" : "RESTEasy Reactive JSON-B", + "description" : "JSON-B serialization support for RESTEasy Reactive. This extension is not compatible with the quarkus-resteasy extension, or any of the extensions that depend on it.", + "metadata" : { + "codestart" : { + "name" : "resteasy-reactive", + "kind" : "core", + "languages" : [ "java", "kotlin", "scala" ], + "artifact" : "io.quarkus:quarkus-project-core-extension-codestarts::jar:3.6.1" + }, + "minimum-java-version" : "11", + "status" : "stable", + "config" : [ "quarkus.resteasy-reactive." ], + "built-with-quarkus-core" : "3.6.1", + "scm-url" : "https://github.com/quarkus-release/release", + "short-name" : "resteasy-reactive-jsonb", + "capabilities" : { + "provides" : [ "io.quarkus.rest.jsonb", "io.quarkus.resteasy.reactive.json.jsonb" ] + }, + "categories" : [ "web", "reactive" ], + "extension-dependencies" : [ "io.quarkus:quarkus-resteasy-reactive", "io.quarkus:quarkus-resteasy-reactive-common", "io.quarkus:quarkus-mutiny", "io.quarkus:quarkus-smallrye-context-propagation", "io.quarkus:quarkus-vertx", "io.quarkus:quarkus-netty", "io.quarkus:quarkus-vertx-http", "io.quarkus:quarkus-core", "io.quarkus:quarkus-jsonp", "io.quarkus:quarkus-virtual-threads", "io.quarkus:quarkus-arc", "io.quarkus:quarkus-resteasy-reactive-jsonb-common", "io.quarkus:quarkus-jsonb" ], + "keywords" : [ "rest-jsonb", "resteasy-reactive-json", "jaxrs-json", "rest", "jaxrs", "json", "jsonb", "jakarta-rest" ] + }, + "artifact" : "io.quarkus:quarkus-resteasy-reactive-jsonb::jar:999-FAKE", + "origins": [ + "io.quarkus:quarkus-fake-bom:999-FAKE:json:999-FAKE" + ] + }, { "name": "YAML Configuration", "description": "Use YAML to configure your Quarkus application",