You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ca...@apache.org on 2022/04/15 02:51:56 UTC

[incubator-linkis] branch dev-1.1.1 updated: Dev 1.1.1 Add junit test code for [linkis-common]-Part1 (#1740)

This is an automated email from the ASF dual-hosted git repository.

casion pushed a commit to branch dev-1.1.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.1.1 by this push:
     new ffc6615ea Dev 1.1.1 Add junit test code for [linkis-common]-Part1 (#1740)
ffc6615ea is described below

commit ffc6615eabcc525139a40ad7ea4ce4609240a624
Author: めぐみん <59...@users.noreply.github.com>
AuthorDate: Fri Apr 15 10:51:50 2022 +0800

    Dev 1.1.1 Add junit test code for [linkis-common]-Part1 (#1740)
    
    Add junit test code for [linkis-common]-Part1
---
 linkis-commons/linkis-common/pom.xml               |   6 +
 ...inkisComputationGovernanceErrorCodeSummary.java |   7 +-
 .../common/errorcode/ErrorCodeUtilsTest.java       |  37 ++++++
 .../LinkisCommonsErrorCodeSummaryTest.java         | 103 +++++++++++++++++
 ...sComputationGovernanceErrorCodeSummaryTest.java | 100 +++++++++++++++++
 .../errorcode/LinkisErrorCodeSummaryTest.java      |  91 +++++++++++++++
 .../errorcode/LinkisFrameErrorCodeSummaryTest.java |  84 ++++++++++++++
 .../common/exception/ErrorExceptionTest.java       |  45 ++++++++
 .../common/exception/ExceptionLevelTest.java       |  65 +++++++++++
 .../common/exception/ExceptionManagerTest.java     | 116 +++++++++++++++++++
 .../common/exception/FatalExceptionTest.java       |  45 ++++++++
 .../exception/LinkisCommonErrorExceptionTest.java  |  33 ++++++
 .../common/exception/LinkisExceptionTest.java      | 124 +++++++++++++++++++++
 .../common/exception/LinkisRetryExceptionTest.java |  31 ++++++
 .../exception/LinkisRuntimeExceptionTest.java      | 124 +++++++++++++++++++++
 .../linkis/common/exception/WarnExceptionTest.java |  45 ++++++++
 .../linkis/common/utils/ArrayUtilsTest.scala       |  68 +++++++++++
 .../linkis/common/utils/ClassUtilsTest.scala       |  66 +++++++++++
 .../linkis/common/utils/OverloadUtilsTest.scala    |  57 ++++++++++
 19 files changed, 1244 insertions(+), 3 deletions(-)

diff --git a/linkis-commons/linkis-common/pom.xml b/linkis-commons/linkis-common/pom.xml
index f314f07b7..947ca9d76 100644
--- a/linkis-commons/linkis-common/pom.xml
+++ b/linkis-commons/linkis-common/pom.xml
@@ -149,6 +149,12 @@
             </exclusions>
         </dependency>
 
+        <dependency>
+            <groupId>com.ginsberg</groupId>
+            <artifactId>junit5-system-exit</artifactId>
+            <version>1.1.1</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 
diff --git a/linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/errorcode/LinkisComputationGovernanceErrorCodeSummary.java b/linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/errorcode/LinkisComputationGovernanceErrorCodeSummary.java
index b23e56788..b415d55c8 100644
--- a/linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/errorcode/LinkisComputationGovernanceErrorCodeSummary.java
+++ b/linkis-commons/linkis-common/src/main/java/org/apache/linkis/common/errorcode/LinkisComputationGovernanceErrorCodeSummary.java
@@ -18,14 +18,15 @@
 package org.apache.linkis.common.errorcode;
 
 public enum LinkisComputationGovernanceErrorCodeSummary {
-    ENGINE_LAUNCH_REQUEST_USER_BLANK(20000, "请求引擎的参数中user为空", "请求引擎的参数中user为空", "EngineConnManger"),
+    ENGINE_LAUNCH_REQUEST_USER_BLANK(
+            20000, "请求引擎的参数中user为空", "请求引擎的参数中user为空", "EngineConnManager"),
     ENGINE_LAUNCH_REQUEST_CREATOR_BLANK(
             20001, "请求启动引擎的参数中creator为空", "请求启动引擎的参数中creator为空", "EngineConnManager"),
     ENGINE_INIT_FAILED(20002, "引擎初始化失败", "引擎初始化失败", "EngineConnManager"),
 
-    ENGINE_REQUEST_USER_BLANK(20000, "请求引擎的参数中user为空", "请求引擎的参数中user为空", "EngineConnManger"),
+    ENGINE_REQUEST_USER_BLANK(20000, "请求引擎的参数中user为空", "请求引擎的参数中user为空", "EngineConnManager"),
 
-    AM_EM_NOT_FOUND(20100, "请求引擎的参数中user为空", "请求引擎的参数中user为空", "EngineConnManger");
+    AM_EM_NOT_FOUND(20100, "请求引擎的参数中user为空", "请求引擎的参数中user为空", "EngineConnManager");
     /** 错误码 */
     private int errorCode;
     /** 错误描述 */
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/ErrorCodeUtilsTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/ErrorCodeUtilsTest.java
new file mode 100644
index 000000000..74355a855
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/ErrorCodeUtilsTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.linkis.common.errorcode;
+
+import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
+import org.junit.jupiter.api.Test;
+
+/** ErrorCodeUtils Tester */
+public class ErrorCodeUtilsTest {
+
+    @Test
+    @ExpectSystemExitWithStatus(10000)
+    public void testValidateErrorCode1() {
+        ErrorCodeUtils.validateErrorCode(1, 2, 3);
+    }
+
+    @Test
+    @ExpectSystemExitWithStatus(10000)
+    public void testValidateErrorCode2() {
+        ErrorCodeUtils.validateErrorCode(4, 2, 3);
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisCommonsErrorCodeSummaryTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisCommonsErrorCodeSummaryTest.java
new file mode 100644
index 000000000..4e49cb7a4
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisCommonsErrorCodeSummaryTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.linkis.common.errorcode;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/** LinkisCommonsErrorCodeSummary Tester */
+class LinkisCommonsErrorCodeSummaryTest {
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testGetErrorCode(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        assertEquals(11000, linkisCommonsErrorCodeSummary.getErrorCode());
+    }
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testSetErrorCode(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        assertEquals(11000, linkisCommonsErrorCodeSummary.getErrorCode());
+        linkisCommonsErrorCodeSummary.setErrorCode(1);
+        assertEquals(1, linkisCommonsErrorCodeSummary.getErrorCode());
+        linkisCommonsErrorCodeSummary.setErrorCode(2147483647);
+        assertEquals(2147483647, linkisCommonsErrorCodeSummary.getErrorCode());
+        linkisCommonsErrorCodeSummary.setErrorCode(11000);
+    }
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testGetErrorDesc(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        assertEquals("引擎启动失败", linkisCommonsErrorCodeSummary.getErrorDesc());
+    }
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testSetErrorDesc(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        assertEquals("引擎启动失败", linkisCommonsErrorCodeSummary.getErrorDesc());
+        linkisCommonsErrorCodeSummary.setErrorDesc("testSetErrorDesc");
+        assertEquals("testSetErrorDesc", linkisCommonsErrorCodeSummary.getErrorDesc());
+        linkisCommonsErrorCodeSummary.setErrorDesc("引擎启动失败");
+    }
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testGetComment(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        assertEquals("引擎启动失败", linkisCommonsErrorCodeSummary.getComment());
+    }
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testSetComment(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        assertEquals("引擎启动失败", linkisCommonsErrorCodeSummary.getComment());
+        linkisCommonsErrorCodeSummary.setComment("testSetComment");
+        assertEquals("testSetComment", linkisCommonsErrorCodeSummary.getComment());
+        linkisCommonsErrorCodeSummary.setComment("引擎启动失败");
+    }
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testGetModule(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        assertEquals("hiveEngineConn", linkisCommonsErrorCodeSummary.getModule());
+    }
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testSetModule(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        assertEquals("hiveEngineConn", linkisCommonsErrorCodeSummary.getModule());
+        linkisCommonsErrorCodeSummary.setModule("testSetModule");
+        assertEquals("testSetModule", linkisCommonsErrorCodeSummary.getModule());
+        linkisCommonsErrorCodeSummary.setModule("hiveEngineConn");
+    }
+
+    @ParameterizedTest
+    @EnumSource(LinkisCommonsErrorCodeSummary.class)
+    void testToString(LinkisCommonsErrorCodeSummary linkisCommonsErrorCodeSummary) {
+        linkisCommonsErrorCodeSummary.setErrorCode(0);
+        linkisCommonsErrorCodeSummary.setErrorDesc("testSetErrorDesc");
+        assertEquals(
+                "errorCode: 0, errorDesc:testSetErrorDesc",
+                linkisCommonsErrorCodeSummary.toString());
+        linkisCommonsErrorCodeSummary.setErrorCode(11000);
+        linkisCommonsErrorCodeSummary.setErrorDesc("引擎启动失败");
+        assertEquals(
+                "errorCode: 11000, errorDesc:引擎启动失败", linkisCommonsErrorCodeSummary.toString());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisComputationGovernanceErrorCodeSummaryTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisComputationGovernanceErrorCodeSummaryTest.java
new file mode 100644
index 000000000..4a07284c6
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisComputationGovernanceErrorCodeSummaryTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.linkis.common.errorcode;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.linkis.common.errorcode.LinkisComputationGovernanceErrorCodeSummary.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/** LinkisComputationGovernanceErrorCodeSummary Tester */
+class LinkisComputationGovernanceErrorCodeSummaryTest {
+
+    @Test
+    void testGetErrorCode() {
+        assertEquals(20000, ENGINE_LAUNCH_REQUEST_USER_BLANK.getErrorCode());
+        assertEquals(20001, ENGINE_LAUNCH_REQUEST_CREATOR_BLANK.getErrorCode());
+        assertEquals(20002, ENGINE_INIT_FAILED.getErrorCode());
+        assertEquals(20000, ENGINE_REQUEST_USER_BLANK.getErrorCode());
+        assertEquals(20100, AM_EM_NOT_FOUND.getErrorCode());
+    }
+
+    @Test
+    void testSetErrorCode() {
+        ENGINE_LAUNCH_REQUEST_USER_BLANK.setErrorCode(1);
+        assertEquals(1, ENGINE_LAUNCH_REQUEST_USER_BLANK.getErrorCode());
+        ENGINE_LAUNCH_REQUEST_USER_BLANK.setErrorCode(20000);
+        assertEquals(20000, ENGINE_LAUNCH_REQUEST_USER_BLANK.getErrorCode());
+    }
+
+    @Test
+    void testGetErrorDesc() {
+        assertEquals("请求引擎的参数中user为空", ENGINE_LAUNCH_REQUEST_USER_BLANK.getErrorDesc());
+        assertEquals("请求启动引擎的参数中creator为空", ENGINE_LAUNCH_REQUEST_CREATOR_BLANK.getErrorDesc());
+        assertEquals("引擎初始化失败", ENGINE_INIT_FAILED.getErrorDesc());
+        assertEquals("请求引擎的参数中user为空", ENGINE_REQUEST_USER_BLANK.getErrorDesc());
+        assertEquals("请求引擎的参数中user为空", AM_EM_NOT_FOUND.getErrorDesc());
+    }
+
+    @Test
+    void testSetErrorDesc() {
+        ENGINE_LAUNCH_REQUEST_CREATOR_BLANK.setErrorDesc("Test SetErrorDesc");
+        assertEquals("Test SetErrorDesc", ENGINE_LAUNCH_REQUEST_CREATOR_BLANK.getErrorDesc());
+        ENGINE_LAUNCH_REQUEST_CREATOR_BLANK.setErrorDesc("请求启动引擎的参数中creator为空");
+        assertEquals("请求启动引擎的参数中creator为空", ENGINE_LAUNCH_REQUEST_CREATOR_BLANK.getErrorDesc());
+    }
+
+    @Test
+    void testGetComment() {
+        assertEquals("请求引擎的参数中user为空", ENGINE_LAUNCH_REQUEST_USER_BLANK.getComment());
+        assertEquals("请求启动引擎的参数中creator为空", ENGINE_LAUNCH_REQUEST_CREATOR_BLANK.getComment());
+        assertEquals("引擎初始化失败", ENGINE_INIT_FAILED.getComment());
+        assertEquals("请求引擎的参数中user为空", ENGINE_REQUEST_USER_BLANK.getComment());
+        assertEquals("请求引擎的参数中user为空", AM_EM_NOT_FOUND.getComment());
+    }
+
+    @Test
+    void testSetComment() {
+        ENGINE_INIT_FAILED.setComment("Test SetComment");
+        assertEquals("Test SetComment", ENGINE_INIT_FAILED.getComment());
+        ENGINE_INIT_FAILED.setComment("引擎初始化失败");
+        assertEquals("引擎初始化失败", ENGINE_INIT_FAILED.getComment());
+    }
+
+    @Test
+    void testGetModule() {
+        assertEquals("EngineConnManager", ENGINE_LAUNCH_REQUEST_USER_BLANK.getModule());
+        assertEquals("EngineConnManager", ENGINE_LAUNCH_REQUEST_CREATOR_BLANK.getModule());
+        assertEquals("EngineConnManager", ENGINE_INIT_FAILED.getModule());
+        assertEquals("EngineConnManager", ENGINE_REQUEST_USER_BLANK.getModule());
+        assertEquals("EngineConnManager", AM_EM_NOT_FOUND.getModule());
+    }
+
+    @Test
+    void testSetModule() {
+        ENGINE_REQUEST_USER_BLANK.setModule("Test SetModule");
+        assertEquals("Test SetModule", ENGINE_REQUEST_USER_BLANK.getModule());
+        ENGINE_REQUEST_USER_BLANK.setModule("EngineConnManager");
+        assertEquals("EngineConnManager", ENGINE_REQUEST_USER_BLANK.getModule());
+    }
+
+    @Test
+    void testToString() {
+        assertEquals("errorCode: 20100, errorDesc:请求引擎的参数中user为空", AM_EM_NOT_FOUND.toString());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisErrorCodeSummaryTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisErrorCodeSummaryTest.java
new file mode 100644
index 000000000..9d9f0b267
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisErrorCodeSummaryTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.linkis.common.errorcode;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.linkis.common.errorcode.LinkisErrorCodeSummary.EngineManagerErrorException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class LinkisErrorCodeSummaryTest {
+
+    @Test
+    void testGetErrorCode() {
+        assertEquals(321, EngineManagerErrorException.getErrorCode());
+    }
+
+    @Test
+    void testSetErrorCode() {
+        EngineManagerErrorException.setErrorCode(1);
+        assertEquals(1, EngineManagerErrorException.getErrorCode());
+        EngineManagerErrorException.setErrorCode(321);
+        assertEquals(321, EngineManagerErrorException.getErrorCode());
+    }
+
+    @Test
+    void testGetErrorDesc() {
+        assertEquals("引擎启动失败", EngineManagerErrorException.getErrorDesc());
+    }
+
+    @Test
+    void testSetErrorDesc() {
+        EngineManagerErrorException.setErrorDesc("test");
+        assertEquals("test", EngineManagerErrorException.getErrorDesc());
+        EngineManagerErrorException.setErrorDesc("引擎启动失败");
+        assertEquals("引擎启动失败", EngineManagerErrorException.getErrorDesc());
+    }
+
+    @Test
+    void testGetComment() {
+        assertEquals("在某种情况下启动失败", EngineManagerErrorException.getComment());
+    }
+
+    @Test
+    void testSetComment() {
+        EngineManagerErrorException.setComment("test");
+        assertEquals("test", EngineManagerErrorException.getComment());
+        EngineManagerErrorException.setComment("在某种情况下启动失败");
+        assertEquals("在某种情况下启动失败", EngineManagerErrorException.getComment());
+    }
+
+    @Test
+    void testGetCreator() {
+        assertEquals("hadoop", EngineManagerErrorException.getCreator());
+    }
+
+    @Test
+    void testSetCreator() {
+        EngineManagerErrorException.setCreator("test");
+        assertEquals("test", EngineManagerErrorException.getCreator());
+        EngineManagerErrorException.setCreator("hadoop");
+        assertEquals("hadoop", EngineManagerErrorException.getCreator());
+    }
+
+    @Test
+    void testGetModule() {
+        assertEquals("EngineConnManager", EngineManagerErrorException.getModule());
+    }
+
+    @Test
+    void testSetModule() {
+        EngineManagerErrorException.setModule("test");
+        assertEquals("test", EngineManagerErrorException.getModule());
+        EngineManagerErrorException.setModule("EngineConnManager");
+        assertEquals("EngineConnManager", EngineManagerErrorException.getModule());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisFrameErrorCodeSummaryTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisFrameErrorCodeSummaryTest.java
new file mode 100644
index 000000000..761379090
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/errorcode/LinkisFrameErrorCodeSummaryTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.linkis.common.errorcode;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.linkis.common.errorcode.LinkisFrameErrorCodeSummary.VALIDATE_ERROR_CODE_FAILED;
+import static org.junit.jupiter.api.Assertions.*;
+
+/** LinkisFrameErrorCodeSummary Tester */
+class LinkisFrameErrorCodeSummaryTest {
+
+    @Test
+    void testGetErrorCode() {
+        assertEquals(10000, VALIDATE_ERROR_CODE_FAILED.getErrorCode());
+    }
+
+    @Test
+    void testSetErrorCode() {
+        VALIDATE_ERROR_CODE_FAILED.setErrorCode(-1);
+        assertEquals(-1, VALIDATE_ERROR_CODE_FAILED.getErrorCode());
+        VALIDATE_ERROR_CODE_FAILED.setErrorCode(10000);
+        assertEquals(10000, VALIDATE_ERROR_CODE_FAILED.getErrorCode());
+    }
+
+    @Test
+    void testGetErrorDesc() {
+        assertEquals("错误码定义有误", VALIDATE_ERROR_CODE_FAILED.getErrorDesc());
+    }
+
+    @Test
+    void testSetErrorDesc() {
+        VALIDATE_ERROR_CODE_FAILED.setErrorDesc("test");
+        assertEquals("test", VALIDATE_ERROR_CODE_FAILED.getErrorDesc());
+        VALIDATE_ERROR_CODE_FAILED.setErrorDesc("错误码定义有误");
+        assertEquals("错误码定义有误", VALIDATE_ERROR_CODE_FAILED.getErrorDesc());
+    }
+
+    @Test
+    void testGetComment() {
+        assertEquals("错误码定义超过最大值或者小于最小值", VALIDATE_ERROR_CODE_FAILED.getComment());
+    }
+
+    @Test
+    void testSetComment() {
+        VALIDATE_ERROR_CODE_FAILED.setComment("test");
+        assertEquals("test", VALIDATE_ERROR_CODE_FAILED.getComment());
+        VALIDATE_ERROR_CODE_FAILED.setComment("错误码定义超过最大值或者小于最小值");
+        assertEquals("错误码定义超过最大值或者小于最小值", VALIDATE_ERROR_CODE_FAILED.getComment());
+    }
+
+    @Test
+    void testGetModule() {
+        assertEquals("linkis-frame", VALIDATE_ERROR_CODE_FAILED.getModule());
+    }
+
+    @Test
+    void testSetModule() {
+        VALIDATE_ERROR_CODE_FAILED.setModule("test");
+        assertEquals("test", VALIDATE_ERROR_CODE_FAILED.getModule());
+        VALIDATE_ERROR_CODE_FAILED.setModule("linkis-frame");
+        assertEquals("linkis-frame", VALIDATE_ERROR_CODE_FAILED.getModule());
+    }
+
+    @Test
+    void testToString() {
+        assertEquals("errorCode: 10000, errorDesc:错误码定义有误", VALIDATE_ERROR_CODE_FAILED.toString());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ErrorExceptionTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ErrorExceptionTest.java
new file mode 100644
index 000000000..e2db3ff22
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ErrorExceptionTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class ErrorExceptionTest {
+
+    @Test
+    void testErrorException() {
+        ErrorException errorException1 = new ErrorException(1, "test");
+        assertEquals(ExceptionLevel.ERROR, errorException1.getLevel());
+        assertEquals("test", errorException1.getDesc());
+        ErrorException errorException2 =
+                new ErrorException(3, "test", "127.0.0.1", 1234, "serviceKind");
+        assertEquals(ExceptionLevel.ERROR, errorException2.getLevel());
+        assertEquals("test", errorException2.getDesc());
+        assertEquals("127.0.0.1", errorException2.getIp());
+        assertEquals(1234, errorException2.getPort());
+        assertEquals("serviceKind", errorException2.getServiceKind());
+    }
+
+    @Test
+    void testGetLevel() {
+        ErrorException errorException = new ErrorException(2, "test");
+        assertEquals(ExceptionLevel.ERROR, errorException.getLevel());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ExceptionLevelTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ExceptionLevelTest.java
new file mode 100644
index 000000000..4ac47524f
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ExceptionLevelTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class ExceptionLevelTest {
+
+    @Test
+    void testGetLevel() {
+        assertEquals(1, ExceptionLevel.WARN.getLevel());
+        assertEquals(2, ExceptionLevel.ERROR.getLevel());
+        assertEquals(3, ExceptionLevel.FATAL.getLevel());
+        assertEquals(4, ExceptionLevel.RETRY.getLevel());
+    }
+
+    @Test
+    void testSetLevel() {
+        ExceptionLevel.WARN.setLevel(-1);
+        assertEquals(-1, ExceptionLevel.WARN.getLevel());
+        ExceptionLevel.WARN.setLevel(1);
+        assertEquals(1, ExceptionLevel.WARN.getLevel());
+    }
+
+    @Test
+    void testGetName() {
+        assertEquals("warn", ExceptionLevel.WARN.getName());
+        assertEquals("error", ExceptionLevel.ERROR.getName());
+        assertEquals("fatal", ExceptionLevel.FATAL.getName());
+        assertEquals("retry", ExceptionLevel.RETRY.getName());
+    }
+
+    @Test
+    void testSetName() {
+        ExceptionLevel.ERROR.setName("testError");
+        assertEquals("testError", ExceptionLevel.ERROR.getName());
+        ExceptionLevel.ERROR.setName("error");
+        assertEquals("error", ExceptionLevel.ERROR.getName());
+    }
+
+    @Test
+    void testToString() {
+        assertEquals("ExceptionLevel{level=1, name='warn'}", ExceptionLevel.WARN.toString());
+        assertEquals("ExceptionLevel{level=2, name='error'}", ExceptionLevel.ERROR.toString());
+        assertEquals("ExceptionLevel{level=3, name='fatal'}", ExceptionLevel.FATAL.toString());
+        assertEquals("ExceptionLevel{level=4, name='retry'}", ExceptionLevel.RETRY.toString());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ExceptionManagerTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ExceptionManagerTest.java
new file mode 100644
index 000000000..8c817fed0
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/ExceptionManagerTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.apache.linkis.common.errorcode.CommonErrorConstants;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.linkis.common.exception.ExceptionLevel.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class ExceptionManagerTest {
+
+    @Test
+    void testGenerateException() {
+        ErrorException errorException =
+                new ErrorException(
+                        CommonErrorConstants.COMMON_ERROR(),
+                        "The map cannot be parsed normally, "
+                                + "the map is empty or the LEVEL value is missing:(map不能被正常的解析,map为空或者缺少LEVEL值: )"
+                                + "null");
+        assertEquals(
+                errorException.getClass(), ExceptionManager.generateException(null).getClass());
+        assertEquals(
+                errorException.toString(), ExceptionManager.generateException(null).toString());
+        Map<String, Object> map = new HashMap<>();
+        map.put("level", null);
+        map.put("errCode", 1);
+        map.put("desc", "test");
+        map.put("ip", LinkisException.hostname);
+        map.put("port", LinkisException.hostPort);
+        map.put("serviceKind", LinkisException.applicationName);
+        errorException.setDesc(
+                "The map cannot be parsed normally, "
+                        + "the map is empty or the LEVEL value is missing:(map不能被正常的解析,map为空或者缺少LEVEL值: )"
+                        + map);
+        assertEquals(errorException.getClass(), ExceptionManager.generateException(map).getClass());
+        assertEquals(errorException.toString(), ExceptionManager.generateException(map).toString());
+        map.replace("level", ERROR.getLevel());
+        errorException.setErrCode((Integer) map.get("errCode"));
+        errorException.setIp(LinkisException.hostname);
+        errorException.setPort(LinkisException.hostPort);
+        errorException.setServiceKind(LinkisException.applicationName);
+        errorException.setDesc((String) map.get("desc"));
+        assertEquals(errorException.getClass(), ExceptionManager.generateException(map).getClass());
+        assertEquals(errorException.toString(), ExceptionManager.generateException(map).toString());
+        map.replace("level", WARN.getLevel());
+        WarnException warnException =
+                new WarnException(
+                        (Integer) map.get("errCode"),
+                        "test",
+                        LinkisException.hostname,
+                        LinkisException.hostPort,
+                        LinkisException.applicationName);
+        assertEquals(warnException.getClass(), ExceptionManager.generateException(map).getClass());
+        assertEquals(warnException.toString(), ExceptionManager.generateException(map).toString());
+        map.replace("level", FATAL.getLevel());
+        FatalException fatalException =
+                new FatalException(
+                        (Integer) map.get("errCode"),
+                        "test",
+                        LinkisException.hostname,
+                        LinkisException.hostPort,
+                        LinkisException.applicationName);
+        assertEquals(fatalException.getClass(), ExceptionManager.generateException(map).getClass());
+        assertEquals(fatalException.toString(), ExceptionManager.generateException(map).toString());
+        map.replace("level", RETRY.getLevel());
+        LinkisRetryException retryException =
+                new LinkisRetryException(
+                        (Integer) map.get("errCode"),
+                        "test",
+                        LinkisException.hostname,
+                        LinkisException.hostPort,
+                        LinkisException.applicationName);
+        assertEquals(retryException.getClass(), ExceptionManager.generateException(map).getClass());
+        assertEquals(retryException.toString(), ExceptionManager.generateException(map).toString());
+        map.replace("level", 123);
+        map.put("test", 123);
+        errorException.setErrCode(CommonErrorConstants.COMMON_ERROR());
+        errorException.setDesc("Exception Map that cannot be parsed:(不能解析的异常Map:)" + map);
+        assertEquals(errorException.getClass(), ExceptionManager.generateException(map).getClass());
+        assertEquals(errorException.toString(), ExceptionManager.generateException(map).toString());
+    }
+
+    @Test
+    void unknownException() {
+        Map<String, Object> map = ExceptionManager.unknownException("test");
+        Map<String, Object> assertMap = new HashMap<String, Object>();
+        assertMap.put("level", ERROR.getLevel());
+        assertMap.put("errCode", 0);
+        assertMap.put("desc", "test");
+        assertMap.put("ip", LinkisException.hostname);
+        assertMap.put("port", LinkisException.hostPort);
+        assertMap.put("serviceKind", LinkisException.applicationName);
+        assertTrue(map.equals(assertMap));
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/FatalExceptionTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/FatalExceptionTest.java
new file mode 100644
index 000000000..eedbc217b
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/FatalExceptionTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class FatalExceptionTest {
+
+    @Test
+    void testFatalException() {
+        FatalException fatalException1 = new FatalException(1, "test");
+        assertEquals(ExceptionLevel.FATAL, fatalException1.getLevel());
+        assertEquals("test", fatalException1.getDesc());
+        FatalException fatalException2 =
+                new FatalException(3, "test", "127.0.0.1", 1234, "serviceKind");
+        assertEquals(ExceptionLevel.FATAL, fatalException2.getLevel());
+        assertEquals("test", fatalException2.getDesc());
+        assertEquals("127.0.0.1", fatalException2.getIp());
+        assertEquals(1234, fatalException2.getPort());
+        assertEquals("serviceKind", fatalException2.getServiceKind());
+    }
+
+    @Test
+    void getLevel() {
+        FatalException fatalException = new FatalException(1, "test");
+        assertEquals(ExceptionLevel.FATAL, fatalException.getLevel());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisCommonErrorExceptionTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisCommonErrorExceptionTest.java
new file mode 100644
index 000000000..cc7a69d1f
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisCommonErrorExceptionTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class LinkisCommonErrorExceptionTest {
+
+    @Test
+    void testLinkisCommonErrorException() {
+        LinkisCommonErrorException linkisCommonErrorException =
+                new LinkisCommonErrorException(1, "test");
+        assertEquals(LinkisCommonErrorException.class, linkisCommonErrorException.getClass());
+        assertTrue(linkisCommonErrorException instanceof ErrorException);
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisExceptionTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisExceptionTest.java
new file mode 100644
index 000000000..41021a08b
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisExceptionTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class LinkisExceptionTest {
+
+    public static LinkisException linkisException =
+            new LinkisException(1, "test", "127.0.0.1", 1, "test") {
+                @Override
+                ExceptionLevel getLevel() {
+                    return ExceptionLevel.ERROR;
+                }
+            };
+
+    @Test
+    void testGetErrCode() {
+        assertEquals(1, linkisException.getErrCode());
+    }
+
+    @Test
+    void testSetErrCode() {
+        linkisException.setErrCode(123);
+        assertEquals(123, linkisException.getErrCode());
+        linkisException.setErrCode(1);
+        assertEquals(1, linkisException.getErrCode());
+    }
+
+    @Test
+    void testGetDesc() {
+        assertEquals("test", linkisException.getDesc());
+    }
+
+    @Test
+    void testSetDesc() {
+        linkisException.setDesc("test2");
+        assertEquals("test2", linkisException.getDesc());
+        linkisException.setDesc("test");
+        assertEquals("test", linkisException.getDesc());
+    }
+
+    @Test
+    void testGetIp() {
+        assertEquals("127.0.0.1", linkisException.getIp());
+    }
+
+    @Test
+    void testSetIp() {
+        linkisException.setIp("0.0.0.0");
+        assertEquals("0.0.0.0", linkisException.getIp());
+        linkisException.setIp("127.0.0.1");
+        assertEquals("127.0.0.1", linkisException.getIp());
+    }
+
+    @Test
+    void testGetPort() {
+        assertEquals(1, linkisException.getPort());
+    }
+
+    @Test
+    void testSetPort() {
+        linkisException.setPort(11);
+        assertEquals(11, linkisException.getPort());
+        linkisException.setPort(1);
+        assertEquals(1, linkisException.getPort());
+    }
+
+    @Test
+    void testGetServiceKind() {
+        assertEquals("test", linkisException.getServiceKind());
+    }
+
+    @Test
+    void testSetServiceKind() {
+        linkisException.setServiceKind("test2");
+        assertEquals("test2", linkisException.getServiceKind());
+        linkisException.setServiceKind("test");
+        assertEquals("test", linkisException.getServiceKind());
+    }
+
+    @Test
+    void toMap() {
+        Map<String, Object> map = new java.util.HashMap<String, Object>();
+        map.put("level", ExceptionLevel.ERROR.getLevel());
+        map.put("errCode", 1);
+        map.put("desc", "test");
+        map.put("ip", "127.0.0.1");
+        map.put("port", 1);
+        map.put("serviceKind", "test");
+        assertEquals(map, linkisException.toMap());
+    }
+
+    @Test
+    void testGetLevel() {
+        assertEquals(ExceptionLevel.ERROR, linkisException.getLevel());
+    }
+
+    @Test
+    void testToString() {
+        assertEquals(
+                "LinkisException{errCode=1, desc='test', ip='127.0.0.1', port=1, serviceKind='test'}",
+                linkisException.toString());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisRetryExceptionTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisRetryExceptionTest.java
new file mode 100644
index 000000000..840ec6551
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisRetryExceptionTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class LinkisRetryExceptionTest {
+
+    @Test
+    void testGetLevel() {
+        LinkisRetryException linkisRetryException = new LinkisRetryException(1, "test");
+        assertEquals(ExceptionLevel.RETRY, linkisRetryException.getLevel());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisRuntimeExceptionTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisRuntimeExceptionTest.java
new file mode 100644
index 000000000..4c3800627
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/LinkisRuntimeExceptionTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class LinkisRuntimeExceptionTest {
+
+    public static LinkisRuntimeException linkisRuntimeException =
+            new LinkisRuntimeException(1, "test", "127.0.0.1", 1, "serviceKind") {
+                @Override
+                public ExceptionLevel getLevel() {
+                    return ExceptionLevel.WARN;
+                }
+            };
+
+    @Test
+    void testGetErrCode() {
+        assertEquals(1, linkisRuntimeException.getErrCode());
+    }
+
+    @Test
+    void testSetErrCode() {
+        linkisRuntimeException.setErrCode(123);
+        assertEquals(123, linkisRuntimeException.getErrCode());
+        linkisRuntimeException.setErrCode(1);
+        assertEquals(1, linkisRuntimeException.getErrCode());
+    }
+
+    @Test
+    void testGetDesc() {
+        assertEquals("test", linkisRuntimeException.getDesc());
+    }
+
+    @Test
+    void testSetDesc() {
+        linkisRuntimeException.setDesc("test2");
+        assertEquals("test2", linkisRuntimeException.getDesc());
+        linkisRuntimeException.setDesc("test");
+        assertEquals("test", linkisRuntimeException.getDesc());
+    }
+
+    @Test
+    void testGetIp() {
+        assertEquals("127.0.0.1", linkisRuntimeException.getIp());
+    }
+
+    @Test
+    void testSetIp() {
+        linkisRuntimeException.setIp("0.0.0.0");
+        assertEquals("0.0.0.0", linkisRuntimeException.getIp());
+        linkisRuntimeException.setIp("127.0.0.1");
+        assertEquals("127.0.0.1", linkisRuntimeException.getIp());
+    }
+
+    @Test
+    void testGetPort() {
+        assertEquals(1, linkisRuntimeException.getPort());
+    }
+
+    @Test
+    void testSetPort() {
+        linkisRuntimeException.setPort(11);
+        assertEquals(11, linkisRuntimeException.getPort());
+        linkisRuntimeException.setPort(1);
+        assertEquals(1, linkisRuntimeException.getPort());
+    }
+
+    @Test
+    void testGetServiceKind() {
+        assertEquals("test", linkisRuntimeException.getServiceKind());
+    }
+
+    @Test
+    void testSetServiceKind() {
+        linkisRuntimeException.setServiceKind("test2");
+        assertEquals("test2", linkisRuntimeException.getServiceKind());
+        linkisRuntimeException.setServiceKind("test");
+        assertEquals("test", linkisRuntimeException.getServiceKind());
+    }
+
+    @Test
+    void toMap() {
+        Map<String, Object> map = new java.util.HashMap<String, Object>();
+        map.put("level", ExceptionLevel.WARN.getLevel());
+        map.put("errCode", 1);
+        map.put("desc", "test");
+        map.put("ip", "127.0.0.1");
+        map.put("port", 1);
+        map.put("serviceKind", "test");
+        assertEquals(map, linkisRuntimeException.toMap());
+    }
+
+    @Test
+    void testGetLevel() {
+        assertEquals(ExceptionLevel.WARN, linkisRuntimeException.getLevel());
+    }
+
+    @Test
+    void testToString() {
+        assertEquals(
+                "LinkisException{errCode=1, desc='test', ip='127.0.0.1', port=1, serviceKind='test'}",
+                linkisRuntimeException.toString());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/WarnExceptionTest.java b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/WarnExceptionTest.java
new file mode 100644
index 000000000..db6b5d104
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/java/org/apache/linkis/common/exception/WarnExceptionTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.linkis.common.exception;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class WarnExceptionTest {
+
+    @Test
+    void testWarnException() {
+        WarnException warnException1 = new WarnException(1, "test");
+        assertEquals(ExceptionLevel.WARN, warnException1.getLevel());
+        assertEquals("test", warnException1.getDesc());
+        WarnException warnException2 =
+                new WarnException(3, "test", "127.0.0.1", 1234, "serviceKind");
+        assertEquals(ExceptionLevel.WARN, warnException2.getLevel());
+        assertEquals("test", warnException2.getDesc());
+        assertEquals("127.0.0.1", warnException2.getIp());
+        assertEquals(1234, warnException2.getPort());
+        assertEquals("serviceKind", warnException2.getServiceKind());
+    }
+
+    @Test
+    void testGetLevel() {
+        WarnException warnException = new WarnException(2, "test");
+        assertEquals(ExceptionLevel.WARN, warnException.getLevel());
+    }
+}
diff --git a/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ArrayUtilsTest.scala b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ArrayUtilsTest.scala
new file mode 100644
index 000000000..4fc3069d2
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ArrayUtilsTest.scala
@@ -0,0 +1,68 @@
+/*
+ * 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.linkis.common.utils
+
+import org.junit.jupiter.api.Assertions._
+import org.junit.jupiter.api.Test
+
+class ArrayUtilsTest {
+  @Test private[utils] def testCopyArray() = {
+    val array = ArrayUtils.newArray[scala.Int](2, Array.emptyIntArray.getClass)
+    array(0) = 123
+    array(1) = 456
+    val newArray = ArrayUtils.copyArray(array)
+    assertEquals("Array(123, 456)", newArray.mkString("Array(", ", ", ")"))
+    val newArray1 = ArrayUtils.copyArray(array, 1)
+    assertEquals(1, newArray1.length)
+    assertEquals("Array(123)", newArray1.mkString("Array(", ", ", ")"))
+    val newArray2 = ArrayUtils.copyArray(array, 10)
+    assertEquals(10, newArray2.length)
+    assertEquals(123, newArray2(0))
+    assertEquals(456, newArray2(1))
+    assertEquals(0, newArray2(2))
+  }
+
+  @Test private[utils] def testCopyArrayWithClass() = {
+    val array = ArrayUtils.newArray[scala.Int](3, Array.emptyIntArray.getClass)
+    val newArray = ArrayUtils.copyArrayWithClass(array, array(0).getClass)
+    assertEquals(newArray.getClass, Array.emptyIntArray.getClass)
+    assertTrue(newArray.isInstanceOf[Array[scala.Int]])
+  }
+
+  @Test private[utils] def testNewArray() = {
+    val array = ArrayUtils.newArray[scala.Int](0, Array.emptyIntArray.getClass)
+    assertEquals(array.getClass, Array.emptyIntArray.getClass)
+    assertTrue(array.isInstanceOf[Array[scala.Int]])
+  }
+
+  @Test private[utils] def testCopyScalaArray() = {
+    val array = ArrayUtils.newArray[scala.Int](2, Array.emptyIntArray.getClass)
+    array(0) = 123
+    array(1) = 456
+    val newArray = ArrayUtils.copyScalaArray(array)
+    assertEquals("Array(123, 456)", newArray.mkString("Array(", ", ", ")"))
+    val newArray1 = ArrayUtils.copyScalaArray(array, 1)
+    assertEquals(1, newArray1.length)
+    assertEquals("Array(123)", newArray1.mkString("Array(", ", ", ")"))
+    val newArray2 = ArrayUtils.copyScalaArray(array, 10)
+    assertEquals(10, newArray2.length)
+    assertEquals(123, newArray2(0))
+    assertEquals(456, newArray2(1))
+    assertEquals(0, newArray2(2))
+  }
+}
diff --git a/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ClassUtilsTest.scala b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ClassUtilsTest.scala
new file mode 100644
index 000000000..5bd522bed
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/ClassUtilsTest.scala
@@ -0,0 +1,66 @@
+/*
+ * 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.linkis.common.utils
+
+import org.junit.jupiter.api.Assertions._
+import org.junit.jupiter.api.Test
+
+import java.util.Hashtable
+
+class ClassUtilsTest {
+  @Test private[utils] def testJarOfClass():Unit = {
+    val hashTable = new Hashtable[String, String]()
+    val someClass = ClassUtils.jarOfClass(hashTable.getClass)
+    val uri = hashTable.getClass.getResource(
+      "/" +
+        hashTable.getClass.getName.replace('.', '/') + ".class")
+    assertEquals(
+      Some(uri.toString.substring("jar:file:".length, uri.toString.indexOf("!")))
+      , someClass)
+  }
+
+  @Test private[utils] def testGetClassInstance():Unit = {
+    val hashTable = new Hashtable[String, String]()
+    assertTrue(ClassUtils.getClassInstance(hashTable.getClass.getName).isInstanceOf[Hashtable[String, String]])
+  }
+
+  @Test private[utils] def testGetFieldVal():Unit = {
+    val hashTable = new Hashtable[String, String]()
+    var modCount = ClassUtils.getFieldVal(hashTable, "modCount")
+    assertEquals(0, modCount)
+    hashTable.put("abc", "123")
+    modCount = ClassUtils.getFieldVal(hashTable, "modCount")
+    assertEquals(1, modCount)
+  }
+
+  @Test private[utils] def testSetFieldVal():Unit = {
+    val hashTable = new Hashtable[String, String]()
+    ClassUtils.setFieldVal(hashTable, "modCount", 3)
+    var modCount = ClassUtils.getFieldVal(hashTable, "modCount")
+    assertEquals(3, modCount)
+    ClassUtils.setFieldVal(hashTable, "modCount", 0)
+    modCount = ClassUtils.getFieldVal(hashTable, "modCount")
+    assertEquals(0, modCount)
+  }
+
+  @Test private[utils] def testIsInterfaceOrAbstract():Unit = {
+    assertTrue(ClassUtils.isInterfaceOrAbstract(classOf[Cloneable]))
+    assertFalse(ClassUtils.isInterfaceOrAbstract(classOf[String]))
+    assertTrue(ClassUtils.isInterfaceOrAbstract(Class.forName("java.util.Dictionary")))
+  }
+}
diff --git a/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/OverloadUtilsTest.scala b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/OverloadUtilsTest.scala
new file mode 100644
index 000000000..5b99498d9
--- /dev/null
+++ b/linkis-commons/linkis-common/src/test/scala/org/apache/linkis/common/utils/OverloadUtilsTest.scala
@@ -0,0 +1,57 @@
+/*
+ * 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.linkis.common.utils
+
+import com.sun.management.OperatingSystemMXBean
+import org.junit.jupiter.api.Assertions._
+import org.junit.jupiter.api.Test
+
+import java.lang.management.ManagementFactory
+
+class OverloadUtilsTest {
+  @Test private[utils] def testGetOSBean():Unit = {
+    assertTrue(OverloadUtils.getOSBean.isInstanceOf[OperatingSystemMXBean])
+  }
+
+  @Test private[utils] def testGetProcessMaxMemory():Unit = {
+    val a = OverloadUtils.getProcessMaxMemory
+    val b = ManagementFactory.getMemoryMXBean.getHeapMemoryUsage.getMax
+    assertEquals(a, b)
+  }
+
+  @Test private[utils] def testGetProcessUsedMemory():Unit = {
+    this.synchronized {
+      assertEquals(OverloadUtils.getProcessUsedMemory,
+        ManagementFactory.getMemoryMXBean.getHeapMemoryUsage.getUsed)
+    }
+  }
+
+  @Test private[utils] def testGetSystemCPUUsed():Unit = {
+    this.synchronized {
+      assertEquals(OverloadUtils.getSystemCPUUsed,
+        ManagementFactory.getOperatingSystemMXBean.getSystemLoadAverage.toFloat)
+    }
+  }
+
+  @Test private[utils] def testGetSystemFreeMemory():Unit = {
+    this.synchronized {
+      assertEquals(OverloadUtils.getSystemFreeMemory,
+        OverloadUtils.getOSBean.getFreePhysicalMemorySize)
+    }
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org