forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support using commas to add extensions with CLI
Actually, it was already supported when creating projects, just not when adding extensions. Fixes quarkusio#37564
- Loading branch information
Showing
3 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
devtools/cli/src/test/java/io/quarkus/cli/CliProjectExtensionsAddTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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("<artifactId>quarkus-resteasy-reactive</artifactId>"), | ||
"pom.xml should contain quarkus-resteasy-reactive:\n" + pomContent); | ||
|
||
// Check the extensions are not there yet | ||
Assertions.assertFalse(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jackson</artifactId>"), | ||
"pom.xml should not contain quarkus-resteasy-reactive-jackson:\n" + pomContent); | ||
Assertions.assertFalse(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>"), | ||
"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("<artifactId>quarkus-resteasy-reactive-jackson</artifactId>"), | ||
"pom.xml should contain quarkus-resteasy-reactive-jackson:\n" + pomContent); | ||
Assertions.assertTrue(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>"), | ||
"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("<artifactId>quarkus-resteasy-reactive</artifactId>"), | ||
"pom.xml should contain quarkus-resteasy-reactive:\n" + pomContent); | ||
|
||
// Check the extensions are not there yet | ||
Assertions.assertFalse(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jackson</artifactId>"), | ||
"pom.xml should not contain quarkus-resteasy-reactive-jackson:\n" + pomContent); | ||
Assertions.assertFalse(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>"), | ||
"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("<artifactId>quarkus-resteasy-reactive-jackson</artifactId>"), | ||
"pom.xml should contain quarkus-resteasy-reactive-jackson:\n" + pomContent); | ||
Assertions.assertTrue(pomContent.contains("<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>"), | ||
"pom.xml should contain quarkus-resteasy-reactive-jsonb:\n" + pomContent); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters