This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new ba0aa7e3ed0 Add test case for ShardingSphereException (#19985)
ba0aa7e3ed0 is described below
commit ba0aa7e3ed08d258fff250a31152ba258f4dd0e9
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Aug 8 20:22:01 2022 +0800
Add test case for ShardingSphereException (#19985)
* Deprecated
org.apache.shardingsphere.infra.exception.ShardingSphereException
* Add ShardingSphereExceptionTest
---
.../exception/ShardingSphereExceptionTest.java | 38 ++++++++++++++++++++++
.../fixture/ShardingSphereExceptionFixture.java | 33 +++++++++++++++++++
2 files changed, 71 insertions(+)
diff --git
a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereExceptionTest.java
b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereExceptionTest.java
new file mode 100644
index 00000000000..865c72732ce
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereExceptionTest.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.shardingsphere.infra.util.exception;
+
+import
org.apache.shardingsphere.infra.util.exception.fixture.ShardingSphereExceptionFixture;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class ShardingSphereExceptionTest {
+
+ @Test
+ public void assertGetMessage() {
+ assertThat(new ShardingSphereExceptionFixture().getMessage(),
is("FIXTURE-00001: Fixture error message"));
+ }
+
+ @Test
+ public void assertGetCause() {
+ RuntimeException cause = new RuntimeException("Test");
+ assertThat(new ShardingSphereExceptionFixture(cause).getCause(),
is(cause));
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereExceptionFixture.java
b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereExceptionFixture.java
new file mode 100644
index 00000000000..6b0903e4e4c
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereExceptionFixture.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.shardingsphere.infra.util.exception.fixture;
+
+import org.apache.shardingsphere.infra.util.exception.ShardingSphereException;
+
+public final class ShardingSphereExceptionFixture extends
ShardingSphereException {
+
+ private static final long serialVersionUID = 4263474713534006256L;
+
+ public ShardingSphereExceptionFixture() {
+ super("FIXTURE", 1, "Fixture error message");
+ }
+
+ public ShardingSphereExceptionFixture(final Exception cause) {
+ super("FIXTURE", 1, "Fixture error message", cause);
+ }
+}