You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/09/04 11:34:53 UTC

[shardingsphere] branch master updated: [Issue #20749]-Added unit test for ShardingSpherePreconditions (#20765)

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 677f9427cec [Issue #20749]-Added unit test for ShardingSpherePreconditions (#20765)
677f9427cec is described below

commit 677f9427cec83fc8d920336c792b14afb227601c
Author: Abhinav Koppula <ab...@gmail.com>
AuthorDate: Sun Sep 4 17:04:44 2022 +0530

    [Issue #20749]-Added unit test for ShardingSpherePreconditions (#20765)
---
 .../exception/ShardingSpherePreconditionsTest.java | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditionsTest.java b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditionsTest.java
new file mode 100644
index 00000000000..4a57e96f782
--- /dev/null
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditionsTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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 java.sql.SQLException;
+import org.apache.shardingsphere.infra.util.exception.external.ShardingSphereExternalException;
+import org.apache.shardingsphere.infra.util.exception.external.sql.SQLWrapperException;
+import org.apache.shardingsphere.infra.util.exception.internal.ShardingSphereInternalException;
+import org.apache.shardingsphere.infra.util.exception.internal.fixture.ShardingSphereInternalExceptionFixture;
+import org.junit.Test;
+
+public final class ShardingSpherePreconditionsTest {
+    
+    @Test(expected = ShardingSphereExternalException.class)
+    public void assertCheckStateThrowsExternalException() {
+        ShardingSphereExternalException exception = new SQLWrapperException(new SQLException());
+        ShardingSpherePreconditions.checkState(false, exception);
+    }
+    
+    @Test(expected = Test.None.class)
+    public void assertCheckStateToNotThrowExternalException() {
+        ShardingSphereExternalException exception = new SQLWrapperException(new SQLException());
+        ShardingSpherePreconditions.checkState(true, exception);
+    }
+    
+    @Test(expected = ShardingSphereInternalException.class)
+    public void assertCheckStateThrowsInternalException() throws ShardingSphereInternalException {
+        ShardingSphereInternalException exception = new ShardingSphereInternalExceptionFixture("message");
+        ShardingSpherePreconditions.checkState(false, exception);
+    }
+    
+    @Test(expected = Test.None.class)
+    public void assertCheckStateToNotThrowInternalException() throws ShardingSphereInternalException {
+        ShardingSphereInternalException exception = new ShardingSphereInternalExceptionFixture("message");
+        ShardingSpherePreconditions.checkState(true, exception);
+    }
+}