This is an automated email from the ASF dual-hosted git repository.
cancai pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new c1e5ba15d [ISSUES-3063][Improve] Improve CommandUtil test code coverage
c1e5ba15d is described below
commit c1e5ba15da0df0742a9dd66665748758322ff1f3
Author: zhengke zhou <[email protected]>
AuthorDate: Sat Feb 17 09:30:40 2024 +0800
[ISSUES-3063][Improve] Improve CommandUtil test code coverage
---
.../streampark/common/util/CommandUtilsTest.scala | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git
a/streampark-common/src/test/scala/org/apache/streampark/common/util/CommandUtilsTest.scala
b/streampark-common/src/test/scala/org/apache/streampark/common/util/CommandUtilsTest.scala
new file mode 100644
index 000000000..859ac4446
--- /dev/null
+++
b/streampark-common/src/test/scala/org/apache/streampark/common/util/CommandUtilsTest.scala
@@ -0,0 +1,43 @@
+/*
+ * 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.streampark.common.util
+
+import org.scalatest.funsuite.AnyFunSuite
+
+class CommandUtilsTest extends AnyFunSuite {
+
+ test("execute single command") {
+ val (exitCode, output) = CommandUtils.execute("echo Hello")
+ println(s"Exit code: $exitCode")
+ println(s"Output:\n$output")
+ assert(exitCode == 0)
+ }
+
+ test("execute multiple commands") {
+ val directory = System.getProperty("temp.dir")
+ val commands = new java.util.ArrayList[String]()
+ commands.add("echo 'Hello'")
+ commands.add("echo 'World'")
+ val outputConsumer = new java.util.function.Consumer[String] {
+ override def accept(output: String): Unit = println(output)
+ }
+ val exitCode = CommandUtils.execute(directory, commands, outputConsumer)
+ println(s"Exit code: $exitCode")
+ assert(exitCode == 0)
+ }
+}