This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch camel-quarkus-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git
The following commit(s) were added to refs/heads/camel-quarkus-main by this
push:
new 77a55a6 Remove unnecessary use of QuarkusProcessExecutor
77a55a6 is described below
commit 77a55a69549075d87bc3ff9af555a5d328bb54e9
Author: James Netherton <[email protected]>
AuthorDate: Wed Sep 11 09:46:30 2024 +0100
Remove unnecessary use of QuarkusProcessExecutor
---
kamelet-chucknorris/pom.xml | 36 ++-------
.../java/org/acme/kamelet/ChuckNorrisTest.java | 78 ++-----------------
timer-log-main/pom.xml | 48 ++----------
.../test/java/org/acme/main/TimerLogMainIT.java | 4 +-
.../test/java/org/acme/main/TimerLogMainTest.java | 90 ++--------------------
5 files changed, 28 insertions(+), 228 deletions(-)
diff --git a/kamelet-chucknorris/pom.xml b/kamelet-chucknorris/pom.xml
index dda1b4f..73cf508 100644
--- a/kamelet-chucknorris/pom.xml
+++ b/kamelet-chucknorris/pom.xml
@@ -31,9 +31,6 @@
<quarkus.platform.version>3.14.2</quarkus.platform.version>
<camel-quarkus.platform.version>3.15.0-SNAPSHOT</camel-quarkus.platform.version>
- <!-- TODO: https://github.com/apache/camel-quarkus/issues/3156 -->
-
<camel-quarkus.version>${camel-quarkus.platform.version}</camel-quarkus.version>
-
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<camel-quarkus.platform.group-id>org.apache.camel.quarkus</camel-quarkus.platform.group-id>
@@ -53,8 +50,6 @@
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<maven-surefire-plugin.version>3.5.0</maven-surefire-plugin.version>
-
-
<quarkus.runner>${project.build.directory}/quarkus-app/quarkus-run.jar</quarkus.runner>
</properties>
<dependencyManagement>
@@ -119,12 +114,6 @@
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
-
<artifactId>camel-quarkus-integration-tests-process-executor-support</artifactId>
- <version>${camel-quarkus.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
@@ -166,27 +155,16 @@
</configuration>
</plugin>
- <!-- Move surefire:test to integration-test phase to be able
to execute the runner JAR from a test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
- <executions>
- <execution>
- <id>default-test</id>
- <goals>
- <goal>test</goal>
- </goals>
- <phase>integration-test</phase>
- <configuration>
- <failIfNoTests>false</failIfNoTests>
- <systemPropertyVariables>
-
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
-
<quarkus.runner>${quarkus.runner}</quarkus.runner>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
+ <configuration>
+ <failIfNoTests>false</failIfNoTests>
+ <systemPropertyVariables>
+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
+ </systemPropertyVariables>
+ </configuration>
</plugin>
<plugin>
@@ -291,7 +269,6 @@
</activation>
<properties>
<quarkus.native.enabled>true</quarkus.native.enabled>
-
<quarkus.runner>${project.build.directory}/${project.artifactId}-${project.version}-runner</quarkus.runner>
</properties>
<build>
<plugins>
@@ -307,7 +284,6 @@
<configuration>
<systemPropertyVariables>
<quarkus.native.enabled>${quarkus.native.enabled}</quarkus.native.enabled>
-
<quarkus.runner>${quarkus.runner}</quarkus.runner>
</systemPropertyVariables>
</configuration>
</execution>
diff --git
a/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisTest.java
b/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisTest.java
index 1fe38c8..6b69770 100644
--- a/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisTest.java
+++ b/kamelet-chucknorris/src/test/java/org/acme/kamelet/ChuckNorrisTest.java
@@ -16,89 +16,23 @@
*/
package org.acme.kamelet;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.apache.camel.quarkus.test.support.process.QuarkusProcessExecutor;
-import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Test;
-import org.zeroturnaround.exec.StartedProcess;
import static org.awaitility.Awaitility.await;
@QuarkusTest
public class ChuckNorrisTest {
-
- private static final String NATIVE_ENABLED =
System.getProperty("quarkus.native.enabled");
-
@Test
- public void testTimerLogMain() throws IOException {
- QuarkusRunnerExecutor quarkusProcessExecutor = new
QuarkusRunnerExecutor();
- StartedProcess process = quarkusProcessExecutor.start();
-
- awaitStartup(quarkusProcessExecutor);
-
- try {
- File quarkusLogFile = getQuarkusLogFile();
- await().atMost(10L, TimeUnit.SECONDS).pollDelay(1,
TimeUnit.SECONDS).until(() -> {
- String log = FileUtils.readFileToString(quarkusLogFile,
StandardCharsets.UTF_8);
- return log.contains("Chuck Norris");
- });
- } finally {
- if (process != null && process.getProcess().isAlive()) {
- process.getProcess().destroy();
- }
- }
- }
-
- private File getQuarkusLogFile() {
- String pathPrefix = "target/quarkus";
- if (isNative()) {
- pathPrefix += "-native";
- }
- return new File(pathPrefix + ".log");
- }
-
- private void awaitStartup(QuarkusProcessExecutor quarkusProcessExecutor) {
- await().atMost(10, TimeUnit.SECONDS).pollDelay(1,
TimeUnit.SECONDS).until(() -> {
- return isApplicationHealthy(quarkusProcessExecutor.getHttpPort());
+ public void testTimerLogMain() {
+ await().atMost(10L, TimeUnit.SECONDS).pollDelay(1,
TimeUnit.SECONDS).until(() -> {
+ List<String> log =
Files.readAllLines(Paths.get("target/quarkus.log"));
+ return log.stream().anyMatch(line ->
line.matches(".*timer.*Chuck.*"));
});
}
-
- private boolean isApplicationHealthy(int port) {
- try {
- int status = RestAssured.given()
- .port(port)
- .get("/q/health")
- .then()
- .extract()
- .statusCode();
- return status == 200;
- } catch (Exception e) {
- return false;
- }
- }
-
- private static boolean isNative() {
- return NATIVE_ENABLED != null && NATIVE_ENABLED.equals("true");
- }
-
- static final class QuarkusRunnerExecutor extends QuarkusProcessExecutor {
- @Override
- protected List<String> command(String... args) {
- List<String> command = super.command(args);
- if (isNative()) {
-
command.add("-Dquarkus.log.file.path=target/quarkus-native.log");
- } else {
- command.add(1, "-Dquarkus.log.file.path=target/quarkus.log");
- }
- return command;
- }
-
- }
}
diff --git a/timer-log-main/pom.xml b/timer-log-main/pom.xml
index d4a5d23..161c443 100644
--- a/timer-log-main/pom.xml
+++ b/timer-log-main/pom.xml
@@ -31,9 +31,6 @@
<quarkus.platform.version>3.14.2</quarkus.platform.version>
<camel-quarkus.platform.version>3.15.0-SNAPSHOT</camel-quarkus.platform.version>
- <!-- TODO: https://github.com/apache/camel-quarkus/issues/3156 -->
-
<camel-quarkus.version>${camel-quarkus.platform.version}</camel-quarkus.version>
-
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<camel-quarkus.platform.group-id>org.apache.camel.quarkus</camel-quarkus.platform.group-id>
@@ -53,8 +50,6 @@
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<maven-surefire-plugin.version>3.5.0</maven-surefire-plugin.version>
-
-
<quarkus.runner>${project.build.directory}/quarkus-app/quarkus-run.jar</quarkus.runner>
</properties>
<dependencyManagement>
@@ -74,13 +69,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-bom-test</artifactId>
- <version>${camel-quarkus.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
</dependencies>
</dependencyManagement>
@@ -109,17 +97,6 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
-
<artifactId>camel-quarkus-integration-tests-process-executor-support</artifactId>
- <version>${camel-quarkus.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.awaitility</groupId>
- <artifactId>awaitility</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
@@ -161,27 +138,16 @@
</configuration>
</plugin>
- <!-- Move surefire:test to integration-test phase to be able
to execute the runner JAR from a test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
- <executions>
- <execution>
- <id>default-test</id>
- <goals>
- <goal>test</goal>
- </goals>
- <phase>integration-test</phase>
- <configuration>
- <failIfNoTests>false</failIfNoTests>
- <systemPropertyVariables>
-
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
-
<quarkus.runner>${quarkus.runner}</quarkus.runner>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
+ <configuration>
+ <failIfNoTests>false</failIfNoTests>
+ <systemPropertyVariables>
+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
+ </systemPropertyVariables>
+ </configuration>
</plugin>
<plugin>
@@ -286,7 +252,6 @@
</activation>
<properties>
<quarkus.native.enabled>true</quarkus.native.enabled>
-
<quarkus.runner>${project.build.directory}/${project.artifactId}-${project.version}-runner</quarkus.runner>
</properties>
<build>
<plugins>
@@ -302,7 +267,6 @@
<configuration>
<systemPropertyVariables>
<quarkus.native.enabled>${quarkus.native.enabled}</quarkus.native.enabled>
-
<quarkus.runner>${quarkus.runner}</quarkus.runner>
</systemPropertyVariables>
</configuration>
</execution>
diff --git a/timer-log-main/src/test/java/org/acme/main/TimerLogMainIT.java
b/timer-log-main/src/test/java/org/acme/main/TimerLogMainIT.java
index 53af995..22aca25 100644
--- a/timer-log-main/src/test/java/org/acme/main/TimerLogMainIT.java
+++ b/timer-log-main/src/test/java/org/acme/main/TimerLogMainIT.java
@@ -16,9 +16,9 @@
*/
package org.acme.main;
-import io.quarkus.test.junit.QuarkusIntegrationTest;
+import io.quarkus.test.junit.main.QuarkusMainIntegrationTest;
-@QuarkusIntegrationTest
+@QuarkusMainIntegrationTest
class TimerLogMainIT extends TimerLogMainTest {
}
diff --git a/timer-log-main/src/test/java/org/acme/main/TimerLogMainTest.java
b/timer-log-main/src/test/java/org/acme/main/TimerLogMainTest.java
index 7308269..6967a55 100644
--- a/timer-log-main/src/test/java/org/acme/main/TimerLogMainTest.java
+++ b/timer-log-main/src/test/java/org/acme/main/TimerLogMainTest.java
@@ -16,91 +16,17 @@
*/
package org.acme.main;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.apache.camel.quarkus.test.support.process.QuarkusProcessExecutor;
-import org.apache.commons.io.FileUtils;
+import io.quarkus.test.junit.main.Launch;
+import io.quarkus.test.junit.main.LaunchResult;
+import io.quarkus.test.junit.main.QuarkusMainTest;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.zeroturnaround.exec.StartedProcess;
-
-import static org.awaitility.Awaitility.await;
-@QuarkusTest
+@QuarkusMainTest
public class TimerLogMainTest {
-
- private static final String NATIVE_ENABLED =
System.getProperty("quarkus.native.enabled");
-
@Test
- public void testTimerLogMain() throws IOException {
- QuarkusRunnerExecutor quarkusProcessExecutor = new
QuarkusRunnerExecutor();
- StartedProcess process = quarkusProcessExecutor.start();
-
- awaitStartup(quarkusProcessExecutor);
-
- try {
- File quarkusLogFile = getQuarkusLogFile();
- await().atMost(10L, TimeUnit.SECONDS).pollDelay(1,
TimeUnit.SECONDS).until(() -> {
- String log = FileUtils.readFileToString(quarkusLogFile,
StandardCharsets.UTF_8);
- return log.contains("Greetings");
- });
- } finally {
- if (process != null && process.getProcess().isAlive()) {
- process.getProcess().destroy();
- }
- }
- }
-
- private File getQuarkusLogFile() {
- String pathPrefix = "target/quarkus";
- if (isNative()) {
- pathPrefix += "-native";
- }
- return new File(pathPrefix + ".log");
- }
-
- private void awaitStartup(QuarkusProcessExecutor quarkusProcessExecutor) {
- await().atMost(10, TimeUnit.SECONDS).pollDelay(1,
TimeUnit.SECONDS).until(() -> {
- return isApplicationHealthy(quarkusProcessExecutor.getHttpPort());
- });
- }
-
- private boolean isApplicationHealthy(int port) {
- try {
- int status = RestAssured.given()
- .port(port)
- .get("/q/health")
- .then()
- .extract()
- .statusCode();
- return status == 200;
- } catch (Exception e) {
- return false;
- }
- }
-
- private static boolean isNative() {
- return NATIVE_ENABLED != null && NATIVE_ENABLED.equals("true");
- }
-
- static final class QuarkusRunnerExecutor extends QuarkusProcessExecutor {
- @Override
- protected List<String> command(String... args) {
- List<String> command = super.command(args);
- if (isNative()) {
-
command.add("-Dquarkus.log.file.path=target/quarkus-native.log");
- } else {
- command.add(1, "-Dquarkus.log.file.path=target/quarkus.log");
- }
- command.add("Greetings");
- command.add("2");
- return command;
- }
-
+ @Launch(value = { "Greetings", "2" }, exitCode = 15)
+ public void testTimerLogMain(LaunchResult result) {
+ Assertions.assertTrue(result.getOutput().contains("Body: Greetings"));
}
}