This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 921843d Move ITWatcher to shardingsphere-integration-test-fixture
module (#9805)
921843d is described below
commit 921843d72944efef6217e58fc02ad4885d995889
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Mar 24 19:24:46 2021 +0800
Move ITWatcher to shardingsphere-integration-test-fixture module (#9805)
* Refactor ITWatcher
* For xml format
* Refactor ITWatcher
* Move ITWatcher to shardingsphere-integration-test-fixture module
---
.../test/integration/junit/watcher}/ITWatcher.java | 12 ++++++------
.../shardingsphere-integration-test-suite/pom.xml | 4 ++--
.../test/integration/engine/it/BaseITCase.java | 6 +++---
.../test/integration/engine/it/SingleITCase.java | 4 +---
4 files changed, 12 insertions(+), 14 deletions(-)
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITWatcher.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/watcher/ITWatcher.java
similarity index 83%
rename from
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITWatcher.java
rename to
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/watcher/ITWatcher.java
index 3f048d2..2b87978 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/junit/ITWatcher.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-fixture/src/test/java/org/apache/shardingsphere/test/integration/junit/watcher/ITWatcher.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.test.integration.engine.junit;
+package org.apache.shardingsphere.test.integration.junit.watcher;
import lombok.extern.slf4j.Slf4j;
import org.junit.rules.TestWatcher;
@@ -31,12 +31,12 @@ import java.io.PrintStream;
public final class ITWatcher extends TestWatcher {
@Override
- protected void failed(final Throwable ex, final Description description) {
- log.error("Error case: {}, message: {}", description.getMethodName(),
stackTrace(ex));
- super.failed(ex, description);
+ protected void failed(final Throwable cause, final Description
description) {
+ log.error("Error case: {}, message: {}", description.getMethodName(),
getStackTrace(cause));
+ super.failed(cause, description);
}
- private String stackTrace(final Throwable cause) {
+ private String getStackTrace(final Throwable cause) {
if (null == cause) {
return "";
}
@@ -48,7 +48,7 @@ public final class ITWatcher extends TestWatcher {
//CHECKSTYLE:OFF
} catch (final Exception ignored) {
//CHECKSTYLE:ON
+ return "";
}
- return "";
}
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
index 917c180..5fbcc2f 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
@@ -25,7 +25,7 @@
</parent>
<artifactId>shardingsphere-integration-test-suite</artifactId>
<name>${project.artifactId}</name>
-
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
@@ -33,7 +33,7 @@
<version>${project.version}</version>
<type>test-jar</type>
</dependency>
-
+
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
index afc45b1..47d03f6 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/BaseITCase.java
@@ -111,7 +111,7 @@ public abstract class BaseITCase {
}
protected String getLiteralSQL(final String sql) throws ParseException {
- List<Object> parameters = null == getAssertion() ?
Collections.emptyList() :
getAssertion().getSQLValues().stream().map(SQLValue::toString).collect(Collectors.toList());
+ List<Object> parameters = null == assertion ? Collections.emptyList()
:
assertion.getSQLValues().stream().map(SQLValue::toString).collect(Collectors.toList());
return parameters.isEmpty() ? sql : String.format(sql.replace("%",
"$").replace("?", "%s"), parameters.toArray()).replace("$", "%").replace("%%",
"%").replace("'%'", "'%%'");
}
@@ -124,8 +124,8 @@ public abstract class BaseITCase {
@After
public final void tearDown() {
- if (getTargetDataSource() instanceof ShardingSphereDataSource) {
- ((ShardingSphereDataSource)
getTargetDataSource()).getMetaDataContexts().getExecutorEngine().close();
+ if (dataSource instanceof ShardingSphereDataSource) {
+ ((ShardingSphereDataSource)
dataSource).getMetaDataContexts().getExecutorEngine().close();
}
}
}
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleITCase.java
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleITCase.java
index a7dea0c..e3f3363 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleITCase.java
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/src/test/java/org/apache/shardingsphere/test/integration/engine/it/SingleITCase.java
@@ -19,10 +19,9 @@ package org.apache.shardingsphere.test.integration.engine.it;
import lombok.AccessLevel;
import lombok.Getter;
-import lombok.SneakyThrows;
import org.apache.shardingsphere.test.integration.cases.dataset.DataSet;
import org.apache.shardingsphere.test.integration.cases.dataset.DataSetLoader;
-import org.apache.shardingsphere.test.integration.engine.junit.ITWatcher;
+import org.apache.shardingsphere.test.integration.junit.watcher.ITWatcher;
import org.junit.Before;
import org.junit.Rule;
@@ -35,7 +34,6 @@ public abstract class SingleITCase extends BaseITCase {
private DataSet dataSet;
@Before
- @SneakyThrows
public void setup() {
dataSet = null == getAssertion() ? null :
DataSetLoader.load(getParentPath(), getDescription().getScenario(),
getDescription().getDatabaseType(), getAssertion().getExpectedDataFile());
}