You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/02/03 16:28:42 UTC

(shardingsphere) branch master updated: Add more test cases on FirebirdStatementIdGeneratorTest (#37949)

This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 163bdc76609 Add more test cases on FirebirdStatementIdGeneratorTest (#37949)
163bdc76609 is described below

commit 163bdc7660920329df857c144f114374c3512337
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Feb 3 23:52:49 2026 +0800

    Add more test cases on FirebirdStatementIdGeneratorTest (#37949)
---
 .../FirebirdStatementIdGeneratorTest.java          | 45 +++++++++++++++++-----
 1 file changed, 36 insertions(+), 9 deletions(-)

diff --git a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdStatementIdGeneratorTest.java b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdStatementIdGeneratorTest.java
index 21fe81d4340..ec30a103e14 100644
--- a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdStatementIdGeneratorTest.java
+++ b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/FirebirdStatementIdGeneratorTest.java
@@ -18,29 +18,56 @@
 package org.apache.shardingsphere.proxy.frontend.firebird.command.query.statement;
 
 import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.util.Collection;
+import java.util.HashSet;
+
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 class FirebirdStatementIdGeneratorTest {
     
-    private static final int CONNECTION_ID = 1;
+    private static final FirebirdStatementIdGenerator GENERATOR = FirebirdStatementIdGenerator.getInstance();
     
-    @BeforeEach
-    void setup() {
-        FirebirdStatementIdGenerator.getInstance().registerConnection(CONNECTION_ID);
-    }
+    private final Collection<Integer> registeredConnectionIds = new HashSet<>(4, 1F);
     
     @AfterEach
     void tearDown() {
-        FirebirdStatementIdGenerator.getInstance().unregisterConnection(CONNECTION_ID);
+        for (Integer each : registeredConnectionIds) {
+            GENERATOR.unregisterConnection(each);
+        }
+        registeredConnectionIds.clear();
+    }
+    
+    @Test
+    void assertRegisterConnection() {
+        GENERATOR.registerConnection(1);
+        registeredConnectionIds.add(1);
+        assertThat(GENERATOR.getStatementId(1), is(0));
     }
     
     @Test
     void assertNextStatementId() {
-        assertThat(FirebirdStatementIdGenerator.getInstance().nextStatementId(CONNECTION_ID), is(1));
-        assertThat(FirebirdStatementIdGenerator.getInstance().nextStatementId(CONNECTION_ID), is(2));
+        GENERATOR.registerConnection(1);
+        registeredConnectionIds.add(1);
+        assertThat(GENERATOR.nextStatementId(1), is(1));
+    }
+    
+    @Test
+    void assertGetStatementId() {
+        GENERATOR.registerConnection(1);
+        registeredConnectionIds.add(1);
+        assertThat(GENERATOR.getStatementId(1), is(0));
+    }
+    
+    @Test
+    void assertUnregisterConnection() {
+        GENERATOR.registerConnection(1);
+        registeredConnectionIds.add(1);
+        GENERATOR.unregisterConnection(1);
+        registeredConnectionIds.remove(1);
+        assertThrows(NullPointerException.class, () -> GENERATOR.getStatementId(1));
     }
 }