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

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


The following commit(s) were added to refs/heads/main by this push:
     new caf33d978686 CAMEL-26931: camel-jbang - camel doctor checks a SNAPSHOT 
CLI against the Apache snapshots, and camel eval prints only the value (#29933)
caf33d978686 is described below

commit caf33d9786868e5b94fbe771f79120402462dc80
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Nov 14 19:28:22 2026 +0100

    CAMEL-26931: camel-jbang - camel doctor checks a SNAPSHOT CLI against the 
Apache snapshots, and camel eval prints only the value (#29933)
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../camel/dsl/jbang/core/commands/Doctor.java      |  4 +-
 .../apache/camel/dsl/jbang/core/commands/Run.java  |  3 +-
 .../camel/dsl/jbang/core/commands/DoctorTest.java  |  6 +-
 .../dsl/jbang/core/commands/EvalSimpleTest.java    |  5 +-
 .../core/commands/RunBackgroundStateLineTest.java  | 66 ++++++++++++++++++++++
 .../camel/dsl/jbang/it/TransformMessageITCase.java |  3 +-
 6 files changed, 80 insertions(+), 7 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Doctor.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Doctor.java
index da0e64f8a395..c9f1de3212f4 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Doctor.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Doctor.java
@@ -182,9 +182,11 @@ public class Doctor extends CamelCommand {
             downloader.build();
             CamelCatalog catalog = new DefaultCamelCatalog();
             String version = catalog.getCatalogVersion();
+            // a SNAPSHOT of the CLI is in the Apache snapshots repository: 
without it, the check failed on every
+            // SNAPSHOT CLI (CAMEL-26931)
             downloader.resolveArtifacts(
                     List.of("org.apache.camel:camel-api:" + version),
-                    Set.of(), false, false);
+                    Set.of(), false, version.endsWith("-SNAPSHOT"));
             report("maven", "Maven", OK, "Artifact resolution (OK)");
         } catch (MavenResolutionException e) {
             // camel run downloads the dependencies of the routes
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index d6a3027b8e06..5b5eada118ec 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -1518,8 +1518,9 @@ public class Run extends CamelCommand implements 
CommandLifecycle {
                                            + waited + "; the log is in "
                                            + BackgroundLog.logOf(p.pid(), 
logPath));
             }
-            printer().println(kind + ": " + name + " (state: " + 
extractState(state) + ")");
             if (!internal) {
+                // not for the Camel of camel eval and transform: X=$(camel 
eval ...) got this line too (CAMEL-26931)
+                printer().println(kind + ": " + name + " (state: " + 
extractState(state) + ")");
                 // started: its log file has all of its logging, and the 
output only the warnings and errors
                 printer().println("Log: " + BackgroundLog.logOf(p.pid(), 
logPath));
             }
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DoctorTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DoctorTest.java
index 35f27a82ff0f..ffcb083f2494 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DoctorTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DoctorTest.java
@@ -108,9 +108,11 @@ class DoctorTest extends CamelCommandBaseTestSupport {
         verify(downloader).setMavenApacheSnapshotEnabled(false);
         verify(downloader).setOffline(true);
         verify(downloader).setFresh(true);
+        // a SNAPSHOT CLI asks for the Apache snapshots; with them disabled 
(as here) the downloader has none to add
+        String version = new DefaultCamelCatalog().getCatalogVersion();
         verify(downloader).resolveArtifacts(
-                List.of("org.apache.camel:camel-api:" + new 
DefaultCamelCatalog().getCatalogVersion()),
-                Set.of(), false, false);
+                List.of("org.apache.camel:camel-api:" + version),
+                Set.of(), false, version.endsWith("-SNAPSHOT"));
     }
 
     @Test
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 3700a5422423..e62b45a67f85 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
@@ -17,6 +17,7 @@
 package org.apache.camel.dsl.jbang.core.commands;
 
 import java.nio.file.Path;
+import java.util.List;
 
 import org.apache.camel.dsl.jbang.core.commands.action.EvalExpressionCommand;
 import org.apache.camel.dsl.jbang.core.common.CommandLineTestHelper;
@@ -50,8 +51,8 @@ class EvalSimpleTest extends CamelCommandBaseTestSupport {
 
             var lines = printer.getLines();
             Assertions.assertNotNull(lines);
-            Assertions.assertEquals(2, lines.size());
-            Assertions.assertEquals("11", lines.get(1));
+            // only the value: the state line of the Camel it starts was 
printed first (CAMEL-26931)
+            Assertions.assertEquals(List.of("11"), lines);
         } catch (Exception e) {
             // ignore if camel is not installed
         }
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunBackgroundStateLineTest.java
 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunBackgroundStateLineTest.java
new file mode 100644
index 000000000000..ebd407ae9812
--- /dev/null
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/RunBackgroundStateLineTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.dsl.jbang.core.commands;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.camel.dsl.jbang.core.common.CommandLineHelper;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * The line that says the integration in the background has started: not for 
the Camel that camel eval and camel
+ * transform start for themselves, as X=$(camel eval ...) got that line too 
(CAMEL-26931).
+ */
+@DisabledOnOs(OS.WINDOWS)
+class RunBackgroundStateLineTest extends CamelCommandBaseTestSupport {
+
+    @Test
+    void anIntegrationInTheBackgroundSaysItHasStarted() throws Exception {
+        assertThat(runInTheBackground(false)).contains("Camel Main: orders 
(state: Running)");
+    }
+
+    @Test
+    void theCamelOfEvalAndTransformSaysNothing() throws Exception {
+        assertThat(runInTheBackground(true)).doesNotContain("(state:");
+    }
+
+    private String runInTheBackground(boolean transform) throws Exception {
+        useTestHomeDir();
+        Path camelDir = CommandLineHelper.getCamelDir();
+        Files.createDirectories(camelDir);
+        Run run = new Run(new CamelJBangMain().withPrinter(printer));
+        run.name = "orders";
+        run.transformRun = transform;
+        // a process that writes the status of a started Camel (phase 5) for 
its own pid, as an integration does
+        ProcessBuilder pb = new ProcessBuilder(
+                "sh", "-c",
+                "echo '{\"context\":{\"name\":\"orders\",\"phase\":5}}' > '" + 
camelDir + "'/$$-status.json; exec sleep 10");
+        try {
+            assertThat(run.runBackgroundProcess(pb, "Camel Main")).isZero();
+        } finally {
+            if (run.spawnPid > 0) {
+                
ProcessHandle.of(run.spawnPid).ifPresent(ProcessHandle::destroy);
+            }
+        }
+        return printer.getOutput();
+    }
+}
diff --git 
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/TransformMessageITCase.java
 
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/TransformMessageITCase.java
index 4ffd777dfcec..30f8eb4d8c44 100644
--- 
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/TransformMessageITCase.java
+++ 
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/TransformMessageITCase.java
@@ -62,7 +62,8 @@ public class TransformMessageITCase extends JBangTestSupport {
     }
 
     private void runTransformation(String command) {
-        checkCommandOutputsPattern(command, "Camel Main: transform \\(state: 
(Running|Starting)\\)");
+        // the Camel that transform starts for itself prints nothing of its 
own on stdout (CAMEL-26931)
+        checkCommandDoesNotOutput(command, "(state: ");
     }
 
     private void checkOutputFile(String contains) throws IOException {

Reply via email to