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 cc0179c7186 Add more test cases on SystemSchemaManager (#36990)
cc0179c7186 is described below

commit cc0179c7186f4d7288f6992897e720de50c316f9
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Nov 2 23:39:29 2025 +0800

    Add more test cases on SystemSchemaManager (#36990)
---
 .../schema/manager/SystemSchemaManager.java        | 14 ++++----
 .../schema/manager/SystemSchemaManagerTest.java    | 38 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 7 deletions(-)

diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManager.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManager.java
index 9dcb830da82..c8ea76be5be 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManager.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManager.java
@@ -61,11 +61,11 @@ public final class SystemSchemaManager {
     }
     
     /**
-     * Judge whether current table is system table or not.
+     * Judge whether the current table is system table.
      *
      * @param schema schema
      * @param tableName table name
-     * @return whether current table is system table or not
+     * @return is system table or not
      */
     public static boolean isSystemTable(final String schema, final String 
tableName) {
         for (Entry<String, Map<String, Collection<String>>> entry : 
DATABASE_TYPE_SCHEMA_TABLE_MAP.entrySet()) {
@@ -77,12 +77,12 @@ public final class SystemSchemaManager {
     }
     
     /**
-     * Judge whether current table is system table or not.
+     * Judge whether the current table is system table.
      *
      * @param databaseType database type
      * @param schema schema
      * @param tableName table name
-     * @return whether current table is system table or not
+     * @return is system table or not
      */
     public static boolean isSystemTable(final String databaseType, final 
String schema, final String tableName) {
         Map<String, Collection<String>> schemaTableMap = 
DATABASE_TYPE_SCHEMA_TABLE_MAP.getOrDefault(databaseType, 
Collections.emptyMap());
@@ -94,12 +94,12 @@ public final class SystemSchemaManager {
     }
     
     /**
-     * Judge whether current table is system table or not.
+     * Judge whether the current table is system table.
      *
      * @param databaseType database type
      * @param schema schema
      * @param tableNames table names
-     * @return whether current table is system table or not
+     * @return is system table or not
      */
     public static boolean isSystemTable(final String databaseType, final 
String schema, final Collection<String> tableNames) {
         Collection<String> databaseTypeTables = 
Optional.ofNullable(DATABASE_TYPE_SCHEMA_TABLE_MAP.get(databaseType)).map(schemas
 -> schemas.get(schema)).orElse(Collections.emptyList());
@@ -131,7 +131,7 @@ public final class SystemSchemaManager {
      *
      * @param databaseType database type
      * @param schema schema
-     * @return inputStream collection
+     * @return input streams
      */
     public static Collection<InputStream> getAllInputStreams(final String 
databaseType, final String schema) {
         Collection<InputStream> result = new LinkedList<>();
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManagerTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManagerTest.java
index a88453a05a5..5566ff2779d 100644
--- 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManagerTest.java
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/SystemSchemaManagerTest.java
@@ -19,11 +19,15 @@ package 
org.apache.shardingsphere.infra.metadata.database.schema.manager;
 
 import org.junit.jupiter.api.Test;
 
+import java.io.InputStream;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 class SystemSchemaManagerTest {
@@ -83,4 +87,38 @@ class SystemSchemaManagerTest {
         assertTrue(SystemSchemaManager.isSystemTable("shardingsphere", 
"cluster_information"));
         assertFalse(SystemSchemaManager.isSystemTable("shardingsphere", 
"nonexistent"));
     }
+    
+    @Test
+    void assertIsSystemTableWithDatabaseTypeAndNullSchema() {
+        assertTrue(SystemSchemaManager.isSystemTable("MySQL", null, 
"columns"));
+        assertTrue(SystemSchemaManager.isSystemTable("PostgreSQL", null, 
"pg_database"));
+        assertFalse(SystemSchemaManager.isSystemTable("MySQL", null, 
"nonexistent_table"));
+    }
+    
+    @Test
+    void assertIsSystemTableWithDatabaseTypeAndSchema() {
+        assertTrue(SystemSchemaManager.isSystemTable("MySQL", 
"information_schema", "columns"));
+        assertTrue(SystemSchemaManager.isSystemTable("PostgreSQL", 
"pg_catalog", "pg_database"));
+        assertTrue(SystemSchemaManager.isSystemTable("MySQL", 
"shardingsphere", "cluster_information"));
+        assertFalse(SystemSchemaManager.isSystemTable("MySQL", 
"information_schema", "nonexistent_table"));
+        assertFalse(SystemSchemaManager.isSystemTable("NonExistentDB", 
"test_schema", "test_table"));
+    }
+    
+    @Test
+    void assertIsSystemTableWithTableNamesCollection() {
+        assertTrue(SystemSchemaManager.isSystemTable("MySQL", 
"information_schema", Arrays.asList("columns", "tables", "schemata")));
+        assertFalse(SystemSchemaManager.isSystemTable("MySQL", 
"information_schema", Arrays.asList("columns", "nonexistent_table")));
+        assertTrue(SystemSchemaManager.isSystemTable("PostgreSQL", 
"pg_catalog", Arrays.asList("pg_database", "pg_tables")));
+        assertFalse(SystemSchemaManager.isSystemTable("NonExistentDB", 
"test_schema", Collections.singleton("test_table")));
+        assertTrue(SystemSchemaManager.isSystemTable("MySQL", 
"nonexistent_schema", Collections.emptyList()));
+    }
+    
+    @Test
+    void assertGetAllInputStreams() {
+        java.util.Collection<java.io.InputStream> actual = 
SystemSchemaManager.getAllInputStreams("MySQL", "information_schema");
+        assertThat(actual.size(), is(95));
+        for (InputStream each : actual) {
+            assertNotNull(each);
+        }
+    }
 }

Reply via email to