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 27, 2024
1 parent 791425e commit b6c6282
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 140 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.

31 changes: 0 additions & 31 deletions quarkus-picocli/src/test/java/PicocliProdIT.java

This file was deleted.

30 changes: 30 additions & 0 deletions quarkus-picocli/src/test/java/PicocliProfileProdIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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 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");

@Test
public void verifyCustomizedCommandLineBehavior() {
String expectedOutput = "Service started with timeout: 60 and verbosity";
customized.logs().assertContains(expectedOutput);
}
}
69 changes: 69 additions & 0 deletions quarkus-picocli/src/test/java/PicocliProfileTestIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

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;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@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().withProperty("quarkus.args", "age --age 30");

@Order(1)
@Test
public void verifyErrorForApplicationScopedBeanInPicocliCommand() {
app.logs().assertContains("CDI: programmatic lookup problem detected");
}

@Order(2)
@Test
public void verifyGreetingCommandOutputsExpectedMessage() {
app.withProperty("quarkus.args", "greeting --name QE");
app.restart();
app.logs().assertContains("Hello QE!");
}

@Order(3)
@Test
void verifyErrorForBlankArgumentsInGreetingCommand() {
app.withProperty("quarkus.args", " --name QE");
app.restart();
app.logs().assertContains("Unmatched arguments from index 0: '', '--name', 'QE'");
}

@Order(4)
@Test
void verifyErrorForInvalidArgumentsInGreetingCommand() {
app.withProperty("quarkus.args", "greeting -x QE");
app.restart();
app.logs().assertContains("Unknown options: '-x', 'QE'");
}

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

}
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 b6c6282

Please sign in to comment.