This is an automated email from the ASF dual-hosted git repository.
fmariani 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 cf8eacdf1d98 Add camel-jbang 4.14+ test coverage
cf8eacdf1d98 is described below
commit cf8eacdf1d98578de571129dc6cb3fe802512d98
Author: Jakub Vrubel <[email protected]>
AuthorDate: Thu Mar 26 14:32:55 2026 +0100
Add camel-jbang 4.14+ test coverage
---
.../apache/camel/dsl/jbang/it/CmdLoadITCase.java | 38 +++++++++++++++++
.../apache/camel/dsl/jbang/it/HistoryITCase.java | 34 +++++++++++++++
.../camel/dsl/jbang/it/InfrastructureITCase.java | 18 +++++++-
.../apache/camel/dsl/jbang/it/ProcessorITCase.java | 44 ++++++++++++++++++++
.../camel/dsl/jbang/it/ValidatePluginITCase.java | 41 ++++++++++++++++++
.../dsl/jbang/it/support/JBangTestSupport.java | 25 +++++++++--
.../src/test/resources/jbang/it/HistoryRoute.java | 36 ++++++++++++++++
.../cli/services/CliLocalContainerService.java | 46 ++++++++++++++++++++-
.../infra/cli/services/CliLocalProcessService.java | 48 +++++++++++++++++++---
.../camel/test/infra/cli/services/CliService.java | 4 ++
10 files changed, 321 insertions(+), 13 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CmdLoadITCase.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CmdLoadITCase.java
new file mode 100644
index 000000000000..61e99eae90e3
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CmdLoadITCase.java
@@ -0,0 +1,38 @@
+/*
+ * 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.it;
+
+import java.io.IOException;
+
+import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
+import org.junit.jupiter.api.Test;
+
+public class CmdLoadITCase extends JBangTestSupport {
+ @Test
+ public void testCmdLoad() throws IOException {
+ copyResourceInDataFolder(TestResources.ROUTE2);
+ copyResourceInDataFolder(TestResources.DIR_ROUTE);
+ executeBackground(String.format("run %s/route2.yaml", mountPoint()));
+ checkCommandOutputs(String.format("cmd load
--source=%s/FromDirectoryRoute.java", mountPoint()),
+ "Successfully loaded 1 source files");
+ //check both routes are running in one app
+ checkCommandOutputsPattern("ps",
+
"INFLIGHT\\s+\\d+\\s+route2\\s+1\\/1\\s+Running\\s+(\\d+m)?\\d+s\\s+\\d+\\s+0\\s+0\\s*$");
+ checkCommandOutputsPattern("get route",
+
"route2\\s+route1.*yaml.*Started.*\\s+.*route2\\s+route2.*Started");
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/HistoryITCase.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/HistoryITCase.java
new file mode 100644
index 000000000000..ba7edb7730fd
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/HistoryITCase.java
@@ -0,0 +1,34 @@
+/*
+ * 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.it;
+
+import java.io.IOException;
+
+import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
+import org.junit.jupiter.api.Test;
+
+public class HistoryITCase extends JBangTestSupport {
+ @Test
+ public void testHistory() throws IOException {
+ copyResourceInDataFolder(TestResources.HISTORY_ROUTE);
+ execInContainer(String.format("mkdir inbox"));
+ execInContainer(String.format("echo -e hello\\nworld\\nfrom\\nme >
inbox/payload.txt"));
+ executeBackground(String.format("run %s/HistoryRoute.java",
mountPoint()));
+ checkCommandOutputs("get history", "status:success");
+ checkCommandOutputs("get history", "File: payload.txt");
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java
index c5edb826f04d..e9e20cc310ad 100644
---
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java
@@ -35,6 +35,10 @@ public class InfrastructureITCase extends JBangTestSupport {
private static final String IMPL_SERVICE = "artemis";
private static final String IMPLEMENTATION = "amqp";
+ private String getServicePID(String message) {
+ return message.split(":")[1].replaceAll("[^0-9]", "");
+ }
+
@Test
public void infraListTest() {
checkCommandOutputsPattern("infra list",
"ALIAS\s+IMPLEMENTATION\s+DESCRIPTION");
@@ -72,7 +76,17 @@ public class InfrastructureITCase extends JBangTestSupport {
checkCommandDoesNotOutput("infra ps", PID);
}
- private String getServicePID(String message) {
- return message.split(":")[1].replaceAll("[^0-9]", "");
+ @DisabledIfSystemProperty(named = "ci.env.name", matches = ".*",
+ disabledReason = "Requires too much resources")
+ @Test
+ public void sendMessageTest() {
+ String msg = execute("infra run --background " + SERVICE);
+ String PID = getServicePID(msg);
+ Awaitility.await()
+ .atMost(Duration.ofSeconds(30))
+ .pollInterval(Duration.ofSeconds(1))
+ .untilAsserted(() -> Assertions.assertThat(execute("infra ps"))
+ .containsPattern(PID));
+ checkCommandOutputs("cmd send --infra " + SERVICE + "
--body=\'hello\'", "Sent (success)");
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/ProcessorITCase.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/ProcessorITCase.java
new file mode 100644
index 000000000000..3ca550881160
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/ProcessorITCase.java
@@ -0,0 +1,44 @@
+/*
+ * 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.it;
+
+import java.io.IOException;
+
+import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
+import org.junit.jupiter.api.Test;
+
+public class ProcessorITCase extends JBangTestSupport {
+ @Test
+ public void testDisableEIP() throws IOException {
+ copyResourceInDataFolder(TestResources.ROUTE2);
+ executeBackground(String.format("run %s/route2.yaml", mountPoint()));
+ checkCommandOutputsPattern("get processor",
"route1\\s+timer:\\/\\/yaml.*\\s+Started");
+ execute("cmd disable-processor --id=route1");
+ checkCommandOutputsPattern("get processor", "log1\\s+log\\s+Disabled");
+ }
+
+ @Test
+ public void testReenableEIP() throws IOException {
+ copyResourceInDataFolder(TestResources.ROUTE2);
+ executeBackground(String.format("run %s/route2.yaml", mountPoint()));
+ checkCommandOutputsPattern("get processor",
"route1\\s+timer:\\/\\/yaml.*\\s+Started");
+ execute("cmd disable-processor --id=route1");
+ checkCommandOutputsPattern("get processor", "log1\\s+log\\s+Disabled");
+ execute("cmd enable-processor --id=route1");
+ checkCommandOutputsPattern("get processor", "log1\\s+log\\s+Started");
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/ValidatePluginITCase.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/ValidatePluginITCase.java
new file mode 100644
index 000000000000..a0c220f8f753
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/ValidatePluginITCase.java
@@ -0,0 +1,41 @@
+/*
+ * 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.it;
+
+import java.io.IOException;
+
+import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
+import org.junit.jupiter.api.Test;
+
+public class ValidatePluginITCase extends JBangTestSupport {
+
+ @Test
+ public void testValidateOK() throws IOException {
+ copyResourceInDataFolder(TestResources.ROUTE2);
+ execute("plugin add validate");
+ checkCommandOutputs(String.format("validate yaml %s/route2.yaml",
mountPoint()), "Validation success (files:1)");
+ }
+
+ @Test
+ public void testValidateKO() throws IOException {
+ copyResourceInDataFolder(TestResources.ROUTE2);
+ execute("plugin add validate");
+ execInContainer(String.format("echo \"test\" >> %s/route2.yaml",
mountPoint()));
+ checkCommandFailsWithOutput(String.format("validate yaml
%s/route2.yaml", mountPoint()),
+ "MarkedYAMLException: while scanning a simple key");
+ }
+}
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
index d81da695a221..85b651229613 100644
---
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/support/JBangTestSupport.java
@@ -110,6 +110,7 @@ public abstract class JBangTestSupport {
COMP_MAPPING_TEMPLATE("transform.xml",
"/jbang/it/data-mapping/components/transform.xml"),
FORMATS_MAPPING_DATA("data.csv",
"/jbang/it/data-mapping/data-formats/data.csv"),
STUB_ROUTE("StubRoute.java", "/jbang/it/StubRoute.java"),
+ HISTORY_ROUTE("HistoryRoute.java", "/jbang/it/HistoryRoute.java"),
USER_SOURCE_KAMELET("user-source.kamelet.yaml",
"/jbang/it/user-source.kamelet.yaml");
private String name;
@@ -137,6 +138,10 @@ public abstract class JBangTestSupport {
return containerService.execute(command);
}
+ protected String execute(final String command, Boolean getError, Boolean
expectFail) {
+ return containerService.execute(command, getError, expectFail);
+ }
+
protected String executeBackground(final String command) {
return containerService.executeBackground(command);
}
@@ -170,7 +175,7 @@ public abstract class JBangTestSupport {
protected void assertFileInDataFolderContains(String file, String
contains) throws IOException {
final Path toVerify = Path.of(containerDataFolder, file);
Assertions.assertThat(new String(Files.readAllBytes(toVerify)))
- .as("file" + toVerify + " should contain" + contains)
+ .as("file " + toVerify + " should contain " + contains)
.contains(contains);
}
@@ -182,13 +187,25 @@ public abstract class JBangTestSupport {
protected void checkCommandOutputs(String command, String contains) {
Assertions.assertThat(execute(command))
- .as("command " + getMainCommand() + " " + command + "should
output " + contains)
+ .as("command " + getMainCommand() + " " + command + " should
output " + contains)
+ .contains(contains);
+ }
+
+ protected void checkCommandFailsWithError(String command, String error) {
+ Assertions.assertThat(execute(command, true, true))
+ .as("command " + getMainCommand() + " " + command + " should
fail with error " + error)
+ .contains(error);
+ }
+
+ protected void checkCommandFailsWithOutput(String command, String
contains) {
+ Assertions.assertThat(execute(command, false, true))
+ .as("command " + getMainCommand() + " " + command + " should
fail with error " + contains)
.contains(contains);
}
protected void checkCommandOutputsPattern(String command, String contains)
{
Assertions.assertThat(execute(command))
- .as("command " + getMainCommand() + " " + command + "should
output " + contains)
+ .as("command " + getMainCommand() + " " + command + " should
output " + contains)
.containsPattern(contains);
}
@@ -200,7 +217,7 @@ public abstract class JBangTestSupport {
protected void checkCommandDoesNotOutput(String command, String contains) {
Assertions.assertThat(execute(command))
- .as("command " + getMainCommand() + " " + command + "should
not output " + contains)
+ .as("command " + getMainCommand() + " " + command + " should
not output " + contains)
.doesNotContain(contains);
}
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/resources/jbang/it/HistoryRoute.java
b/dsl/camel-jbang/camel-jbang-it/src/test/resources/jbang/it/HistoryRoute.java
new file mode 100644
index 000000000000..cdd2aff4f30e
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/resources/jbang/it/HistoryRoute.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+import org.apache.camel.builder.RouteBuilder;
+
+public class HistoryRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("file:inbox?noop=true")
+ .log("Incoming file")
+ .split(body().tokenize("\n"))
+ .filter(body().contains("world"))
+ .log("Stop the world")
+ .stop()
+ .end()
+ .to("log:line")
+ .end()
+ .to("https://camel.apache.org/xxx?throwExceptionOnFailure=false")
+ .to("log:after-http")
+ .log("complete");
+ }
+}
\ No newline at end of file
diff --git
a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliLocalContainerService.java
b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliLocalContainerService.java
index 9f09e0208af4..df15ae1c3487 100644
---
a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliLocalContainerService.java
+++
b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliLocalContainerService.java
@@ -116,6 +116,20 @@ public class CliLocalContainerService implements
CliService, ContainerService<Cl
return executeGenericCommand(getMainCommand() + " " + command);
}
+ /**
+ * Alternative method for executing camel-cli commands that has the option
to intentionally fail and allows to
+ * return stdErr
+ *
+ * @param command camel-cli command to be executed
+ * @param getError true - return stdErr, false - return stdOut
+ * @param expectFail whether or not the command is expected to fail or not
+ * @return stdErr or stdOut of the executed command, depending
on the value of getError
+ */
+ @Override
+ public String execute(String command, Boolean getError, Boolean
expectFail) {
+ return executeGenericCommand(getMainCommand() + " " + command,
getError, expectFail);
+ }
+
@Override
public String executeBackground(String command) {
final String pid = StringHelper.after(execute(command.concat("
--background")), "PID:").trim();
@@ -124,12 +138,36 @@ public class CliLocalContainerService implements
CliService, ContainerService<Cl
@Override
public String executeGenericCommand(String command) {
+ return executeGenericCommand(command, false, false);
+ }
+
+ /**
+ * Alternative method for executing bash commands that has the option to
intentionally fail and allows to return
+ * stdErr
+ *
+ * @param command bash command to be executed
+ * @param getError true - return stdErr, false - return stdOut
+ * @param expectFail whether the command is expected to succeed or not
+ * @return stdErr or stdOut of the executed command, depending
on the value of getError
+ */
+ @Override
+ public String executeGenericCommand(String command, Boolean getError,
Boolean expectFail) {
try {
LOG.debug("Executing command: {}", command);
Container.ExecResult execResult =
container.execInContainer("/bin/bash", "-c", command);
- if (execResult.getExitCode() != 0) {
+ //Expected to fail and failed
+ if (execResult.getExitCode() != 0 && expectFail) {
+ LOG.debug(String.format("command %s failed with output %s and
error %s", command, execResult.getStdout(),
+ execResult.getStderr()));
+ //Expected to succeed but failed
+ } else if (execResult.getExitCode() != 0 && !expectFail) {
Assertions.fail(String.format("command %s failed with output
%s and error %s", command, execResult.getStdout(),
execResult.getStderr()));
+ //Expected to fail but succeeded
+ } else if (execResult.getExitCode() == 0 && expectFail) {
+ Assertions.fail(String.format("command %s was expected to fail
but succeeded with output %s and error %s",
+ command, execResult.getStdout(),
+ execResult.getStderr()));
}
if (LOG.isDebugEnabled()) {
if (ObjectHelper.isNotEmpty(execResult.getStdout())) {
@@ -139,7 +177,11 @@ public class CliLocalContainerService implements
CliService, ContainerService<Cl
LOG.debug("result error {}", execResult.getStderr());
}
}
- return execResult.getStdout();
+ if (getError) {
+ return execResult.getStderr();
+ } else {
+ return execResult.getStdout();
+ }
} catch (Exception e) {
LOG.error("ERROR running generic command: {}", command, e);
throw new RuntimeException(e);
diff --git
a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliLocalProcessService.java
b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliLocalProcessService.java
index 9a1c44ded42e..161548c2726c 100644
---
a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliLocalProcessService.java
+++
b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliLocalProcessService.java
@@ -158,11 +158,25 @@ public class CliLocalProcessService implements CliService
{
@Override
public String execute(String command) {
+ return execute(command, false, false);
+ }
+
+ /**
+ * Alternative method for executing camel-cli commands that has the option
to intentionally fail and allows to
+ * retreive stdErr
+ *
+ * @param command bash command to be executed
+ * @param getError true - return stdErr, false - return stdOut
+ * @param expectFail whether the command is expected to succeed or not
+ * @return stdErr or stdOut of the executed command, depending
on the value of getError
+ */
+ @Override
+ public String execute(String command, Boolean getError, Boolean
expectFail) {
String camelCommand = getMainCommand() + " " + command;
if (mavenSettingsFile != null && command.startsWith("run ")) {
camelCommand += " --maven-settings=" +
mavenSettingsFile.toAbsolutePath();
}
- return executeGenericCommand(camelCommand);
+ return executeGenericCommand(camelCommand, getError, expectFail);
}
@Override
@@ -177,6 +191,20 @@ public class CliLocalProcessService implements CliService {
@Override
public String executeGenericCommand(String command) {
+ return executeGenericCommand(command, false, false);
+ }
+
+ /**
+ * Alternative method for executing bash commands that has the option to
intentionally fail and allows to retreive
+ * stdErr
+ *
+ * @param command bash command to be executed
+ * @param getError true - return stdErr, false - return stdOut
+ * @param expectFail whether the command is expected to succeed or not
+ * @return stdErr or stdOut of the executed command, depending
on the value of getError
+ */
+ @Override
+ public String executeGenericCommand(String command, Boolean getError,
Boolean expectFail) {
try {
LOG.debug("Executing command: {}", command);
@@ -233,9 +261,16 @@ public class CliLocalProcessService implements CliService {
}
String stderr = stderrFuture.join();
-
- if (process.exitValue() != 0) {
+ //Expected to fail and failed
+ if (process.exitValue() != 0 && expectFail) {
+ LOG.debug(String.format("command %s failed with output %s and
error %s", command, stdout, stderr));
+ //Expected to succeed but failed
+ } else if (process.exitValue() != 0 && !expectFail) {
Assertions.fail(String.format("command %s failed with output
%s and error %s", command, stdout, stderr));
+ //Expected to fail but succeeded
+ } else if (process.exitValue() == 0 && expectFail) {
+ Assertions.fail(String.format("command %s was expected to fail
but succeeded with output %s and error %s",
+ command, stdout, stderr));
}
if (LOG.isDebugEnabled()) {
@@ -246,8 +281,11 @@ public class CliLocalProcessService implements CliService {
LOG.debug("result error {}", stderr);
}
}
-
- return stdout;
+ if (getError) {
+ return stderr;
+ } else {
+ return stdout;
+ }
} catch (IOException | InterruptedException e) {
LOG.error("ERROR running command: {}", command, e);
throw new RuntimeException(e);
diff --git
a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliService.java
b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliService.java
index 9c81eff5e55d..88ebc5ba3978 100644
---
a/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliService.java
+++
b/test-infra/camel-test-infra-cli/src/main/java/org/apache/camel/test/infra/cli/services/CliService.java
@@ -47,10 +47,14 @@ public interface CliService extends BeforeEachCallback,
AfterEachCallback, TestS
*/
String execute(String command);
+ String execute(String command, Boolean getError, Boolean expectFail);
+
String executeBackground(String command);
String executeGenericCommand(String command);
+ String executeGenericCommand(String command, Boolean getError, Boolean
expectFail);
+
/**
* Copy a file inside the container
*