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 0454ab04b85 Refactor DistSQLExecutor's test cases (#30216)
0454ab04b85 is described below

commit 0454ab04b85883f2c6153cd97644dbea91a2239f
Author: zhengke zhou <[email protected]>
AuthorDate: Thu Feb 22 16:41:48 2024 +0800

    Refactor DistSQLExecutor's test cases (#30216)
    
    * Refactor DistSQLExecutor's test cases replace with 
DistSQLQueryExecuteEngine
    
    * import lost package
---
 .../query/ShowBroadcastTableRuleExecutorTest.java  | 27 ++++++++--
 .../handler/query/ShowEncryptRuleExecutorTest.java | 28 ++++++++--
 .../handler/query/ShowMaskRuleExecutorTest.java    | 28 ++++++++--
 .../ShowReadwriteSplittingRuleExecutorTest.java    | 51 +++++++++++-------
 ...tusFromReadwriteSplittingRulesExecutorTest.java |  1 +
 .../ShowDefaultShadowAlgorithmExecutorTest.java    | 29 +++++++---
 .../query/ShowShadowAlgorithmsExecutorTest.java    | 29 +++++++---
 .../distsql/query/ShowShadowRuleExecutorTest.java  | 29 +++++++---
 .../query/ShowShadowTableRulesExecutorTest.java    | 29 +++++++---
 .../ShowDefaultShardingStrategyExecutorTest.java   | 62 ++++++++++++++--------
 .../query/ShowShardingAlgorithmExecutorTest.java   | 29 +++++++---
 .../query/ShowShardingAuditorsExecutorTest.java    | 29 +++++++---
 .../ShowShardingKeyGeneratorExecutorTest.java      | 29 +++++++---
 .../query/ShowShardingTableNodesExecutorTest.java  | 45 +++++++++++-----
 ...ShowShardingTableReferenceRuleExecutorTest.java | 38 ++++++++-----
 .../query/ShowShardingTableRuleExecutorTest.java   | 29 +++++++---
 ...hardingTableRulesUsedAlgorithmExecutorTest.java | 43 ++++++++++-----
 ...wShardingTableRulesUsedAuditorExecutorTest.java | 30 ++++++++---
 ...dingTableRulesUsedKeyGeneratorExecutorTest.java | 30 ++++++++---
 .../ShowUnusedShardingAlgorithmsExecutorTest.java  | 29 +++++++---
 .../ShowUnusedShardingAuditorsExecutorTest.java    | 29 +++++++---
 ...ShowUnusedShardingKeyGeneratorExecutorTest.java | 29 +++++++---
 .../query/ShowGlobalClockRuleExecutorTest.java     | 28 ++++++++--
 ...wDefaultSingleTableStorageUnitExecutorTest.java | 28 ++++++++--
 .../handler/query/ShowSingleTableExecutorTest.java | 35 ++++++++----
 .../query/ShowSQLFederationRuleExecutorTest.java   | 28 ++++++++--
 .../query/ShowSQLParserRuleExecutorTest.java       | 28 ++++++++--
 .../query/ShowSQLTranslatorRuleExecutorTest.java   | 36 +++++++++----
 .../handler/query/ShowTrafficRuleExecutorTest.java | 50 +++++++++++------
 .../query/ShowTransactionRuleExecutorTest.java     | 39 ++++++++++----
 30 files changed, 735 insertions(+), 239 deletions(-)

diff --git 
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutorTest.java
 
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutorTest.java
index a6120295ca0..9405fc633c6 100644
--- 
a/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutorTest.java
+++ 
b/features/broadcast/distsql/handler/src/test/java/org/apache/shardingsphere/broadcast/distsql/handler/query/ShowBroadcastTableRuleExecutorTest.java
@@ -20,26 +20,45 @@ package 
org.apache.shardingsphere.broadcast.distsql.handler.query;
 import 
org.apache.shardingsphere.broadcast.api.config.BroadcastRuleConfiguration;
 import 
org.apache.shardingsphere.broadcast.distsql.statement.ShowBroadcastTableRulesStatement;
 import org.apache.shardingsphere.broadcast.rule.BroadcastRule;
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowBroadcastTableRuleExecutorTest {
     
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowBroadcastTableRulesStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        BroadcastRule rule = mockBroadcastRule();
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(BroadcastRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
     @Test
-    void assertGetRowData() {
-        ShowBroadcastTableRuleExecutor executor = new 
ShowBroadcastTableRuleExecutor();
-        executor.setRule(mockBroadcastRule());
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowBroadcastTableRulesStatement.class), 
mock(ContextManager.class));
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
index 40c2fbd4495..3127d62cd54 100644
--- 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
+++ 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.encrypt.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
 import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnItemRuleConfiguration;
 import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
@@ -26,27 +28,43 @@ import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowEncryptRuleExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowEncryptRuleExecutor executor = new ShowEncryptRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowEncryptRulesStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         EncryptRule rule = mock(EncryptRule.class);
         when(rule.getConfiguration()).thenReturn(getRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowEncryptRulesStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(EncryptRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
 
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
index 19b523e2787..b1e043fdfc1 100644
--- 
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
+++ 
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.mask.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
@@ -25,27 +27,43 @@ import 
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration
 import org.apache.shardingsphere.mask.distsql.statement.ShowMaskRulesStatement;
 import org.apache.shardingsphere.mask.rule.MaskRule;
 import org.apache.shardingsphere.mode.manager.ContextManager;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowMaskRuleExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowMaskRuleExecutor executor = new ShowMaskRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowMaskRulesStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         MaskRule rule = mock(MaskRule.class);
         when(rule.getConfiguration()).thenReturn(getRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowMaskRulesStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(MaskRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
index 151ae971231..c00fc9401ca 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.readwritesplitting.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableConstants;
@@ -29,28 +31,43 @@ import 
org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowReadwriteSplittingRuleExecutorTest {
     
-    @Test
-    void assertGetRowData() {
+    private DistSQLQueryExecuteEngine engine;
+    
+    private DistSQLQueryExecuteEngine setUp(final 
ShowReadwriteSplittingRulesStatement statement, final 
ReadwriteSplittingRuleConfiguration configuration) {
+        return new DistSQLQueryExecuteEngine(statement, null, 
mockContextManager(configuration), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager(final 
ReadwriteSplittingRuleConfiguration configuration) {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ReadwriteSplittingRule rule = mock(ReadwriteSplittingRule.class);
-        when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
+        when(rule.getConfiguration()).thenReturn(configuration);
         when(rule.getExportData()).thenReturn(createExportedData());
-        ShowReadwriteSplittingRuleExecutor executor = new 
ShowReadwriteSplittingRuleExecutor();
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowReadwriteSplittingRulesStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ReadwriteSplittingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine = setUp(mock(ShowReadwriteSplittingRulesStatement.class), 
createRuleConfiguration());
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -63,13 +80,10 @@ class ShowReadwriteSplittingRuleExecutorTest {
     }
     
     @Test
-    void assertGetRowDataWithSpecifiedRuleName() {
-        ReadwriteSplittingRule rule = mock(ReadwriteSplittingRule.class);
-        when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        when(rule.getExportData()).thenReturn(createExportedData());
-        ShowReadwriteSplittingRuleExecutor executor = new 
ShowReadwriteSplittingRuleExecutor();
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = executor.getRows(new 
ShowReadwriteSplittingRulesStatement("readwrite_ds", null), 
mock(ContextManager.class));
+    void assertGetRowDataWithSpecifiedRuleName() throws SQLException {
+        engine = setUp(new 
ShowReadwriteSplittingRulesStatement("readwrite_ds", null), 
createRuleConfiguration());
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -96,13 +110,10 @@ class ShowReadwriteSplittingRuleExecutorTest {
     }
     
     @Test
-    void assertGetRowDataWithoutLoadBalancer() {
-        ReadwriteSplittingRule rule = mock(ReadwriteSplittingRule.class);
-        
when(rule.getConfiguration()).thenReturn(createRuleConfigurationWithoutLoadBalancer());
-        when(rule.getExportData()).thenReturn(createExportedData());
-        ShowReadwriteSplittingRuleExecutor executor = new 
ShowReadwriteSplittingRuleExecutor();
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowReadwriteSplittingRulesStatement.class), 
mock(ContextManager.class));
+    void assertGetRowDataWithoutLoadBalancer() throws SQLException {
+        engine = setUp(mock(ShowReadwriteSplittingRulesStatement.class), 
createRuleConfigurationWithoutLoadBalancer());
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowStatusFromReadwriteSplittingRulesExecutorTest.java
 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowStatusFromReadwriteSplittingRulesExecutorTest.java
index 88f73be8410..9cca049bcdf 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowStatusFromReadwriteSplittingRulesExecutorTest.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowStatusFromReadwriteSplittingRulesExecutorTest.java
@@ -38,6 +38,7 @@ import static org.mockito.Mockito.when;
 
 class ShowStatusFromReadwriteSplittingRulesExecutorTest {
     
+    // TODO Replace With DistSQLQueryExecuteEngine
     @Test
     void assertGetRowData() {
         ShowStatusFromReadwriteSplittingRulesExecutor executor = new 
ShowStatusFromReadwriteSplittingRulesExecutor();
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java
index 7197b5e7c91..ddb0cc1c539 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java
@@ -17,36 +17,53 @@
 
 package org.apache.shardingsphere.shadow.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
-import 
org.apache.shardingsphere.shadow.distsql.handler.query.ShowDefaultShadowAlgorithmExecutor;
 import 
org.apache.shardingsphere.shadow.distsql.statement.ShowDefaultShadowAlgorithmStatement;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowDefaultShadowAlgorithmExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowDefaultShadowAlgorithmExecutor executor = new 
ShowDefaultShadowAlgorithmExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowDefaultShadowAlgorithmStatement.class), 
null, mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShadowRule rule = mock(ShadowRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowDefaultShadowAlgorithmStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShadowRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java
index 2696298b2b9..2c67c5c64b4 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java
@@ -17,36 +17,53 @@
 
 package org.apache.shardingsphere.shadow.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
-import 
org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowAlgorithmsExecutor;
 import 
org.apache.shardingsphere.shadow.distsql.statement.ShowShadowAlgorithmsStatement;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShadowAlgorithmsExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowShadowAlgorithmsExecutor executor = new 
ShowShadowAlgorithmsExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowShadowAlgorithmsStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShadowRule rule = mock(ShadowRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowShadowAlgorithmsStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShadowRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
index 9b69e8f1d48..ba49f454389 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
@@ -17,36 +17,53 @@
 
 package org.apache.shardingsphere.shadow.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
-import 
org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowRuleExecutor;
 import 
org.apache.shardingsphere.shadow.distsql.statement.ShowShadowRulesStatement;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShadowRuleExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowShadowRuleExecutor executor = new ShowShadowRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowShadowRulesStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShadowRule rule = mock(ShadowRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowShadowRulesStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShadowRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(2));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowTableRulesExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowTableRulesExecutorTest.java
index cb452ef6ae5..81a2b87fec9 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowTableRulesExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowTableRulesExecutorTest.java
@@ -17,37 +17,54 @@
 
 package org.apache.shardingsphere.shadow.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
-import 
org.apache.shardingsphere.shadow.distsql.handler.query.ShowShadowTableRulesExecutor;
 import 
org.apache.shardingsphere.shadow.distsql.statement.ShowShadowTableRulesStatement;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShadowTableRulesExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowShadowTableRulesExecutor executor = new 
ShowShadowTableRulesExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowShadowTableRulesStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShadowRule rule = mock(ShadowRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowShadowTableRulesStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShadowRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowDefaultShardingStrategyExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowDefaultShardingStrategyExecutorTest.java
index 92db8867bea..b6d584a308a 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowDefaultShardingStrategyExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowDefaultShardingStrategyExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -25,30 +27,44 @@ import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexSh
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowDefaultShardingStrategyExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowDefaultShardingStrategyStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowDefaultShardingStrategyExecutorTest {
     
+    private DistSQLQueryExecuteEngine engine;
+    
+    DistSQLQueryExecuteEngine setUp(final ShardingRuleConfiguration 
configuration) {
+        return new 
DistSQLQueryExecuteEngine(mock(ShowDefaultShardingStrategyStatement.class), 
null, mockContextManager(configuration), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager(final ShardingRuleConfiguration 
configuration) {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        ShardingRule rule = mock(ShardingRule.class);
+        when(rule.getConfiguration()).thenReturn(configuration);
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
     @Test
-    void assertGetRowData() {
-        ShardingRule rule1 = mock(ShardingRule.class);
-        when(rule1.getConfiguration()).thenReturn(createRuleConfiguration1());
-        ShowDefaultShardingStrategyExecutor executor = new 
ShowDefaultShardingStrategyExecutor();
-        executor.setRule(rule1);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowDefaultShardingStrategyStatement.class), 
mock(ContextManager.class));
+    void assertGetRowData1() throws SQLException {
+        engine = setUp(createRuleConfiguration1());
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(2));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -65,14 +81,24 @@ class ShowDefaultShardingStrategyExecutorTest {
         assertThat(row.getCell(4), is("database_inline"));
         assertThat(row.getCell(5), is("INLINE"));
         assertThat(row.getCell(6), 
is("{\"algorithm-expression\":\"ds_${user_id % 2}\"}"));
-        ShardingRule rule2 = mock(ShardingRule.class);
-        when(rule2.getConfiguration()).thenReturn(createRuleConfiguration2());
-        executor = new ShowDefaultShardingStrategyExecutor();
-        executor.setRule(rule2);
-        actual = 
executor.getRows(mock(ShowDefaultShardingStrategyStatement.class), 
mock(ContextManager.class));
+    }
+    
+    private ShardingRuleConfiguration createRuleConfiguration1() {
+        ShardingRuleConfiguration result = new ShardingRuleConfiguration();
+        result.getShardingAlgorithms().put("database_inline", new 
AlgorithmConfiguration("INLINE", PropertiesBuilder.build(new 
Property("algorithm-expression", "ds_${user_id % 2}"))));
+        result.setDefaultTableShardingStrategy(new 
NoneShardingStrategyConfiguration());
+        result.setDefaultDatabaseShardingStrategy(new 
ComplexShardingStrategyConfiguration("use_id, order_id", "database_inline"));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData2() throws SQLException {
+        engine = setUp(createRuleConfiguration2());
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(2));
-        iterator = actual.iterator();
-        row = iterator.next();
+        Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
+        LocalDataQueryResultRow row = iterator.next();
         assertThat(row.getCell(1), is("TABLE"));
         assertThat(row.getCell(2), is("STANDARD"));
         assertThat(row.getCell(3), is("use_id"));
@@ -88,14 +114,6 @@ class ShowDefaultShardingStrategyExecutorTest {
         assertThat(row.getCell(6), 
is("{\"algorithm-expression\":\"ds_${user_id % 2}\"}"));
     }
     
-    private ShardingRuleConfiguration createRuleConfiguration1() {
-        ShardingRuleConfiguration result = new ShardingRuleConfiguration();
-        result.getShardingAlgorithms().put("database_inline", new 
AlgorithmConfiguration("INLINE", PropertiesBuilder.build(new 
Property("algorithm-expression", "ds_${user_id % 2}"))));
-        result.setDefaultTableShardingStrategy(new 
NoneShardingStrategyConfiguration());
-        result.setDefaultDatabaseShardingStrategy(new 
ComplexShardingStrategyConfiguration("use_id, order_id", "database_inline"));
-        return result;
-    }
-    
     private ShardingRuleConfiguration createRuleConfiguration2() {
         ShardingRuleConfiguration result = new ShardingRuleConfiguration();
         result.getShardingAlgorithms().put("database_inline", new 
AlgorithmConfiguration("INLINE", PropertiesBuilder.build(new 
Property("algorithm-expression", "ds_${user_id % 2}"))));
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java
index 3aa9e37cb23..24d5ca7316e 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java
@@ -17,34 +17,51 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAlgorithmExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingAlgorithmsStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShardingAlgorithmExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowShardingAlgorithmExecutor executor = new 
ShowShardingAlgorithmExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowShardingAlgorithmsStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowShardingAlgorithmsStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAuditorsExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAuditorsExecutorTest.java
index ff22cdaf3c3..6c2251055e7 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAuditorsExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAuditorsExecutorTest.java
@@ -17,34 +17,51 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAuditorsExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingAuditorsStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShardingAuditorsExecutorTest {
     
-    @Test
-    void assertGetRowData() {
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowShardingAuditorsStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        ShowShardingAuditorsExecutor executor = new 
ShowShardingAuditorsExecutor();
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowShardingAuditorsStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingKeyGeneratorExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingKeyGeneratorExecutorTest.java
index 34c9530e9fb..0f6539e0f98 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingKeyGeneratorExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingKeyGeneratorExecutorTest.java
@@ -17,34 +17,51 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingKeyGeneratorExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingKeyGeneratorsStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShardingKeyGeneratorExecutorTest {
     
-    @Test
-    void assertGetRowData() {
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowShardingKeyGeneratorsStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        ShowShardingKeyGeneratorExecutor executor = new 
ShowShardingKeyGeneratorExecutor();
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowShardingKeyGeneratorsStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableNodesExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableNodesExecutorTest.java
index da4c0158751..45c5bc9c2c7 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableNodesExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableNodesExecutorTest.java
@@ -19,13 +19,14 @@ package org.apache.shardingsphere.sharding.distsql.query;
 
 import lombok.SneakyThrows;
 import org.apache.groovy.util.Maps;
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import org.apache.shardingsphere.infra.instance.InstanceContext;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
 import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingTableNodesExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingTableNodesStatement;
 import 
org.apache.shardingsphere.sharding.exception.metadata.ShardingRuleNotFoundException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -36,18 +37,34 @@ import org.junit.jupiter.api.Test;
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 class ShowShardingTableNodesExecutorTest {
     
+    private DistSQLQueryExecuteEngine engine;
+    
+    DistSQLQueryExecuteEngine setUp(final ShardingRule rule, final 
ShowShardingTableNodesStatement statement) {
+        return new DistSQLQueryExecuteEngine(statement, null, 
mockContextManager(rule), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager(final ShardingRule rule) {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
     @Test
-    void assertGetRowData() {
+    void assertGetRowData() throws SQLException {
         ShardingRule rule = createShardingRule();
         assertOrder(rule);
         assertOrderItem(rule);
@@ -64,10 +81,10 @@ class ShowShardingTableNodesExecutorTest {
         return new ShardingRule(shardingRuleConfig, Maps.of("ds_1", new 
MockedDataSource(), "ds_2", new MockedDataSource(), "ds_3", new 
MockedDataSource()), mock(InstanceContext.class));
     }
     
-    private void assertOrder(final ShardingRule rule) {
-        ShowShardingTableNodesExecutor executor = new 
ShowShardingTableNodesExecutor();
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = executor.getRows(new 
ShowShardingTableNodesStatement("t_order", null), mock(ContextManager.class));
+    private void assertOrder(final ShardingRule rule) throws SQLException {
+        engine = setUp(rule, new ShowShardingTableNodesStatement("t_order", 
null));
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -75,10 +92,10 @@ class ShowShardingTableNodesExecutorTest {
         assertThat(row.getCell(2), is("ds_1.t_order_0, ds_2.t_order_1, 
ds_1.t_order_2, ds_2.t_order_3, ds_1.t_order_4, ds_2.t_order_5"));
     }
     
-    private void assertOrderItem(final ShardingRule rule) {
-        ShowShardingTableNodesExecutor executor = new 
ShowShardingTableNodesExecutor();
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = executor.getRows(new 
ShowShardingTableNodesStatement("t_order_item", null), 
mock(ContextManager.class));
+    private void assertOrderItem(final ShardingRule rule) throws SQLException {
+        engine = setUp(rule, new 
ShowShardingTableNodesStatement("t_order_item", null));
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -86,10 +103,10 @@ class ShowShardingTableNodesExecutorTest {
         assertThat(row.getCell(2), is("ds_2.t_order_item_0, 
ds_3.t_order_item_1, ds_2.t_order_item_2, ds_3.t_order_item_3, 
ds_2.t_order_item_4, ds_3.t_order_item_5"));
     }
     
-    private void assertAll(final ShardingRule rule) {
-        ShowShardingTableNodesExecutor executor = new 
ShowShardingTableNodesExecutor();
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = executor.getRows(new 
ShowShardingTableNodesStatement(null, null), mock(ContextManager.class));
+    private void assertAll(final ShardingRule rule) throws SQLException {
+        engine = setUp(rule, new ShowShardingTableNodesStatement(null, null));
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(2));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableReferenceRuleExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableReferenceRuleExecutorTest.java
index 5615149b387..ef75db33e1c 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableReferenceRuleExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableReferenceRuleExecutorTest.java
@@ -17,33 +17,49 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingTableReferenceRuleExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingTableReferenceRulesStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShardingTableReferenceRuleExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowShardingTableReferenceRuleExecutor executor = new 
ShowShardingTableReferenceRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    DistSQLQueryExecuteEngine setUp(final 
ShowShardingTableReferenceRulesStatement statement) {
+        return new DistSQLQueryExecuteEngine(statement, null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowShardingTableReferenceRulesStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine = setUp(mock(ShowShardingTableReferenceRulesStatement.class));
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -52,12 +68,10 @@ class ShowShardingTableReferenceRuleExecutorTest {
     }
     
     @Test
-    void assertGetRowDataWithSpecifiedRuleName() {
-        ShowShardingTableReferenceRuleExecutor executor = new 
ShowShardingTableReferenceRuleExecutor();
-        ShardingRule rule = mock(ShardingRule.class);
-        when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = executor.getRows(new 
ShowShardingTableReferenceRulesStatement("foo", null), 
mock(ContextManager.class));
+    void assertGetRowDataWithSpecifiedRuleName() throws SQLException {
+        engine = setUp(new ShowShardingTableReferenceRulesStatement("foo", 
null));
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
index b190a47b273..22c6efd7573 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
@@ -18,6 +18,8 @@
 package org.apache.shardingsphere.sharding.distsql.query;
 
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
@@ -26,32 +28,47 @@ import 
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAudi
 import 
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingTableRuleExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingTableRulesStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShardingTableRuleExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowShardingTableRuleExecutor executor = new 
ShowShardingTableRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowShardingTableRulesStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowShardingTableRulesStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAlgorithmExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAlgorithmExecutorTest.java
index 77078023152..5526d0c5556 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAlgorithmExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAlgorithmExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -26,13 +28,13 @@ import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfi
 import 
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingTableRulesUsedAlgorithmExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingTableRulesUsedAlgorithmStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Optional;
@@ -40,30 +42,47 @@ import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShardingTableRulesUsedAlgorithmExecutorTest {
     
-    @Test
-    void assertGetRowData() {
+    private DistSQLQueryExecuteEngine engine;
+    
+    DistSQLQueryExecuteEngine setUp(final 
ShowShardingTableRulesUsedAlgorithmStatement statement, final String 
algorithmName) {
+        
when(statement.getShardingAlgorithmName()).thenReturn(Optional.of(algorithmName));
+        return new DistSQLQueryExecuteEngine(statement, null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        ShowShardingTableRulesUsedAlgorithmExecutor executor = new 
ShowShardingTableRulesUsedAlgorithmExecutor();
-        executor.setRule(rule);
-        ShowShardingTableRulesUsedAlgorithmStatement statement = 
mock(ShowShardingTableRulesUsedAlgorithmStatement.class);
-        
when(statement.getShardingAlgorithmName()).thenReturn(Optional.of("t_order_inline"));
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(statement, mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData1() throws SQLException {
+        engine = 
setUp(mock(ShowShardingTableRulesUsedAlgorithmStatement.class), 
"t_order_inline");
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
         assertThat(row.getCell(1), is("table"));
         assertThat(row.getCell(2), is("t_order"));
-        
when(statement.getShardingAlgorithmName()).thenReturn(Optional.of("auto_mod"));
-        actual = executor.getRows(statement, mock(ContextManager.class));
+    }
+    
+    @Test
+    void assertGetRowData2() throws SQLException {
+        engine = 
setUp(mock(ShowShardingTableRulesUsedAlgorithmStatement.class), "auto_mod");
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
-        iterator = actual.iterator();
-        row = iterator.next();
+        Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
+        LocalDataQueryResultRow row = iterator.next();
         assertThat(row.getCell(1), is("auto_table"));
         assertThat(row.getCell(2), is("t_order_auto"));
     }
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAuditorExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAuditorExecutorTest.java
index de6ec05c206..0fbcda5fac7 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAuditorExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedAuditorExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -26,13 +28,13 @@ import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfi
 import 
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingTableRulesUsedAuditorExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingTableRulesUsedAuditorStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -41,20 +43,32 @@ import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShardingTableRulesUsedAuditorExecutorTest {
     
-    @Test
-    void assertGetRowData() {
+    private DistSQLQueryExecuteEngine engine;
+    
+    DistSQLQueryExecuteEngine setUp(final 
ShowShardingTableRulesUsedAuditorStatement statement, final String auditorName) 
{
+        when(statement.getAuditorName()).thenReturn(Optional.of(auditorName));
+        return new DistSQLQueryExecuteEngine(statement, null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        ShowShardingTableRulesUsedAuditorExecutor executor = new 
ShowShardingTableRulesUsedAuditorExecutor();
-        executor.setRule(rule);
-        ShowShardingTableRulesUsedAuditorStatement statement = 
mock(ShowShardingTableRulesUsedAuditorStatement.class);
-        
when(statement.getAuditorName()).thenReturn(Optional.of("shardingKeyAudit"));
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(statement, mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine = setUp(mock(ShowShardingTableRulesUsedAuditorStatement.class), 
"shardingKeyAudit");
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(2));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedKeyGeneratorExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedKeyGeneratorExecutorTest.java
index d0b16059e70..047b1791d91 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedKeyGeneratorExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRulesUsedKeyGeneratorExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -26,13 +28,13 @@ import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfi
 import 
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingTableRulesUsedKeyGeneratorExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowShardingTableRulesUsedKeyGeneratorStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Optional;
@@ -40,20 +42,32 @@ import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowShardingTableRulesUsedKeyGeneratorExecutorTest {
     
-    @Test
-    void assertGetRowData() {
+    private DistSQLQueryExecuteEngine engine;
+    
+    DistSQLQueryExecuteEngine setUp(final 
ShowShardingTableRulesUsedKeyGeneratorStatement statement, final String 
keyGeneratorName) {
+        
when(statement.getKeyGeneratorName()).thenReturn(Optional.of(keyGeneratorName));
+        return new DistSQLQueryExecuteEngine(statement, null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        ShowShardingTableRulesUsedKeyGeneratorExecutor executor = new 
ShowShardingTableRulesUsedKeyGeneratorExecutor();
-        executor.setRule(rule);
-        ShowShardingTableRulesUsedKeyGeneratorStatement statement = 
mock(ShowShardingTableRulesUsedKeyGeneratorStatement.class);
-        
when(statement.getKeyGeneratorName()).thenReturn(Optional.of("snowflake"));
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(statement, mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine = 
setUp(mock(ShowShardingTableRulesUsedKeyGeneratorStatement.class), "snowflake");
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(2));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java
index 5ef17e666a7..ddf0c557482 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java
@@ -17,36 +17,53 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowUnusedShardingAlgorithmsExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowUnusedShardingAlgorithmsStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowUnusedShardingAlgorithmsExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowUnusedShardingAlgorithmsExecutor executor = new 
ShowUnusedShardingAlgorithmsExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowUnusedShardingAlgorithmsStatement.class), 
null, mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowUnusedShardingAlgorithmsStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAuditorsExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAuditorsExecutorTest.java
index 7eea7ab0899..f3b7069757c 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAuditorsExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAuditorsExecutorTest.java
@@ -17,38 +17,55 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowUnusedShardingAuditorsExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowUnusedShardingAuditorsStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowUnusedShardingAuditorsExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowUnusedShardingAuditorsExecutor executor = new 
ShowUnusedShardingAuditorsExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowUnusedShardingAuditorsStatement.class), 
null, mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowUnusedShardingAuditorsStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
index 13dfa0ea96b..35ead71c686 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
@@ -17,35 +17,52 @@
 
 package org.apache.shardingsphere.sharding.distsql.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import 
org.apache.shardingsphere.sharding.distsql.handler.query.ShowUnusedShardingKeyGeneratorExecutor;
 import 
org.apache.shardingsphere.sharding.distsql.statement.ShowUnusedShardingKeyGeneratorsStatement;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowUnusedShardingKeyGeneratorExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowUnusedShardingKeyGeneratorExecutor executor = new 
ShowUnusedShardingKeyGeneratorExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowUnusedShardingKeyGeneratorsStatement.class), 
null, mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         ShardingRule rule = mock(ShardingRule.class);
         when(rule.getConfiguration()).thenReturn(createRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowUnusedShardingKeyGeneratorsStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(ShardingRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutorTest.java
 
b/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutorTest.java
index a4d91d1ae5e..2bcd8bc8f59 100644
--- 
a/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutorTest.java
+++ 
b/kernel/global-clock/distsql/handler/src/test/java/org/apache/shardingsphere/globalclock/distsql/handler/query/ShowGlobalClockRuleExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.globalclock.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.globalclock.api.config.GlobalClockRuleConfiguration;
 import org.apache.shardingsphere.globalclock.core.rule.GlobalClockRule;
 import 
org.apache.shardingsphere.globalclock.distsql.statement.queryable.ShowGlobalClockRuleStatement;
@@ -24,25 +26,41 @@ import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryRes
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowGlobalClockRuleExecutorTest {
     
-    @Test
-    void assertGlobalClockRule() {
-        ShowGlobalClockRuleExecutor executor = new 
ShowGlobalClockRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new DistSQLQueryExecuteEngine(new 
ShowGlobalClockRuleStatement(), null, mockContextManager(), 
mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         GlobalClockRule rule = mock(GlobalClockRule.class);
         when(rule.getConfiguration()).thenReturn(new 
GlobalClockRuleConfiguration("TSO", "local", false, PropertiesBuilder.build(new 
Property("key", "value"))));
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowGlobalClockRuleStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(GlobalClockRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGlobalClockRule() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/query/ShowDefaultSingleTableStorageUnitExecutorTest.java
 
b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/query/ShowDefaultSingleTableStorageUnitExecutorTest.java
index 5c5b7d5ffb6..2b0f21e32fc 100644
--- 
a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/query/ShowDefaultSingleTableStorageUnitExecutorTest.java
+++ 
b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/query/ShowDefaultSingleTableStorageUnitExecutorTest.java
@@ -17,31 +17,49 @@
 
 package org.apache.shardingsphere.single.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.single.api.config.SingleRuleConfiguration;
 import 
org.apache.shardingsphere.single.distsql.statement.rql.ShowDefaultSingleTableStorageUnitStatement;
 import org.apache.shardingsphere.single.rule.SingleRule;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowDefaultSingleTableStorageUnitExecutorTest {
     
-    @Test
-    void assertGetRowData() {
-        ShowDefaultSingleTableStorageUnitExecutor executor = new 
ShowDefaultSingleTableStorageUnitExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowDefaultSingleTableStorageUnitStatement.class),
 null, mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         SingleRule rule = mock(SingleRule.class);
         when(rule.getConfiguration()).thenReturn(new 
SingleRuleConfiguration(Collections.emptyList(), "foo_ds"));
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowDefaultSingleTableStorageUnitStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(SingleRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRowData() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> rowData = actual.iterator();
         String defaultSingleTableStorageUnit = (String) 
rowData.next().getCell(1);
diff --git 
a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/query/ShowSingleTableExecutorTest.java
 
b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/query/ShowSingleTableExecutorTest.java
index 6265b0f4388..adcb7e0411e 100644
--- 
a/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/query/ShowSingleTableExecutorTest.java
+++ 
b/kernel/single/distsql/handler/src/test/java/org/apache/shardingsphere/single/distsql/handler/query/ShowSingleTableExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.single.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -24,24 +26,40 @@ import 
org.apache.shardingsphere.single.distsql.statement.rql.ShowSingleTableSta
 import org.apache.shardingsphere.single.rule.SingleRule;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowSingleTableExecutorTest {
     
+    private DistSQLQueryExecuteEngine engine;
+    
+    DistSQLQueryExecuteEngine setUp(final ShowSingleTableStatement statement) {
+        return new DistSQLQueryExecuteEngine(statement, null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        SingleRule rule = mockSingleRule();
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(SingleRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
     @Test
-    void assertGetRowData() {
-        ShowSingleTableExecutor executor = new ShowSingleTableExecutor();
-        executor.setRule(mockSingleRule());
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowSingleTableStatement.class), 
mock(ContextManager.class));
+    void assertGetRowData() throws SQLException {
+        engine = setUp(mock(ShowSingleTableStatement.class));
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(2));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -53,11 +71,10 @@ class ShowSingleTableExecutorTest {
     }
     
     @Test
-    void assertGetSingleTableWithLikeLiteral() {
-        ShowSingleTableExecutor executor = new ShowSingleTableExecutor();
-        executor.setRule(mockSingleRule());
-        ShowSingleTableStatement statement = new 
ShowSingleTableStatement(null, "%item", null);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(statement, mock(ContextManager.class));
+    void assertGetSingleTableWithLikeLiteral() throws SQLException {
+        engine = setUp(new ShowSingleTableStatement(null, "%item", null));
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutorTest.java
 
b/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutorTest.java
index 72f77ecf124..07fb660c064 100644
--- 
a/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutorTest.java
+++ 
b/kernel/sql-federation/distsql/handler/src/test/java/org/apache/shardingsphere/sqlfederation/distsql/handler/query/ShowSQLFederationRuleExecutorTest.java
@@ -17,31 +17,49 @@
 
 package org.apache.shardingsphere.sqlfederation.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.sql.parser.api.CacheOption;
 import 
org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
 import 
org.apache.shardingsphere.sqlfederation.distsql.statement.queryable.ShowSQLFederationRuleStatement;
 import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowSQLFederationRuleExecutorTest {
     
-    @Test
-    void assertGetRows() {
-        ShowSQLFederationRuleExecutor executor = new 
ShowSQLFederationRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new DistSQLQueryExecuteEngine(new 
ShowSQLFederationRuleStatement(), null, mockContextManager(), 
mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         SQLFederationRule rule = mock(SQLFederationRule.class);
         when(rule.getConfiguration()).thenReturn(new 
SQLFederationRuleConfiguration(true, true, new CacheOption(2000, 65535L)));
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowSQLFederationRuleStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(SQLFederationRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertGetRows() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java
 
b/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java
index 65d40053f3d..2764e4158ec 100644
--- 
a/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java
+++ 
b/kernel/sql-parser/distsql/handler/src/test/java/org/apache/shardingsphere/parser/distsql/handler/query/ShowSQLParserRuleExecutorTest.java
@@ -17,31 +17,49 @@
 
 package org.apache.shardingsphere.parser.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
 import 
org.apache.shardingsphere.parser.distsql.statement.queryable.ShowSQLParserRuleStatement;
 import org.apache.shardingsphere.parser.rule.SQLParserRule;
 import org.apache.shardingsphere.sql.parser.api.CacheOption;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowSQLParserRuleExecutorTest {
     
-    @Test
-    void assertSQLParserRule() {
-        ShowSQLParserRuleExecutor executor = new ShowSQLParserRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new DistSQLQueryExecuteEngine(new 
ShowSQLParserRuleStatement(), null, mockContextManager(), 
mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         SQLParserRule rule = mock(SQLParserRule.class);
         when(rule.getConfiguration()).thenReturn(new 
SQLParserRuleConfiguration(new CacheOption(128, 1024), new CacheOption(2000, 
65535)));
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowSQLParserRuleStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(SQLParserRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    @Test
+    void assertSQLParserRule() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
diff --git 
a/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java
 
b/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java
index 54d6665c9e7..8ce72bc7b19 100644
--- 
a/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java
+++ 
b/kernel/sql-translator/distsql/handler/src/test/java/org/apache/shardingsphere/sqltranslator/distsql/handler/query/ShowSQLTranslatorRuleExecutorTest.java
@@ -17,31 +17,53 @@
 
 package org.apache.shardingsphere.sqltranslator.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import 
org.apache.shardingsphere.sqltranslator.api.config.SQLTranslatorRuleConfiguration;
 import 
org.apache.shardingsphere.sqltranslator.distsql.statement.queryable.ShowSQLTranslatorRuleStatement;
 import org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowSQLTranslatorRuleExecutorTest {
     
-    @Test
-    void assertExecute() {
-        ShowSQLTranslatorRuleExecutor executor = new 
ShowSQLTranslatorRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new DistSQLQueryExecuteEngine(new 
ShowSQLTranslatorRuleStatement(), null, mockContextManager(), 
mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         SQLTranslatorRule rule = mock(SQLTranslatorRule.class);
         
when(rule.getConfiguration()).thenReturn(createSQLTranslatorRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowSQLTranslatorRuleStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(SQLTranslatorRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    private SQLTranslatorRuleConfiguration 
createSQLTranslatorRuleConfiguration() {
+        return new SQLTranslatorRuleConfiguration("NATIVE", new Properties(), 
true);
+    }
+    
+    @Test
+    void assertExecute() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -49,8 +71,4 @@ class ShowSQLTranslatorRuleExecutorTest {
         assertThat(row.getCell(2), is(""));
         assertThat(row.getCell(3), is("true"));
     }
-    
-    private SQLTranslatorRuleConfiguration 
createSQLTranslatorRuleConfiguration() {
-        return new SQLTranslatorRuleConfiguration("NATIVE", new Properties(), 
true);
-    }
 }
diff --git 
a/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java
 
b/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java
index 623e7592242..329af18e7f9 100644
--- 
a/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java
+++ 
b/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.traffic.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -26,28 +28,55 @@ import 
org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
 import 
org.apache.shardingsphere.traffic.api.config.TrafficStrategyConfiguration;
 import 
org.apache.shardingsphere.traffic.distsql.statement.queryable.ShowTrafficRulesStatement;
 import org.apache.shardingsphere.traffic.rule.TrafficRule;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 class ShowTrafficRuleExecutorTest {
     
-    @Test
-    void assertExecute() {
-        ShowTrafficRuleExecutor executor = new ShowTrafficRuleExecutor();
+    private DistSQLQueryExecuteEngine engine;
+    
+    @BeforeEach
+    void setUp() {
+        engine = new 
DistSQLQueryExecuteEngine(mock(ShowTrafficRulesStatement.class), null, 
mockContextManager(), mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager() {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
         TrafficRule rule = mock(TrafficRule.class);
         
when(rule.getConfiguration()).thenReturn(createTrafficRuleConfiguration());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowTrafficRulesStatement.class), 
mock(ContextManager.class));
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(TrafficRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
+    private TrafficRuleConfiguration createTrafficRuleConfiguration() {
+        TrafficRuleConfiguration result = new TrafficRuleConfiguration();
+        result.getTrafficStrategies().add(new 
TrafficStrategyConfiguration("rule_name_1", Arrays.asList("olap", "order_by"), 
"algorithm_1", "load_balancer_1"));
+        result.getTrafficStrategies().add(new 
TrafficStrategyConfiguration("rule_name_2", Collections.singletonList("oltp"), 
"algorithm_2", "load_balancer_2"));
+        result.getLoadBalancers().put("load_balancer_1", new 
AlgorithmConfiguration("RANDOM", new Properties()));
+        result.getLoadBalancers().put("load_balancer_2", new 
AlgorithmConfiguration("ROBIN", new Properties()));
+        result.getTrafficAlgorithms().put("algorithm_1", new 
AlgorithmConfiguration("SQL_MATCH", PropertiesBuilder.build(new Property("sql", 
"select * from t_order"))));
+        result.getTrafficAlgorithms().put("algorithm_2", new 
AlgorithmConfiguration("SQL_HINT", new Properties()));
+        return result;
+    }
+    
+    @Test
+    void assertExecute() throws SQLException {
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(2));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -65,15 +94,4 @@ class ShowTrafficRuleExecutorTest {
         assertThat(row.getCell(5), is("ROBIN"));
         assertThat(row.getCell(6), is(""));
     }
-    
-    private TrafficRuleConfiguration createTrafficRuleConfiguration() {
-        TrafficRuleConfiguration result = new TrafficRuleConfiguration();
-        result.getTrafficStrategies().add(new 
TrafficStrategyConfiguration("rule_name_1", Arrays.asList("olap", "order_by"), 
"algorithm_1", "load_balancer_1"));
-        result.getTrafficStrategies().add(new 
TrafficStrategyConfiguration("rule_name_2", Collections.singletonList("oltp"), 
"algorithm_2", "load_balancer_2"));
-        result.getLoadBalancers().put("load_balancer_1", new 
AlgorithmConfiguration("RANDOM", new Properties()));
-        result.getLoadBalancers().put("load_balancer_2", new 
AlgorithmConfiguration("ROBIN", new Properties()));
-        result.getTrafficAlgorithms().put("algorithm_1", new 
AlgorithmConfiguration("SQL_MATCH", PropertiesBuilder.build(new Property("sql", 
"select * from t_order"))));
-        result.getTrafficAlgorithms().put("algorithm_2", new 
AlgorithmConfiguration("SQL_HINT", new Properties()));
-        return result;
-    }
 }
diff --git 
a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java
 
b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java
index 52b2b15dc6d..9981ec1ebe0 100644
--- 
a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java
+++ 
b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.transaction.distsql.handler.query;
 
+import 
org.apache.shardingsphere.distsql.handler.engine.DistSQLConnectionContext;
+import 
org.apache.shardingsphere.distsql.handler.engine.query.DistSQLQueryExecuteEngine;
 import 
org.apache.shardingsphere.infra.merge.result.impl.local.LocalDataQueryResultRow;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
@@ -27,25 +29,42 @@ import 
org.apache.shardingsphere.transaction.distsql.statement.queryable.ShowTra
 import org.apache.shardingsphere.transaction.rule.TransactionRule;
 import org.junit.jupiter.api.Test;
 
+import java.sql.SQLException;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 class ShowTransactionRuleExecutorTest {
     
+    private DistSQLQueryExecuteEngine engine;
+    
+    private DistSQLQueryExecuteEngine setUp(final ContextManager 
contextManager) {
+        return new DistSQLQueryExecuteEngine(new 
ShowTransactionRuleStatement(), null, contextManager, 
mock(DistSQLConnectionContext.class));
+    }
+    
+    private ContextManager mockContextManager(final TransactionRule rule) {
+        ContextManager result = mock(ContextManager.class, RETURNS_DEEP_STUBS);
+        
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().findSingleRule(TransactionRule.class)).thenReturn(Optional.of(rule));
+        return result;
+    }
+    
     @Test
-    void assertExecuteWithXA() {
-        ShowTransactionRuleExecutor executor = new 
ShowTransactionRuleExecutor();
+    void assertExecuteWithXA() throws SQLException {
         TransactionRule rule = new 
TransactionRule(createTransactionRuleConfiguration(TransactionType.XA.name(), 
"Atomikos",
                 PropertiesBuilder.build(new Property("host", "127.0.0.1"), new 
Property("databaseName", "jbossts"))), Collections.emptyMap());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowTransactionRuleStatement.class), 
mock(ContextManager.class));
+        ContextManager contextManager = mockContextManager(rule);
+        engine = setUp(contextManager);
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();
@@ -57,11 +76,13 @@ class ShowTransactionRuleExecutorTest {
     }
     
     @Test
-    void assertExecuteWithLocal() {
-        ShowTransactionRuleExecutor executor = new 
ShowTransactionRuleExecutor();
-        TransactionRule rule = new 
TransactionRule(createTransactionRuleConfiguration(TransactionType.LOCAL.name(),
 null, new Properties()), Collections.emptyMap());
-        executor.setRule(rule);
-        Collection<LocalDataQueryResultRow> actual = 
executor.getRows(mock(ShowTransactionRuleStatement.class), 
mock(ContextManager.class));
+    void assertExecuteWithLocal() throws SQLException {
+        TransactionRule rule = new 
TransactionRule(createTransactionRuleConfiguration(TransactionType.LOCAL.name(),
+                null, new Properties()), Collections.emptyMap());
+        ContextManager contextManager = mockContextManager(rule);
+        engine = setUp(contextManager);
+        engine.executeQuery();
+        Collection<LocalDataQueryResultRow> actual = engine.getRows();
         assertThat(actual.size(), is(1));
         Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
         LocalDataQueryResultRow row = iterator.next();

Reply via email to