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 bc2003657de CAMEL-20367: Adds Cmd start stop route tests (#15647)
bc2003657de is described below
commit bc2003657de70f0506a519b039a7326ccd4c6ae3
Author: Jakub Vrubel <[email protected]>
AuthorDate: Mon Sep 23 12:33:51 2024 +0200
CAMEL-20367: Adds Cmd start stop route tests (#15647)
---
.../camel/dsl/jbang/it/CmdStartStopITCase.java | 41 ++++++++++++++++++++++
.../dsl/jbang/it/support/JBangTestSupport.java | 6 ++++
2 files changed, 47 insertions(+)
diff --git
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CmdStartStopITCase.java
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CmdStartStopITCase.java
new file mode 100644
index 00000000000..b5ae16a6a9c
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/CmdStartStopITCase.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 CmdStartStopITCase extends JBangTestSupport {
+
+ @Test
+ public void testCmdStop() throws IOException {
+ copyResourceInDataFolder(TestResources.DIR_ROUTE);
+ copyResourceInDataFolder(TestResources.ROUTE2);
+ executeBackground(String.format("run --source-dir=%s", mountPoint()));
+ checkLogContains("Hello world!");
+ checkCommandOutputsPattern("get route",
+
"route1\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Started.*\\n.*route2\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Started");
+ execute("cmd stop-route route2");
+ checkCommandOutputsPattern("get route",
+
"route1\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Stopped.*\\n.*route2\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Stopped");
+ execute("cmd start-route --id=route1");
+ checkCommandOutputsPattern("get route",
+
"route1\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Started.*\\n.*route2\\s+timer:\\/\\/(yaml|java)\\?period=1000\\s+Stopped");
+ }
+}
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 cbdbaa64bad..1ef80e9b22d 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
@@ -153,6 +153,12 @@ public abstract class JBangTestSupport {
.contains(contains);
}
+ protected void checkCommandOutputsPattern(String command, String contains)
{
+ Assertions.assertThat(execute(command))
+ .as("command camel" + command + "should output pattern" +
contains)
+ .containsPattern(contains);
+ }
+
protected void checkCommandDoesNotOutput(String command, String contains) {
Assertions.assertThat(execute(command))
.as("command camel" + command + "should not output" + contains)