Skip to content

Commit

Permalink
enable native execution for picocli tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarranzan committed Sep 26, 2024
1 parent 7e8c50d commit 17f94c7
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 114 deletions.
4 changes: 4 additions & 0 deletions quarkus-picocli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<artifactId>quarkus-picocli</artifactId>
<name>Quarkus QE TS: Quarkus Picocli</name>
<packaging>jar</packaging>
<properties>
<!-- Skip build since our framework will build own executable anyway -->
<quarkus.build.skip>true</quarkus.build.skip>
</properties>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
import io.quarkus.ts.qe.command.OtherEntryCommand;

@ApplicationScoped
public class Config {
public class Configuration {

@Produces
@TopCommand
@IfBuildProfile("dev")
public Object devCommand() {
@IfBuildProfile("test")
public Class<EntryCommand> devCommand() {
return EntryCommand.class;
}

@Produces
@TopCommand
@IfBuildProfile("prod")
public Object prodCommand() {
public Class<OtherEntryCommand> prodCommand() {
return OtherEntryCommand.class;
}

}
}
102 changes: 0 additions & 102 deletions quarkus-picocli/src/test/java/PicocliDevIT.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.services.QuarkusApplication;
import io.quarkus.ts.qe.command.AgeCommand;
import io.quarkus.ts.qe.command.CommonOptions;
import io.quarkus.ts.qe.command.EntryCommand;
import io.quarkus.ts.qe.command.HelloCommand;
import io.quarkus.ts.qe.command.OtherCommand;
import io.quarkus.ts.qe.command.OtherEntryCommand;
import io.quarkus.ts.qe.configuration.Config;
import io.quarkus.ts.qe.configuration.Configuration;
import io.quarkus.ts.qe.services.AgeService;
import io.quarkus.ts.qe.services.HelloService;

@QuarkusScenario
public class PicocliProdIT {
@QuarkusApplication(classes = { OtherEntryCommand.class, Config.class, OtherCommand.class,
CommonOptions.class }, properties = "prod.properties")
public class PicocliProfileProdIT {

@QuarkusApplication(classes = { AgeCommand.class, CommonOptions.class, EntryCommand.class, HelloCommand.class,
OtherCommand.class, OtherEntryCommand.class,
Configuration.class, AgeService.class, HelloService.class }, properties = "prod.properties")
static final RestService customized = new RestService()
.withProperty("quarkus.args", "start -t 60 -v")
.setAutoStart(false);
Expand All @@ -28,4 +35,4 @@ public void verifyCustomizedCommandLineBehavior() {
customized.stop();
}
}
}
}
85 changes: 85 additions & 0 deletions quarkus-picocli/src/test/java/PicocliProfileTestIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import static java.util.concurrent.CompletableFuture.runAsync;

import org.junit.jupiter.api.Test;

import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.services.QuarkusApplication;
import io.quarkus.ts.qe.command.AgeCommand;
import io.quarkus.ts.qe.command.CommonOptions;
import io.quarkus.ts.qe.command.EntryCommand;
import io.quarkus.ts.qe.command.HelloCommand;
import io.quarkus.ts.qe.command.OtherCommand;
import io.quarkus.ts.qe.command.OtherEntryCommand;
import io.quarkus.ts.qe.configuration.Configuration;
import io.quarkus.ts.qe.services.AgeService;
import io.quarkus.ts.qe.services.HelloService;

@QuarkusScenario
public class PicocliProfileTestIT {

@QuarkusApplication(classes = { AgeCommand.class, CommonOptions.class, EntryCommand.class, HelloCommand.class,
OtherCommand.class, OtherEntryCommand.class,
Configuration.class, AgeService.class, HelloService.class }, properties = "test.properties")
static final RestService app = new RestService().setAutoStart(false);

@Test
public void verifyErrorForApplicationScopedBeanInPicocliCommand() {
try {
app.withProperty("quarkus.args", "age --age 30");
runAsync(app::start);
app.logs().assertContains("CDI: programmatic lookup problem detected");
} finally {
app.stop();
}
}

@Test
public void verifyGreetingCommandOutputsExpectedMessage() {
try {
app.withProperty("quarkus.args", "greeting --name QE");
runAsync(app::start);
app.logs().assertContains("Hello QE!");
} finally {
app.stop();
}
}

@Test
void verifyErrorForBlankArgumentsInGreetingCommand() {
try {
app.withProperty("quarkus.args", " --name QE");
runAsync(app::start);
app.logs().assertContains("Unmatched arguments from index 0: '', '--name', 'QE'");
} finally {
app.stop();
}
}

@Test
void verifyErrorForInvalidArgumentsInGreetingCommand() {
try {
app.withProperty("quarkus.args", "greeting -x QE");
runAsync(app::start);
app.logs().assertContains("Unknown options: '-x', 'QE'");
} finally {
app.stop();
}
}

/**
* Chain Commands in a Single Execution is not possible
*/
@Test
public void verifyErrorForMultipleCommandsWithoutTopCommand() {
app
.withProperty("quarkus.args", "greeting --name EEUU age --age 247");
try {
runAsync(app::start);
app.logs().assertContains("Unmatched arguments from index 3: 'age', '--age', '247'");
} finally {
app.stop();
}
}

}
1 change: 0 additions & 1 deletion quarkus-picocli/src/test/resources/dev.properties

This file was deleted.

1 change: 1 addition & 0 deletions quarkus-picocli/src/test/resources/test.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
quarkus.profile=test

0 comments on commit 17f94c7

Please sign in to comment.