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 676514e78ae0293a8b563f962dee7b2e39fa4b75
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Mon Nov 16 16:31:05 2026 +0100

    CAMEL-26818: camel-jbang-core - review of #30210: a work directory for 
ExportMainApplicationPropertiesTest, and a few clean-ups
    
    - ExportMainApplicationPropertiesTest no longer has @UsesWorkingDirectory 
but
      did not give itself a work directory, so its export used and deleted the
      .camel-jbang of the module that the other forks share. It extends
      CamelCommandBaseTestSupport and calls useTestWorkDir() as 
ExportMainJibTest
      and ExportMainJkubeTest do.
    - ExportTest creates its base directory with Files.createTempDirectory, as 
the
      other three classes do.
    - AGENTS.md of the module no longer points at ExportTest as an example of a
      method annotation (no test in this change has one), and names the three 
ways
      to avoid the serial fork: exportBaseDir, useTestWorkDir() and port 0.
    
    Co-authored-by: IBM Bob 2.2.1
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 dsl/camel-jbang/camel-jbang-core/AGENTS.md                         | 7 ++++---
 .../jbang/core/commands/ExportMainApplicationPropertiesTest.java   | 7 +++++--
 .../java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java  | 3 +--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/dsl/camel-jbang/camel-jbang-core/AGENTS.md 
b/dsl/camel-jbang/camel-jbang-core/AGENTS.md
index 665ddb8aa6f5..bf18db462f26 100644
--- a/dsl/camel-jbang/camel-jbang-core/AGENTS.md
+++ b/dsl/camel-jbang/camel-jbang-core/AGENTS.md
@@ -22,9 +22,10 @@ reused). So a test must not depend on a fresh JVM, nor share 
anything with the t
   `camel init` writes a file given without a directory there, and a local 
`camel-cli.properties` is read from it. A
   test that listens on a fixed port, such as `camel infra run` with the 
default port of a service, is annotated
   `@UsesFixedPort`. These tests run after the others, one class at a time, in 
a fork of their own (the `serial-test`
-  execution). Prefer a temporary directory (`--dir`) and port 0, so a test 
does not need them. Both annotations also
-  go on a single test method: the serial fork is a tail that nothing runs 
beside, so annotate only the methods that
-  need it (as in `ExportTest`), not the whole class, and the other tests of 
the class run in the parallel forks.
+  execution). Prefer a temporary directory (`--dir`, `exportBaseDir` for the 
`application.properties` of an export,
+  `useTestWorkDir()` for `.camel-jbang`) and port 0, so a test does not need 
them. Both annotations also go on a single
+  test method: the serial fork is a tail that nothing runs beside, so annotate 
only the methods that need it, not the
+  whole class, and the other tests of the class run in the parallel forks.
 - Restore what else a test changes in the JVM: system properties 
(`@SetSystemProperty` of junit-pioneer, or set and
   clear them), static fields, and stop the servers, threads and CamelContexts 
that it starts.
 - A test that only fails now and then usually shares something with another 
test: run the module a few times with
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportMainApplicationPropertiesTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportMainApplicationPropertiesTest.java
index 96b02406520e..446a3dd4f52c 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportMainApplicationPropertiesTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportMainApplicationPropertiesTest.java
@@ -38,14 +38,17 @@ import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
 import org.junit.jupiter.params.provider.MethodSource;
 
-class ExportMainApplicationPropertiesTest {
+class ExportMainApplicationPropertiesTest extends CamelCommandBaseTestSupport {
 
     private File workingDir;
     private File baseDir;
     private File profile;
 
     @BeforeEach
-    public void setup() throws IOException {
+    @Override
+    public void setup() throws Exception {
+        super.setup();
+        useTestWorkDir();
         workingDir = Files.createTempDirectory("camel-export").toFile();
         // a base directory of its own: the application.properties of the 
module directory is shared with the other forks
         baseDir = Files.createTempDirectory("camel-export-base").toFile();
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
index d53e413a0aa8..62c9f4fb9097 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
@@ -1610,8 +1610,7 @@ class ExportTest extends CamelCommandBaseTestSupport {
      * tests of the other forks share.
      */
     private Path baseDirWithApplicationProperties(String content) throws 
IOException {
-        Path baseDir = workingDir.toPath().resolveSibling(workingDir.getName() 
+ "-base");
-        Files.createDirectories(baseDir);
+        Path baseDir = Files.createTempDirectory("camel-export-base");
         baseDirs.add(baseDir.toFile());
         Files.writeString(baseDir.resolve("application.properties"), content);
         return baseDir;

Reply via email to