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 33165b0069d Add more test cases on FirebirdBlobColumnLoaderTest 
(#38117)
33165b0069d is described below

commit 33165b0069d6d49248bbc2d0aaf4c6259a095f49
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Feb 21 19:20:37 2026 +0800

    Add more test cases on FirebirdBlobColumnLoaderTest (#38117)
---
 .../data/loader/FirebirdBlobColumnLoaderTest.java  | 75 +++++++++++++---------
 1 file changed, 45 insertions(+), 30 deletions(-)

diff --git 
a/database/connector/dialect/firebird/src/test/java/org/apache/shardingsphere/database/connector/firebird/metadata/data/loader/FirebirdBlobColumnLoaderTest.java
 
b/database/connector/dialect/firebird/src/test/java/org/apache/shardingsphere/database/connector/firebird/metadata/data/loader/FirebirdBlobColumnLoaderTest.java
index c408791e5b4..6db5cdab100 100644
--- 
a/database/connector/dialect/firebird/src/test/java/org/apache/shardingsphere/database/connector/firebird/metadata/data/loader/FirebirdBlobColumnLoaderTest.java
+++ 
b/database/connector/dialect/firebird/src/test/java/org/apache/shardingsphere/database/connector/firebird/metadata/data/loader/FirebirdBlobColumnLoaderTest.java
@@ -20,9 +20,11 @@ package 
org.apache.shardingsphere.database.connector.firebird.metadata.data.load
 import 
org.apache.shardingsphere.database.connector.core.metadata.data.loader.MetaDataLoaderMaterial;
 import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 
@@ -31,13 +33,13 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
+import java.util.stream.Stream;
 
-import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.hasKey;
+import static org.hamcrest.Matchers.is;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.verify;
@@ -46,49 +48,62 @@ import static org.mockito.Mockito.when;
 @ExtendWith(MockitoExtension.class)
 class FirebirdBlobColumnLoaderTest {
     
-    private static final Collection<String> TABLES = 
Collections.singleton("test_table");
+    private final DatabaseType databaseType = 
TypedSPILoader.getService(DatabaseType.class, "Firebird");
     
     @Mock
-    private DataSource dataSource;
-    
-    @Mock
-    private Connection connection;
+    private ResultSet resultSet;
     
     @Mock
     private PreparedStatement preparedStatement;
     
     @Mock
-    private ResultSet resultSet;
+    private Connection connection;
     
-    private MetaDataLoaderMaterial material;
+    @Mock
+    private DataSource dataSource;
     
-    @BeforeEach
-    void setUp() {
-        DatabaseType databaseType = 
TypedSPILoader.getService(DatabaseType.class, "Firebird");
-        material = new MetaDataLoaderMaterial(TABLES, "logic_ds", dataSource, 
databaseType, "schema");
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("loadWithBlobColumnArguments")
+    void assertLoadWithBlobColumn(final String name, final String columnName, 
final Object subType, final Integer expectedSubType) throws SQLException {
+        when(resultSet.next()).thenReturn(true, false);
+        when(resultSet.getString("COLUMN_NAME")).thenReturn(columnName);
+        when(resultSet.getObject("SUB_TYPE")).thenReturn(subType);
+        when(preparedStatement.executeQuery()).thenReturn(resultSet);
+        
when(connection.prepareStatement(anyString())).thenReturn(preparedStatement);
+        when(dataSource.getConnection()).thenReturn(connection);
+        MetaDataLoaderMaterial material = new 
MetaDataLoaderMaterial(Collections.singleton("foo_tbl"), "foo_ds", dataSource, 
databaseType, "schema");
+        Map<String, Map<String, Integer>> actual = new 
FirebirdBlobColumnLoader(material).load();
+        assertThat(actual, hasKey("foo_tbl"));
+        Map<String, Integer> actualTableColumns = actual.get("foo_tbl");
+        assertThat(actualTableColumns.size(), is(1));
+        assertThat(actualTableColumns.get("BLOB_COL"), is(expectedSubType));
+        verify(preparedStatement).setString(1, "FOO_TBL");
     }
     
     @Test
-    void assertLoadReturnsBlobColumns() throws SQLException {
-        when(dataSource.getConnection()).thenReturn(connection);
-        
when(connection.prepareStatement(anyString())).thenReturn(preparedStatement);
-        when(preparedStatement.executeQuery()).thenReturn(resultSet);
+    void assertLoadWithInvalidColumnNames() throws SQLException {
         when(resultSet.next()).thenReturn(true, true, false);
-        when(resultSet.getString("COLUMN_NAME")).thenReturn(" blob_col ", "  
");
-        
when(resultSet.getObject("SUB_TYPE")).thenReturn(2).thenReturn((Object) null);
+        when(resultSet.getString("COLUMN_NAME")).thenReturn(null, "   ");
+        when(preparedStatement.executeQuery()).thenReturn(resultSet);
+        
when(connection.prepareStatement(anyString())).thenReturn(preparedStatement);
+        when(dataSource.getConnection()).thenReturn(connection);
+        MetaDataLoaderMaterial material = new 
MetaDataLoaderMaterial(Collections.singleton("foo_tbl"), "foo_ds", dataSource, 
databaseType, "schema");
         Map<String, Map<String, Integer>> actual = new 
FirebirdBlobColumnLoader(material).load();
-        assertThat(actual, hasKey("test_table"));
-        Map<String, Integer> actualTableColumns = actual.get("test_table");
-        assertThat(actualTableColumns.size(), is(1));
-        assertThat(actualTableColumns.get("BLOB_COL"), is(2));
-        verify(preparedStatement).setString(1, "TEST_TABLE");
+        assertThat(actual, hasKey("foo_tbl"));
+        assertTrue(actual.get("foo_tbl").isEmpty());
+        verify(preparedStatement).setString(1, "FOO_TBL");
     }
     
     @Test
-    void assertLoadReturnsEmptyWhenNoTables() throws SQLException {
-        material = new MetaDataLoaderMaterial(Collections.emptyList(), 
"logic_ds", dataSource,
-                TypedSPILoader.getService(DatabaseType.class, "Firebird"), 
"schema");
-        Map<String, Map<String, Integer>> actual = new 
FirebirdBlobColumnLoader(material).load();
-        assertTrue(actual.isEmpty());
+    void assertLoadWithNoTables() throws SQLException {
+        MetaDataLoaderMaterial material = new 
MetaDataLoaderMaterial(Collections.emptyList(), "foo_ds", dataSource, 
databaseType, "schema");
+        assertTrue(new FirebirdBlobColumnLoader(material).load().isEmpty());
+    }
+    
+    private static Stream<Arguments> loadWithBlobColumnArguments() {
+        return Stream.of(
+                Arguments.of("trimmed column with integer subtype", " blob_col 
", 2, 2),
+                Arguments.of("upper case column with null subtype", 
"BLOB_COL", null, null),
+                Arguments.of("lower case column with negative subtype", 
"blob_col", -1, -1));
     }
 }

Reply via email to