You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by su...@apache.org on 2023/04/27 10:24:15 UTC
[shardingsphere] branch master updated: Refactor ClassicTransferTestCase (#25366)
This is an automated email from the ASF dual-hosted git repository.
sunnianjun 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 eb3b873b00a Refactor ClassicTransferTestCase (#25366)
eb3b873b00a is described below
commit eb3b873b00a5b72f1f29f441d25304aa90115e0a
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Apr 27 18:24:03 2023 +0800
Refactor ClassicTransferTestCase (#25366)
* Remove useless CircuitBreakerDataSource.close()
* Refactor ClassicTransferTestCase
---
.../classictransfer/ClassicTransferTestCase.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/classictransfer/ClassicTransferTestCase.java b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/classictransfer/ClassicTransferTestCase.java
index 5a7a96702d7..dff24211760 100644
--- a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/classictransfer/ClassicTransferTestCase.java
+++ b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/classictransfer/ClassicTransferTestCase.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.test.e2e.transaction.cases.classictransfer;
-import lombok.AllArgsConstructor;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.apache.shardingsphere.test.e2e.transaction.cases.base.BaseTransactionTestCase;
import org.apache.shardingsphere.test.e2e.transaction.engine.base.TransactionBaseE2EIT;
@@ -58,13 +58,13 @@ public final class ClassicTransferTestCase extends BaseTransactionTestCase {
private void innerRun() throws SQLException {
List<Thread> tasks = new LinkedList<>();
for (int i = 0; i < 20; i++) {
- Thread updateThread = new UpdateTread(getDataSource());
+ Thread updateThread = new Thread(new UpdateAccountTask(getDataSource()));
updateThread.start();
tasks.add(updateThread);
int sum = getBalanceSum();
assertThat(String.format("Balance sum is %s, should be 100.", sum), sum, is(100));
}
- Thread.sleep(3000);
+ Thread.sleep(3000L);
int sum = getBalanceSum();
assertThat(String.format("Balance sum is %s, should be 100.", sum), sum, is(100));
for (Thread task : tasks) {
@@ -85,20 +85,20 @@ public final class ClassicTransferTestCase extends BaseTransactionTestCase {
return result;
}
- @AllArgsConstructor
- private static class UpdateTread extends Thread {
+ @RequiredArgsConstructor
+ @Getter
+ private static class UpdateAccountTask implements Runnable {
- @Getter
- private DataSource dataSource;
+ private final DataSource dataSource;
public void run() {
try (Connection connection = dataSource.getConnection()) {
connection.setAutoCommit(false);
Statement statement1 = connection.createStatement();
- statement1.execute("update account set balance = balance - 1 where transaction_id = 2;");
+ statement1.execute("UPDATE account SET balance = balance - 1 WHERE transaction_id = 2;");
Statement statement2 = connection.createStatement();
- Thread.sleep(1000);
- statement2.execute("update account set balance = balance + 1 where transaction_id = 1;");
+ Thread.sleep(1000L);
+ statement2.execute("UPDATE account SET balance = balance + 1 WHERE transaction_id = 1;");
connection.commit();
} catch (final SQLException | InterruptedException ignored) {
}