This is an automated email from the ASF dual-hosted git repository.
panjuan 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 e1126a7c789 Add ShardingSphereInsideExceptionTest (#19988)
e1126a7c789 is described below
commit e1126a7c7897b15485aaabf5ddb3ad9fd7372fd7
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Aug 8 20:33:17 2022 +0800
Add ShardingSphereInsideExceptionTest (#19988)
---
.../exception/ShardingSphereInsideException.java | 8 +++---
.../ShardingSphereInsideExceptionTest.java} | 30 +++++++++++++---------
.../ShardingSphereInsideExceptionFixture.java} | 19 +++++++-------
3 files changed, 31 insertions(+), 26 deletions(-)
diff --git
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
index cdc58df4671..e4bf2356f62 100644
---
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
+++
b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
@@ -28,11 +28,11 @@ public abstract class ShardingSphereInsideException extends
Exception {
super(String.format(errorMessage, args));
}
- public ShardingSphereInsideException(final String message, final Exception
cause) {
- super(message, cause);
- }
-
public ShardingSphereInsideException(final Exception cause) {
super(cause);
}
+
+ public ShardingSphereInsideException(final String message, final Exception
cause) {
+ super(message, cause);
+ }
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideExceptionTest.java
similarity index 51%
copy from
shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
copy to
shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideExceptionTest.java
index cdc58df4671..71098cd159f 100644
---
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
+++
b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideExceptionTest.java
@@ -17,22 +17,28 @@
package org.apache.shardingsphere.infra.util.exception;
-/**
- * ShardingSphere inside exception.
- */
-public abstract class ShardingSphereInsideException extends Exception {
-
- private static final long serialVersionUID = -8238061892944243621L;
+import
org.apache.shardingsphere.infra.util.exception.fixture.ShardingSphereInsideExceptionFixture;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class ShardingSphereInsideExceptionTest {
- public ShardingSphereInsideException(final String errorMessage, final
Object... args) {
- super(String.format(errorMessage, args));
+ @Test
+ public void assertGetMessage() {
+ assertThat(new
ShardingSphereInsideExceptionFixture("Test").getMessage(), is("Fixture error
message: Test"));
}
- public ShardingSphereInsideException(final String message, final Exception
cause) {
- super(message, cause);
+ @Test
+ public void assertGetCause() {
+ RuntimeException cause = new RuntimeException("Test");
+ assertThat(new ShardingSphereInsideExceptionFixture(cause).getCause(),
is(cause));
}
- public ShardingSphereInsideException(final Exception cause) {
- super(cause);
+ @Test
+ public void assertGetCauseWithMessage() {
+ RuntimeException cause = new RuntimeException("Test");
+ assertThat(new ShardingSphereInsideExceptionFixture("Test",
cause).getCause(), is(cause));
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInsideExceptionFixture.java
similarity index 59%
copy from
shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
copy to
shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInsideExceptionFixture.java
index cdc58df4671..83e65e606be 100644
---
a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSphereInsideException.java
+++
b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/fixture/ShardingSphereInsideExceptionFixture.java
@@ -15,24 +15,23 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.util.exception;
+package org.apache.shardingsphere.infra.util.exception.fixture;
-/**
- * ShardingSphere inside exception.
- */
-public abstract class ShardingSphereInsideException extends Exception {
+import
org.apache.shardingsphere.infra.util.exception.ShardingSphereInsideException;
+
+public final class ShardingSphereInsideExceptionFixture extends
ShardingSphereInsideException {
- private static final long serialVersionUID = -8238061892944243621L;
+ private static final long serialVersionUID = 3759417279204541147L;
- public ShardingSphereInsideException(final String errorMessage, final
Object... args) {
- super(String.format(errorMessage, args));
+ public ShardingSphereInsideExceptionFixture(final String message) {
+ super("Fixture error message: %s", message);
}
- public ShardingSphereInsideException(final String message, final Exception
cause) {
+ public ShardingSphereInsideExceptionFixture(final String message, final
Exception cause) {
super(message, cause);
}
- public ShardingSphereInsideException(final Exception cause) {
+ public ShardingSphereInsideExceptionFixture(final Exception cause) {
super(cause);
}
}