From 2bd39c9e7e034dea109c102961819aa7f0029d44 Mon Sep 17 00:00:00 2001
From: will <349071347@qq.com>
Date: Tue, 22 Dec 2020 12:49:53 +0800
Subject: [PATCH] optimize: optimize StatementProxyTest unit test (#3383)

---
 .../java/io/seata/rm/datasource/StatementProxyTest.java  | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/rm-datasource/src/test/java/io/seata/rm/datasource/StatementProxyTest.java b/rm-datasource/src/test/java/io/seata/rm/datasource/StatementProxyTest.java
index 4a9ff5035..8260ef81e 100644
--- a/rm-datasource/src/test/java/io/seata/rm/datasource/StatementProxyTest.java
+++ b/rm-datasource/src/test/java/io/seata/rm/datasource/StatementProxyTest.java
@@ -30,12 +30,15 @@ import com.google.common.collect.Lists;
 import io.seata.common.loader.EnhancedServiceLoader;
 import io.seata.rm.datasource.mock.MockConnection;
 import io.seata.rm.datasource.mock.MockDriver;
+
 import io.seata.sqlparser.SQLRecognizerFactory;
 import io.seata.sqlparser.SqlParserType;
 import io.seata.sqlparser.druid.DruidDelegatingSQLRecognizerFactory;
 import io.seata.sqlparser.druid.SQLOperateRecognizerHolder;
 import io.seata.sqlparser.druid.SQLOperateRecognizerHolderFactory;
 import io.seata.sqlparser.util.JdbcConstants;
+
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.MethodOrderer;
@@ -93,6 +96,11 @@ public class StatementProxyTest {
             .load(SQLRecognizerFactory.class, SqlParserType.SQL_PARSER_TYPE_DRUID);
     }
 
+    @AfterEach
+    public void clear() throws SQLException {
+        statementProxy.clearBatch();
+    }
+
     @Test
     public void testStatementProxy() {
         Assertions.assertNotNull(statementProxy);
@@ -116,6 +124,7 @@ public class StatementProxyTest {
         Assertions.assertDoesNotThrow(() -> statementProxy.execute(sql, new int[]{1}));
         Assertions.assertDoesNotThrow(() -> statementProxy.execute(sql, new String[]{"id"}));
         Assertions.assertDoesNotThrow(() -> statementProxy.executeBatch());
+        Assertions.assertDoesNotThrow(() -> statementProxy.clearBatch());
     }
 
     @Test
-- 
GitLab