gnodet-bot commented on code in PR #29459:
URL: https://github.com/apache/camel/pull/29459#discussion_r4511775853
##########
core/camel-console/src/test/java/org/apache/camel/impl/console/SendDevConsoleTest.java:
##########
@@ -131,6 +133,27 @@ public void testSendConsoleToNonExistentEndpoint() {
assertEquals("error", jsonOut.getString("status"));
}
+ @Test
+ public void testSendConsoleFileBodyToAQueue() throws Exception {
+ // seda hands the message to another thread, which reads the body
after the send returns
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("seda:refunds").delay(200).to("mock:refunds");
+ }
+ });
+ Path file = Files.createTempFile("refund", ".json");
+ Files.writeString(file, "{\"refund\": 1}");
+ MockEndpoint mock = getMockEndpoint("mock:refunds");
+ mock.expectedBodiesReceived("{\"refund\": 1}");
+
+ JsonObject jsonOut = callJson(startedSendConsole(),
createOptions("seda:refunds", "file:" + file));
+
+ assertEquals("success", jsonOut.getString("status"), jsonOut.toJson());
+ mock.assertIsSatisfied();
+ Files.delete(file);
Review Comment:
`Files.createTempFile` without a `try-finally` or `@TempDir` means the file
leaks if any assertion between lines 145–153 fails. The sibling test class
`LocalCliConnectorSendActionTest` correctly uses `@TempDir`. Use the same
pattern:
```suggestion
@TempDir
Path tempDir;
```
Then replace `Files.createTempFile("refund", ".json")` with
`tempDir.resolve("refund.json")` and drop the explicit `Files.delete(file)` —
the framework handles cleanup regardless of test outcome.
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelSendAction.java:
##########
@@ -166,6 +186,18 @@ public Integer doCall() throws Exception {
if (timeout < 5000) {
timeout = 5000;
}
+ if (repeat < 0 || repeat > MAX_MESSAGES) {
+ throw CliException.usage("--repeat must be between 1 and " +
MAX_MESSAGES + ", was: " + repeat);
Review Comment:
The condition `repeat < 0 || repeat > MAX_MESSAGES` allows `repeat=0` (the
picocli default for unset int), but the error message says "must be between
**1** and 10000". A user passing `--repeat=-1` or `--repeat=0` explicitly gets
a confusing error. Guard the intentional default separately:
```suggestion
if (repeat != 0 && (repeat < 1 || repeat > MAX_MESSAGES)) {
throw CliException.usage("--repeat must be between 1 and " +
MAX_MESSAGES + ", was: " + repeat);
```
--
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]