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

sunnianjun 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 b830587fb90 Add authority rule on test cases (#31380)
b830587fb90 is described below

commit b830587fb9054e37c1b0e50b2c698a81cdbc6e84
Author: Liang Zhang <[email protected]>
AuthorDate: Sat May 25 10:52:38 2024 +0800

    Add authority rule on test cases (#31380)
    
    * Update IDEA code-style file
    
    * Add authority rule on test cases
---
 .../executor/batch/BatchPreparedStatementExecutorTest.java       | 3 ++-
 .../driver/jdbc/adapter/ConnectionAdapterTest.java               | 3 ++-
 .../jdbc/core/connection/ShardingSphereConnectionTest.java       | 4 +++-
 .../shardingsphere/driver/state/DriverStateContextTest.java      | 4 +++-
 .../apache/shardingsphere/driver/state/ok/OKDriverStateTest.java | 3 ++-
 .../proxy/frontend/netty/FrontendChannelInboundHandlerTest.java  | 9 +++++----
 6 files changed, 17 insertions(+), 9 deletions(-)

diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
index 899e8b8a090..a02c891ee8f 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/executor/batch/BatchPreparedStatementExecutorTest.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.driver.executor.batch;
 
 import lombok.SneakyThrows;
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
 import 
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
 import 
org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
@@ -105,7 +106,7 @@ class BatchPreparedStatementExecutorTest {
     
     private MetaDataContexts mockMetaDataContexts() {
         MetaDataContexts result = mock(MetaDataContexts.class, 
RETURNS_DEEP_STUBS);
-        RuleMetaData globalRuleMetaData = new 
RuleMetaData(Arrays.asList(mockTransactionRule(), new TrafficRule(new 
DefaultTrafficRuleConfigurationBuilder().build())));
+        RuleMetaData globalRuleMetaData = new 
RuleMetaData(Arrays.asList(mockTransactionRule(), new TrafficRule(new 
DefaultTrafficRuleConfigurationBuilder().build()), mock(AuthorityRule.class)));
         
when(result.getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
         RuleMetaData databaseRuleMetaData = new 
RuleMetaData(Collections.singleton(mockShardingRule()));
         
when(result.getMetaData().getDatabase("foo_db").getRuleMetaData()).thenReturn(databaseRuleMetaData);
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
index 69c972de9b3..493d234c952 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.driver.jdbc.adapter;
 
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
 import 
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
 import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
@@ -99,7 +100,7 @@ class ConnectionAdapterTest {
     private Connection createConnectionAdaptor() {
         ContextManager contextManager = mock(ContextManager.class, 
RETURNS_DEEP_STUBS);
         
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(
-                new RuleMetaData(Arrays.asList(mock(TransactionRule.class, 
RETURNS_DEEP_STUBS), new TrafficRule(new 
DefaultTrafficRuleConfigurationBuilder().build()))));
+                new RuleMetaData(Arrays.asList(mock(TransactionRule.class, 
RETURNS_DEEP_STUBS), new TrafficRule(new 
DefaultTrafficRuleConfigurationBuilder().build()), mock(AuthorityRule.class))));
         return new ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, 
contextManager);
     }
 }
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
index 37401cb6588..69eabb34c99 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.driver.jdbc.core.connection;
 
 import lombok.SneakyThrows;
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
 import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
 import 
org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.unit.StorageUnit;
@@ -250,7 +251,8 @@ class ShardingSphereConnectionTest {
         StorageUnit storageUnit = mock(StorageUnit.class);
         when(storageUnit.getDataSource()).thenReturn(dataSource);
         
when(result.getStorageUnits(DefaultDatabase.LOGIC_NAME)).thenReturn(Collections.singletonMap("ds",
 storageUnit));
-        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new
 RuleMetaData(Arrays.asList(mockTransactionRule(), mock(TrafficRule.class))));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(
+                new RuleMetaData(Arrays.asList(mockTransactionRule(), 
mock(TrafficRule.class), mock(AuthorityRule.class))));
         return result;
     }
     
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
index 7b00dd9a8a4..e164b600a18 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/DriverStateContextTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.driver.state;
 
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
 import 
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
@@ -63,7 +64,8 @@ class DriverStateContextTest {
         Map<String, ShardingSphereDatabase> databases = mockDatabases();
         TransactionRule transactionRule = mock(TransactionRule.class);
         TrafficRule trafficRule = mock(TrafficRule.class);
-        RuleMetaData globalRuleMetaData = new 
RuleMetaData(Arrays.asList(transactionRule, trafficRule));
+        AuthorityRule authorityRule = mock(AuthorityRule.class);
+        RuleMetaData globalRuleMetaData = new 
RuleMetaData(Arrays.asList(transactionRule, trafficRule, authorityRule));
         MetaDataContexts metaDataContexts = MetaDataContextsFactory.create(
                 mock(MetaDataPersistService.class), new 
ShardingSphereMetaData(databases, mock(ResourceMetaData.class), 
globalRuleMetaData, new ConfigurationProperties(new Properties())));
         
when(contextManager.getMetaDataContexts()).thenReturn(metaDataContexts);
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
index 3092f340416..0641a889478 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/state/ok/OKDriverStateTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.driver.state.ok;
 
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
 import 
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
 import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
@@ -40,7 +41,7 @@ class OKDriverStateTest {
     void assertGetConnection() {
         ContextManager contextManager = mock(ContextManager.class, 
RETURNS_DEEP_STUBS);
         
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(
-                new RuleMetaData(Arrays.asList(mock(TransactionRule.class, 
RETURNS_DEEP_STUBS), mock(TrafficRule.class))));
+                new RuleMetaData(Arrays.asList(mock(TransactionRule.class, 
RETURNS_DEEP_STUBS), mock(TrafficRule.class), mock(AuthorityRule.class))));
         Connection actual = new 
OKDriverState().getConnection(DefaultDatabase.LOGIC_NAME, contextManager);
         assertThat(actual, instanceOf(ShardingSphereConnection.class));
     }
diff --git 
a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandlerTest.java
 
b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandlerTest.java
index 5542d9c79b3..d7e0c694fbf 100644
--- 
a/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandlerTest.java
+++ 
b/proxy/frontend/core/src/test/java/org/apache/shardingsphere/proxy/frontend/netty/FrontendChannelInboundHandlerTest.java
@@ -21,6 +21,9 @@ import io.netty.buffer.Unpooled;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.embedded.EmbeddedChannel;
 import lombok.SneakyThrows;
+import org.apache.shardingsphere.authentication.result.AuthenticationResult;
+import 
org.apache.shardingsphere.authentication.result.AuthenticationResultBuilder;
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
 import org.apache.shardingsphere.db.protocol.payload.PacketPayload;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
@@ -31,8 +34,6 @@ import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.frontend.authentication.AuthenticationEngine;
-import org.apache.shardingsphere.authentication.result.AuthenticationResult;
-import 
org.apache.shardingsphere.authentication.result.AuthenticationResultBuilder;
 import 
org.apache.shardingsphere.proxy.frontend.spi.DatabaseProtocolFrontendEngine;
 import org.apache.shardingsphere.test.mock.AutoMockExtension;
 import org.apache.shardingsphere.test.mock.StaticMockSettings;
@@ -44,7 +45,7 @@ import org.mockito.Answers;
 import org.mockito.Mock;
 import org.mockito.internal.configuration.plugins.Plugins;
 
-import java.util.Collections;
+import java.util.Arrays;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -80,7 +81,7 @@ class FrontendChannelInboundHandlerTest {
         
when(authenticationEngine.handshake(any(ChannelHandlerContext.class))).thenReturn(CONNECTION_ID);
         channel = new EmbeddedChannel(false, true);
         ContextManager contextManager = mock(ContextManager.class, 
RETURNS_DEEP_STUBS);
-        
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new
 RuleMetaData(Collections.singleton(mock(TransactionRule.class))));
+        
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new
 RuleMetaData(Arrays.asList(mock(TransactionRule.class), 
mock(AuthorityRule.class))));
         
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
         frontendChannelInboundHandler = new 
FrontendChannelInboundHandler(frontendEngine, channel);
         channel.pipeline().addLast(frontendChannelInboundHandler);

Reply via email to