strongduanmu commented on code in PR #20254:
URL: https://github.com/apache/shardingsphere/pull/20254#discussion_r950057072


##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/ExceptionInTransactionTestCase.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.integration.transaction.cases.commitrollback;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * An exception occurred within the transaction integration test.
+ */
+@Slf4j
+@TransactionTestCase
+public final class ExceptionInTransactionTestCase extends 
BaseTransactionTestCase {
+    
+    public ExceptionInTransactionTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
+    }
+    
+    @Override
+    @SneakyThrows(SQLException.class)
+    protected void executeTest() {
+        Connection conn = null;
+        try {
+            conn = getDataSource().getConnection();
+            conn.setAutoCommit(false);
+            assertAccountRowCount(conn, 0);
+            executeWithLog(conn, "insert into account(id, balance, 
transaction_id) values(1, 1, 1);");
+            // Simulate execution exception in transaction
+            int errorResult = 1 / 0;
+            executeWithLog(conn, "insert into account(id, balance, 
transaction_id) values(2, 2, 2);");
+            conn.commit();
+            fail("It should fail here.");
+        } catch (final ArithmeticException ex) {
+            assertThat(ex.getMessage(), is("/ by zero"));
+        } finally {
+            if (null != conn) {
+                conn.rollback();
+            }
+        }
+        Thread queryThread = new Thread(() -> {
+            log.info("Execute query in new thread.");
+            try (Connection connection = getDataSource().getConnection()) {
+                assertAccountRowCount(connection, 0);
+            } catch (final SQLException ignored) {
+                
+            }
+        });
+        queryThread.start();
+        try {
+            queryThread.join();
+            log.info("ExceptionInTransactionTestCase test over.");
+        } catch (final InterruptedException ignored) {
+            

Review Comment:
   Please remove this blank line.



##########
shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-transaction/src/test/java/org/apache/shardingsphere/integration/transaction/cases/commitrollback/ExceptionInTransactionTestCase.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.integration.transaction.cases.commitrollback;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import 
org.apache.shardingsphere.integration.transaction.cases.base.BaseTransactionTestCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.BaseTransactionITCase;
+import 
org.apache.shardingsphere.integration.transaction.engine.base.TransactionTestCase;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * An exception occurred within the transaction integration test.
+ */
+@Slf4j
+@TransactionTestCase
+public final class ExceptionInTransactionTestCase extends 
BaseTransactionTestCase {
+    
+    public ExceptionInTransactionTestCase(final BaseTransactionITCase 
baseTransactionITCase, final DataSource dataSource) {
+        super(baseTransactionITCase, dataSource);
+    }
+    
+    @Override
+    @SneakyThrows(SQLException.class)
+    protected void executeTest() {
+        Connection conn = null;
+        try {
+            conn = getDataSource().getConnection();
+            conn.setAutoCommit(false);
+            assertAccountRowCount(conn, 0);
+            executeWithLog(conn, "insert into account(id, balance, 
transaction_id) values(1, 1, 1);");
+            // Simulate execution exception in transaction

Review Comment:
   Please remove this useless doc.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to