Skip to content

Commit

Permalink
Workaround Picocli native failures
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Sep 26, 2024
1 parent 17f94c7 commit 6018878
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>999-SNAPSHOT</quarkus.platform.version>
<quarkus.ide.version>3.15.0</quarkus.ide.version>
<quarkus.qe.framework.version>1.6.0.Beta6</quarkus.qe.framework.version>
<quarkus.qe.framework.version>1.6.0.Beta7-SNAPSHOT</quarkus.qe.framework.version>
<quarkus-qpid-jms.version>2.6.1</quarkus-qpid-jms.version>
<confluent.kafka-avro-serializer.version>7.5.1</confluent.kafka-avro-serializer.version>
<formatter-maven-plugin.version>2.24.1</formatter-maven-plugin.version>
Expand Down
5 changes: 5 additions & 0 deletions quarkus-picocli/src/test/java/PicocliProfileProdIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
@QuarkusScenario
public class PicocliProfileProdIT {

static {
// TODO: remove this when we deal with warnings in the log
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
}

@QuarkusApplication(classes = { AgeCommand.class, CommonOptions.class, EntryCommand.class, HelloCommand.class,
OtherCommand.class, OtherEntryCommand.class,
Configuration.class, AgeService.class, HelloService.class }, properties = "prod.properties")
Expand Down
65 changes: 29 additions & 36 deletions quarkus-picocli/src/test/java/PicocliProfileTestIT.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import static java.util.concurrent.CompletableFuture.runAsync;

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;
Expand All @@ -15,71 +18,61 @@
import io.quarkus.ts.qe.services.AgeService;
import io.quarkus.ts.qe.services.HelloService;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@QuarkusScenario
public class PicocliProfileTestIT {

static {
// TODO: remove this when we deal with warnings in the log
System.setProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
}

@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);

@Order(1)
@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();
}
app.withProperty("quarkus.args", "age --age 30");
runAsync(app::start);
app.logs().assertContains("CDI: programmatic lookup problem detected");
}

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

@Order(3)
@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();
}
app.withProperty("quarkus.args", " --name QE");
runAsync(app::restart);
app.logs().assertContains("Unmatched arguments from index 0: '', '--name', 'QE'");
}

@Order(4)
@Test
void verifyErrorForInvalidArgumentsInGreetingCommand() {
try {
app.withProperty("quarkus.args", "greeting -x QE");
runAsync(app::start);
app.logs().assertContains("Unknown options: '-x', 'QE'");
} finally {
app.stop();
}
app.withProperty("quarkus.args", "greeting -x QE");
runAsync(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");
try {
runAsync(app::start);
app.logs().assertContains("Unmatched arguments from index 3: 'age', '--age', '247'");
} finally {
app.stop();
}
app.withProperty("quarkus.args", "greeting --name EEUU age --age 247");
runAsync(app::restart);
app.logs().assertContains("Unmatched arguments from index 3: 'age', '--age', '247'");
}

}

0 comments on commit 6018878

Please sign in to comment.