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/09/30 01:00:22 UTC

(shardingsphere) branch master updated: Align SQLFederationProviderFactoryTest with provider fallback (#40009)

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

terrymanu 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 45caa6250dd Align SQLFederationProviderFactoryTest with provider fallback (#40009)
45caa6250dd is described below

commit 45caa6250dd5af14c14c0ed585d7ffd5526cee6a
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Wed Sep 30 09:00:14 2026 +0800

    Align SQLFederationProviderFactoryTest with provider fallback (#40009)
---
 .../rule/SQLFederationProviderFactoryTest.java              | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationProviderFactoryTest.java b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationProviderFactoryTest.java
index 7fd30bfd130..af9991673df 100644
--- a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationProviderFactoryTest.java
+++ b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/rule/SQLFederationProviderFactoryTest.java
@@ -41,14 +41,13 @@ import static org.mockito.Mockito.when;
 class SQLFederationProviderFactoryTest {
     
     @Test
-    void assertExplicitProviderMissing() {
-        SQLFederationProvider defaultProvider = mock(SQLFederationProvider.class);
-        when(defaultProvider.getType()).thenReturn("CALCITE");
-        when(defaultProvider.isDefault()).thenReturn(true);
+    void assertMissingProviderFallsBackToDefault() {
+        SQLFederationProvider expected = mock(SQLFederationProvider.class);
+        when(expected.getType()).thenReturn("CALCITE");
+        when(expected.isDefault()).thenReturn(true);
         try (MockedStatic<ShardingSphereServiceLoader> serviceLoader = mockStatic(ShardingSphereServiceLoader.class)) {
-            serviceLoader.when(() -> ShardingSphereServiceLoader.getServiceInstances(SQLFederationProvider.class)).thenReturn(Collections.singleton(defaultProvider));
-            ServiceProviderNotFoundException actual = assertThrows(ServiceProviderNotFoundException.class, () -> SQLFederationProviderFactory.getProvider("UNKNOWN"));
-            assertThat(actual.getMessage(), is("SPI-00001: No implementation class load from SPI 'org.apache.shardingsphere.sqlfederation.spi.SQLFederationProvider' with type 'UNKNOWN'."));
+            serviceLoader.when(() -> ShardingSphereServiceLoader.getServiceInstances(SQLFederationProvider.class)).thenReturn(Collections.singleton(expected));
+            assertThat(SQLFederationProviderFactory.getProvider("UNKNOWN"), sameInstance(expected));
         }
     }