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 753e1d22e5b Move the teardown code for the E2E test to the finally
block. (#32764)
753e1d22e5b is described below
commit 753e1d22e5b6407186708a308780a1552e05117f
Author: Cong Hu <[email protected]>
AuthorDate: Mon Sep 2 15:59:06 2024 +0800
Move the teardown code for the E2E test to the finally block. (#32764)
---
.../test/e2e/engine/type/DDLE2EIT.java | 6 ++--
.../test/e2e/engine/type/RALE2EIT.java | 7 +++--
.../test/e2e/engine/type/RDLE2EIT.java | 7 +++--
.../test/e2e/engine/type/dml/BatchDMLE2EIT.java | 16 ++++++----
.../test/e2e/engine/type/dml/GeneralDMLE2EIT.java | 34 +++++++++++++---------
5 files changed, 44 insertions(+), 26 deletions(-)
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
index 4d315e4cd47..a57d2724d07 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/DDLE2EIT.java
@@ -83,8 +83,9 @@ class DDLE2EIT implements E2EEnvironmentAware {
executeUpdateForPreparedStatement(context, connection);
}
assertTableMetaData(testParam, context);
+ } finally {
+ tearDown(context);
}
- tearDown(context);
}
private void executeUpdateForStatement(final E2ETestContext context, final
Connection connection) throws SQLException {
@@ -118,8 +119,9 @@ class DDLE2EIT implements E2EEnvironmentAware {
executeForPreparedStatement(context, connection);
}
assertTableMetaData(testParam, context);
+ } finally {
+ tearDown(context);
}
- tearDown(context);
}
private void executeForStatement(final E2ETestContext context, final
Connection connection) throws SQLException {
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java
index 11326403aac..cf62fe6f65a 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RALE2EIT.java
@@ -70,8 +70,11 @@ class RALE2EIT implements E2EEnvironmentAware {
}
E2ETestContext context = new E2ETestContext(testParam);
init(context);
- assertExecute(context);
- tearDown(context);
+ try {
+ assertExecute(context);
+ } finally {
+ tearDown(context);
+ }
}
private void assertExecute(final E2ETestContext context) throws
SQLException {
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java
index 81764a29165..9ad1d64ae1b 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/RDLE2EIT.java
@@ -70,8 +70,11 @@ class RDLE2EIT implements E2EEnvironmentAware {
}
E2ETestContext context = new E2ETestContext(testParam);
init(context);
- assertExecute(testParam, context);
- tearDown(context);
+ try {
+ assertExecute(testParam, context);
+ } finally {
+ tearDown(context);
+ }
}
private void assertExecute(final AssertionTestParameter testParam, final
E2ETestContext context) throws SQLException {
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BatchDMLE2EIT.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BatchDMLE2EIT.java
index cce603e75d0..be57989abe2 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BatchDMLE2EIT.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BatchDMLE2EIT.java
@@ -49,12 +49,15 @@ class BatchDMLE2EIT extends BaseDMLE2EIT {
return;
}
init(testParam);
- int[] actualUpdateCounts;
- try (Connection connection =
getEnvironmentEngine().getTargetDataSource().getConnection()) {
- actualUpdateCounts = executeBatchForPreparedStatement(testParam,
connection);
+ try {
+ int[] actualUpdateCounts;
+ try (Connection connection =
getEnvironmentEngine().getTargetDataSource().getConnection()) {
+ actualUpdateCounts =
executeBatchForPreparedStatement(testParam, connection);
+ }
+ assertDataSet(actualUpdateCounts, testParam);
+ } finally {
+ tearDown(testParam);
}
- assertDataSet(actualUpdateCounts, testParam);
- tearDown(testParam);
}
void init(final CaseTestParameter testParam) throws SQLException,
IOException, JAXBException {
@@ -112,8 +115,9 @@ class BatchDMLE2EIT extends BaseDMLE2EIT {
}
preparedStatement.clearBatch();
assertThat(preparedStatement.executeBatch().length, is(0));
+ } finally {
+ tearDown(testParam);
}
- tearDown(testParam);
}
private static boolean isEnabled() {
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/GeneralDMLE2EIT.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/GeneralDMLE2EIT.java
index bd7de8646ee..fa11a303ed0 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/GeneralDMLE2EIT.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/GeneralDMLE2EIT.java
@@ -51,14 +51,17 @@ class GeneralDMLE2EIT extends BaseDMLE2EIT {
}
E2ETestContext context = new E2ETestContext(testParam);
init(testParam);
- int actualUpdateCount;
- try (Connection connection =
getEnvironmentEngine().getTargetDataSource().getConnection()) {
- actualUpdateCount = SQLExecuteType.LITERAL ==
context.getSqlExecuteType()
- ? executeUpdateForStatement(context, connection)
- : executeUpdateForPreparedStatement(context, connection);
+ try {
+ int actualUpdateCount;
+ try (Connection connection =
getEnvironmentEngine().getTargetDataSource().getConnection()) {
+ actualUpdateCount = SQLExecuteType.LITERAL ==
context.getSqlExecuteType()
+ ? executeUpdateForStatement(context, connection)
+ : executeUpdateForPreparedStatement(context,
connection);
+ }
+ assertDataSet(context, actualUpdateCount, testParam);
+ } finally {
+ tearDown(context);
}
- assertDataSet(context, actualUpdateCount, testParam);
- tearDown(context);
}
void init(final AssertionTestParameter testParam) throws SQLException,
IOException, JAXBException {
@@ -96,14 +99,17 @@ class GeneralDMLE2EIT extends BaseDMLE2EIT {
}
E2ETestContext context = new E2ETestContext(testParam);
init(testParam);
- int actualUpdateCount;
- try (Connection connection =
getEnvironmentEngine().getTargetDataSource().getConnection()) {
- actualUpdateCount = SQLExecuteType.LITERAL ==
context.getSqlExecuteType()
- ? executeForStatement(context, connection)
- : executeForPreparedStatement(context, connection);
+ try {
+ int actualUpdateCount;
+ try (Connection connection =
getEnvironmentEngine().getTargetDataSource().getConnection()) {
+ actualUpdateCount = SQLExecuteType.LITERAL ==
context.getSqlExecuteType()
+ ? executeForStatement(context, connection)
+ : executeForPreparedStatement(context, connection);
+ }
+ assertDataSet(context, actualUpdateCount, testParam);
+ } finally {
+ tearDown(context);
}
- assertDataSet(context, actualUpdateCount, testParam);
- tearDown(context);
}
private int executeForStatement(final E2ETestContext context, final
Connection connection) throws SQLException {