This is an automated email from the ASF dual-hosted git repository.

apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 490df0466baa99100ac722334b91cd8908bbe99a
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Mon Nov 16 16:08:32 2026 +0100

    CAMEL-26818: camel-jbang-core - move isolated tests from serial fork to 
parallel forks
    
    - LoadTest: use isolated test home and work dir, remove 
@UsesWorkingDirectory
    - EvalSimpleTest: remove @UsesWorkingDirectory
    - InfraTest: scope @UsesFixedPort to runService method, allowing other test 
methods to run in parallel forks
    
    Co-authored-by: IBM Bob 2.2.1
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../dsl/jbang/core/commands/EvalSimpleTest.java    |  1 -
 .../camel/dsl/jbang/core/commands/LoadTest.java    | 38 ++++++++++------------
 .../dsl/jbang/core/commands/infra/InfraTest.java   |  2 +-
 3 files changed, 19 insertions(+), 22 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/EvalSimpleTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/EvalSimpleTest.java
index e62b45a67f85..c01eb95641c8 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/EvalSimpleTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/EvalSimpleTest.java
@@ -27,7 +27,6 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
 
-@UsesWorkingDirectory
 @DisabledIfSystemProperty(named = "ci.env.name", matches = ".*", 
disabledReason = "Runs only local")
 class EvalSimpleTest extends CamelCommandBaseTestSupport {
 
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/LoadTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/LoadTest.java
index 3a1531afb043..0ac1b5c519b3 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/LoadTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/LoadTest.java
@@ -16,16 +16,16 @@
  */
 package org.apache.camel.dsl.jbang.core.commands;
 
+import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
-import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.dsl.jbang.core.commands.action.CamelLoadAction;
 import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
 import org.apache.camel.dsl.jbang.core.common.CommandLineTestHelper;
-import org.apache.camel.dsl.jbang.run.common.PathUtils;
-import org.apache.camel.util.HomeHelper;
+import org.apache.camel.util.FileUtil;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -35,37 +35,35 @@ import static 
org.apache.camel.dsl.jbang.run.common.RuntimeUtil.getPid;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.awaitility.Awaitility.await;
 
-@UsesWorkingDirectory
-class LoadTest {
+class LoadTest extends CamelCommandBaseTestSupport {
 
-    private Path workingDir;
-    private Path previousHome;
+    private File workingDir;
 
     @BeforeEach
-    public void setup() throws IOException {
-        Path base = Paths.get("target");
-        workingDir = Files.createTempDirectory(base, "camel-load");
-        // the routes run in this JVM, and their CLI connector reads the 
actions in the user home
-        previousHome = CommandLineHelper.getHomeDir();
-        CommandLineHelper.useHomeDir(HomeHelper.resolveHomeDir());
+    @Override
+    public void setup() throws Exception {
+        super.setup();
+        useTestWorkDir();
+        useTestHomeDir();
+        workingDir = Files.createTempDirectory("camel-load").toFile();
     }
 
     @AfterEach
     public void end() throws IOException {
-        CommandLineHelper.useHomeDir(previousHome.toString());
-        // force removing, since deleteOnExit is not removing.
-        PathUtils.deleteDirectory(workingDir);
+        FileUtil.removeDir(workingDir);
     }
 
     @Test
     public void shouldLoad() throws Exception {
-        Run run = new Run(new CamelJBangMain());
+        Run run = new Run(new CamelJBangMain().withPrinter(printer));
         CommandLineTestHelper.parse(run, "src/test/resources/hello.yaml", 
"--name=myload", "--max-messages=5",
-                "--prop=mydir=" + workingDir);
+                "--prop=mydir=" + workingDir.getAbsolutePath());
 
         Runnable r = () -> {
             try {
-                Thread.sleep(2000);
+                // wait for the integration status file to be written to the 
home dir
+                await().atMost(10, TimeUnit.SECONDS)
+                        .until(() -> 
Files.exists(CommandLineHelper.getCamelDir().resolve(getPid() + 
"-status.json")));
                 CamelLoadAction load = new CamelLoadAction(new 
CamelJBangMain());
                 CommandLineTestHelper.parse(load, getPid(), 
"--source=src/test/resources/load.yaml");
                 load.doCall();
@@ -80,7 +78,7 @@ class LoadTest {
         int exit = run.doCall();
         Assertions.assertEquals(0, exit);
 
-        Path outPath = workingDir.resolve("load.txt");
+        Path outPath = workingDir.toPath().resolve("load.txt");
         await("load.txt file is created by the launched 
routes").untilAsserted(() -> assertThat(outPath).exists());
         String data = Files.readString(outPath);
         Assertions.assertEquals("I was loaded", data);
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraTest.java
index 20bd47bb7d14..f6dc5c23a4ff 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/infra/InfraTest.java
@@ -28,13 +28,13 @@ import org.assertj.core.api.Assertions;
 import org.awaitility.Awaitility;
 import org.junit.jupiter.api.Test;
 
-@UsesFixedPort
 public class InfraTest extends CamelCommandBaseTestSupport {
 
     /**
      * This test asserts that the reflection in InfraRun works as expected. In 
case of issues in the reflection, most
      * probably the affected module is camel-test-infra-common
      */
+    @UsesFixedPort
     @Test
     public void runService() throws Exception {
         // infraRun.doCall() is blocking, run on a new thread.

Reply via email to