davsclaus opened a new pull request, #28696: URL: https://github.com/apache/camel/pull/28696
_Claude Code on behalf of davsclaus_ Stage 1c-0 of [CAMEL-24727](https://issues.apache.org/jira/browse/CAMEL-24727), stacked on #28688 (and so on #28675 and #28671): retarget to `main` once those merge. The next step, 1c-2, moves the settings pipeline of `camel run` (what `Run.run()` makes of the files, `application.properties`, the profile and the options) into camel-jbang-export, so that run and export share it. Before that refactor, this PR adds golden tests that pin what the pipeline does today. The expected files are written from the current code, and 1c-2 must leave them unchanged. ## What the existing tests did not cover - No test read the run settings file (`camel-jbang-run.properties`), which is what the pipeline writes and the exporter reads. `ExportTest` sees it only through the pom that comes out. - Some kinds of input had no test at all (TLS files, `--local-kamelet-dir`, `--code`, `--source-dir`); others had one each. - `camel run --runtime=main|quarkus|spring-boot`, and `camel run pom.xml`, had no coverage: these start Maven. ## Changes - **`RunExportGoldenTest`** (serial, as it uses the working directory), with fixtures in `src/test/resources/golden` and the expected output in `golden/expected`: - **15 export cases.** For each: the run settings, the files of the exported project, a summary of its pom.xml (dependencies, repositories, plugins and property names, without the versions the build brings), and its `application.properties`. - **20 run cases.** For each: the run settings, and the initial and override properties `camel run` gives Camel Main. A subclass of `Run` keeps the `KameletMain` instead of starting it. - **6 runs with Maven.** For each: the Maven and java commands, and the project exported to run. - The fixtures cover: - YAML, XML and Java routes, and a directory with every kind of file (bean, properties, README, script, TLS, jkube); - Groovy, a profile, Kamelets and a local Kamelet directory; - `//DEPS` in Java and YAML, `--dep`, OpenAPI, `--resource-dir`, excludes, a `pom.xml` project; - the server and console options, and the run-only options: dev mode, `--source-dir`, `--code`, `--stub`, JFR and trace. - Paths and the versions the build brings (Camel, Spring Boot, Kamelets) are normalized, so a version upgrade does not change the expected files. Run with `-Dcamel.golden.update=true` to write them again, and review the diff. - **`Run.startProcess`**: the Maven-run paths start their processes through this protected method, so the test can capture the commands without running Maven. This is the only change to production code, and it doesn't change behaviour. - **`ExportTest` leaked system properties.** junit-pioneer 2.3.0 does not restore `@SetSystemProperty` after a `@ParameterizedTest`; a plain `@Test` is restored. So four tests left `camel.jbang.repos`, `camel.extra.repos` and `camel.default.extra.repos.default.value` set for every test that ran after them in the serial fork. The golden test found this, because its exports picked up the leaked repository. The four tests now set and restore the property in the test body. The golden test also clears `camel.*` system properties for each case and restores them afterwards. ## Coverage JaCoCo of the camel-jbang-core suite (lines), before and after: | | before | after | |---|---|---| | `Run` | 47% | 70% | | `Run.run()` | 62% | 80% | | `runCamelMain` / `runQuarkus` / `runSpringBoot` | 0% / 2% / 0% | 86% / 94% / 90% | | `setupReload` / `createMainInstance` | 9% / 18% | 81% / 87% | | `Exporter` | 75% | 80% | Not covered, as they need the network or another JVM: GitHub and Gist sources, `--camel-version` with another version, `--debug`, and `camel run` with no files. I did not run the camel-jbang-it integration tests locally: their local mode installs the Camel CLI with JBang, which would replace the one installed on the machine. ## Found while writing the fixtures (not changed here) - A jkube file in a subdirectory is exported to `src/main/jkube/<its source path>`, such as `src/main/jkube/src/test/resources/golden/mixed/deployment.yaml`, instead of `src/main/jkube/deployment.yaml`. `Exporter` builds the target from the path of the file, not its name. The golden file records this as it is today. - Camel's modeline parser handles `//DEPS` only. The old `// camel-k:` modeline lines are ignored, and the fixtures use `//DEPS`. ## Tests - The golden tests give the same output on repeated runs. - The full camel-jbang-core suite (2417 tests, plus 283 serial) passes, except `EvalSimpleTest`, which runs the Camel installed with JBang, not this build. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
