You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/09/30 11:31:46 UTC

[shardingsphere] branch master updated: Use ShardingSphereSchema.name instead of SchemaContext.name (#7674)

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

zhangyonglun 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 6ee78a6  Use ShardingSphereSchema.name instead of SchemaContext.name (#7674)
6ee78a6 is described below

commit 6ee78a691571d47f7397818229c4e58b14f3302b
Author: Liang Zhang <te...@163.com>
AuthorDate: Wed Sep 30 19:31:28 2020 +0800

    Use ShardingSphereSchema.name instead of SchemaContext.name (#7674)
    
    * Add ShardingSphereSchema.name
    
    * Use ShardingSphereSchema.name instead of SchemaContext.name
    
    * Use RETURNS_DEEP_STUBS ti simply mock
    
    * Use RETURNS_DEEP_STUBS ti simply mock
    
    * Use RETURNS_DEEP_STUBS ti simply mock
    
    * Use RETURNS_DEEP_STUBS ti simply mock
    
    * Use RETURNS_DEEP_STUBS ti simply mock
    
    * Remove SchemaContext.name
    
    * Remove SchemaContext.name
    
    * Add javadoc
---
 .../context/schema/GovernanceSchemaContexts.java   | 16 +++----
 .../schema/GovernanceSchemaContextsTest.java       | 18 ++++----
 .../infra/context/schema/SchemaContext.java        |  2 -
 .../context/schema/SchemaContextsBuilder.java      |  4 +-
 .../infra/context/schema/ShardingSphereSchema.java |  2 +
 .../infra/context/schema/SchemaContextTest.java    | 20 ++++-----
 .../context/schema/ShardingSphereSchemaTest.java   |  6 ++-
 .../schema/impl/StandardSchemaContextsTest.java    |  2 +-
 .../driver/executor/AbstractBaseExecutorTest.java  | 39 ++++++----------
 .../executor/PreparedStatementExecutorTest.java    | 24 +++++-----
 .../driver/executor/StatementExecutorTest.java     | 38 ++++++++--------
 .../driver/jdbc/adapter/ConnectionAdapterTest.java | 14 +++---
 .../connection/ShardingSphereConnectionTest.java   | 29 +++++-------
 .../ShardingSphereDatabaseMetaDataTest.java        | 13 ++----
 .../AbstractShardingTransactionManagerFixture.java | 11 ++++-
 .../jdbc/JDBCDatabaseCommunicationEngine.java      |  2 +-
 .../backend/response/query/QueryHeaderBuilder.java |  2 +-
 .../jdbc/connection/BackendConnectionTest.java     |  2 +-
 .../jdbc/datasource/JDBCBackendDataSourceTest.java | 15 ++-----
 .../proxy/backend/context/ProxyContextTest.java    | 52 +++++++---------------
 .../response/query/QueryHeaderBuilderTest.java     | 30 ++++++-------
 .../backend/text/admin/RDLBackendHandlerTest.java  |  2 +-
 .../ShardingCTLExplainBackendHandlerTest.java      |  4 +-
 .../hint/ShardingCTLHintBackendHandlerTest.java    |  2 +-
 .../frontend/mysql/MySQLFrontendEngineTest.java    |  2 +-
 .../mysql/auth/MySQLAuthenticationHandlerTest.java |  2 +-
 .../parse/PostgreSQLComParseExecutorTest.java      |  4 +-
 27 files changed, 159 insertions(+), 198 deletions(-)

diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/main/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContexts.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/main/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContexts.java
index cab96d0..6f683c5 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/main/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContexts.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/main/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContexts.java
@@ -211,7 +211,7 @@ public final class GovernanceSchemaContexts implements SchemaContexts {
             String schemaName = entry.getKey();
             SchemaContext oldSchemaContext = entry.getValue();
             SchemaContext newSchemaContext = event.getSchemaNames().contains(schemaName) 
-                    ? new SchemaContext(oldSchemaContext.getName(), getChangedShardingSphereSchema(oldSchemaContext.getSchema(), event.getRuleSchemaMetaData(), schemaName),
+                    ? new SchemaContext(getChangedShardingSphereSchema(oldSchemaContext.getSchema(), event.getRuleSchemaMetaData(), schemaName),
                     oldSchemaContext.getRuntimeContext()) : oldSchemaContext;
             newSchemaContexts.put(schemaName, newSchemaContext);
         }
@@ -292,7 +292,7 @@ public final class GovernanceSchemaContexts implements SchemaContexts {
         Map<String, SchemaContext> result = new HashMap<>(schemaContexts.getSchemaContextMap().size());
         for (Entry<String, SchemaContext> entry : schemaContexts.getSchemaContextMap().entrySet()) {
             RuntimeContext runtimeContext = entry.getValue().getRuntimeContext();
-            result.put(entry.getKey(), new SchemaContext(entry.getValue().getName(), entry.getValue().getSchema(), new RuntimeContext(runtimeContext.getCachedDatabaseMetaData(),
+            result.put(entry.getKey(), new SchemaContext(entry.getValue().getSchema(), new RuntimeContext(runtimeContext.getCachedDatabaseMetaData(),
                     new ExecutorKernel(props.<Integer>getValue(ConfigurationPropertyKey.EXECUTOR_SIZE)), runtimeContext.getSqlParserEngine())));
         }
         return result;
@@ -300,13 +300,13 @@ public final class GovernanceSchemaContexts implements SchemaContexts {
     
     private ShardingSphereSchema getChangedShardingSphereSchema(final ShardingSphereSchema oldShardingSphereSchema, final RuleSchemaMetaData newRuleSchemaMetaData, final String schemaName) {
         ShardingSphereMetaData metaData = new ShardingSphereMetaData(oldShardingSphereSchema.getMetaData().getDataSourceMetaDatas(), newRuleSchemaMetaData, schemaName);
-        return new ShardingSphereSchema(oldShardingSphereSchema.getConfigurations(), oldShardingSphereSchema.getRules(), oldShardingSphereSchema.getDataSources(), metaData);
+        return new ShardingSphereSchema(schemaName, oldShardingSphereSchema.getConfigurations(), oldShardingSphereSchema.getRules(), oldShardingSphereSchema.getDataSources(), metaData);
     }
     
     private SchemaContext getChangedSchemaContext(final SchemaContext oldSchemaContext, final Collection<RuleConfiguration> ruleConfigs) throws SQLException {
         ShardingSphereSchema oldSchema = oldSchemaContext.getSchema();
-        SchemaContextsBuilder builder = new SchemaContextsBuilder(schemaContexts.getDatabaseType(), Collections.singletonMap(oldSchemaContext.getName(), oldSchema.getDataSources()),
-                Collections.singletonMap(oldSchemaContext.getName(), ruleConfigs), schemaContexts.getAuthentication(), schemaContexts.getProps().getProps());
+        SchemaContextsBuilder builder = new SchemaContextsBuilder(schemaContexts.getDatabaseType(), Collections.singletonMap(oldSchemaContext.getSchema().getName(), oldSchema.getDataSources()),
+                Collections.singletonMap(oldSchemaContext.getSchema().getName(), ruleConfigs), schemaContexts.getAuthentication(), schemaContexts.getProps().getProps());
         return builder.build().getSchemaContextMap().values().iterator().next();
     }
     
@@ -315,11 +315,11 @@ public final class GovernanceSchemaContexts implements SchemaContexts {
         Map<String, DataSource> modifiedDataSources = getModifiedDataSources(oldSchemaContext, newDataSourceConfigs);
         oldSchemaContext.getSchema().closeDataSources(deletedDataSources);
         oldSchemaContext.getSchema().closeDataSources(modifiedDataSources.keySet());
-        Map<String, Map<String, DataSource>> dataSourcesMap = Collections.singletonMap(oldSchemaContext.getName(), 
+        Map<String, Map<String, DataSource>> dataSourcesMap = Collections.singletonMap(oldSchemaContext.getSchema().getName(), 
                 getNewDataSources(oldSchemaContext.getSchema().getDataSources(), getAddedDataSources(oldSchemaContext, newDataSourceConfigs), modifiedDataSources, deletedDataSources));
         return new SchemaContextsBuilder(schemaContexts.getDatabaseType(), dataSourcesMap,
-                Collections.singletonMap(oldSchemaContext.getName(), oldSchemaContext.getSchema().getConfigurations()), schemaContexts.getAuthentication(), 
-                schemaContexts.getProps().getProps()).build().getSchemaContextMap().get(oldSchemaContext.getName());
+                Collections.singletonMap(oldSchemaContext.getSchema().getName(), oldSchemaContext.getSchema().getConfigurations()), schemaContexts.getAuthentication(), 
+                schemaContexts.getProps().getProps()).build().getSchemaContextMap().get(oldSchemaContext.getSchema().getName());
     }
     
     private Map<String, DataSource> getNewDataSources(final Map<String, DataSource> oldDataSources, 
diff --git a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java
index 6d0b39f..53e5f7b 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-context/src/test/java/org/apache/shardingsphere/governance/context/schema/GovernanceSchemaContextsTest.java
@@ -36,9 +36,9 @@ import org.apache.shardingsphere.infra.config.datasource.DataSourceConfiguration
 import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
 import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.context.schema.SchemaContext;
+import org.apache.shardingsphere.infra.context.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
 import org.apache.shardingsphere.infra.context.schema.runtime.RuntimeContext;
-import org.apache.shardingsphere.infra.context.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
@@ -75,6 +75,10 @@ import static org.mockito.Mockito.when;
 @RunWith(MockitoJUnitRunner.class)
 public final class GovernanceSchemaContextsTest {
     
+    private final Authentication authentication = new Authentication();
+    
+    private final ConfigurationProperties props = new ConfigurationProperties(new Properties());
+    
     @Mock
     private DatabaseType databaseType;
     
@@ -93,10 +97,6 @@ public final class GovernanceSchemaContextsTest {
     @Mock
     private PrimaryReplicaReplicationRule primaryReplicaReplicationRule;
     
-    private Authentication authentication = new Authentication();
-    
-    private ConfigurationProperties configurationProperties = new ConfigurationProperties(new Properties());
-    
     private GovernanceSchemaContexts governanceSchemaContexts;
     
     @Before
@@ -106,16 +106,16 @@ public final class GovernanceSchemaContextsTest {
         when(governanceFacade.getRegistryCenter()).thenReturn(registryCenter);
         when(governanceFacade.getConfigCenter()).thenReturn(configCenter);
         when(registryCenter.loadDisabledDataSources("schema")).thenReturn(Collections.singletonList("schema.ds_1"));
-        governanceSchemaContexts = new GovernanceSchemaContexts(new StandardSchemaContexts(getSchemaContextMap(), authentication, configurationProperties, databaseType), governanceFacade);
+        governanceSchemaContexts = new GovernanceSchemaContexts(new StandardSchemaContexts(createSchemaContextMap(), authentication, props, databaseType), governanceFacade);
     }
     
     @SneakyThrows
-    private Map<String, SchemaContext> getSchemaContextMap() {
+    private Map<String, SchemaContext> createSchemaContextMap() {
         ShardingSphereSchema shardingSphereSchema = mock(ShardingSphereSchema.class);
         ShardingSphereMetaData shardingSphereMetaData = mock(ShardingSphereMetaData.class);
         RuntimeContext runtimeContext = mock(RuntimeContext.class);
-        when(schemaContext.getName()).thenReturn("schema");
         when(schemaContext.getSchema()).thenReturn(shardingSphereSchema);
+        when(schemaContext.getSchema().getName()).thenReturn("schema");
         when(schemaContext.getRuntimeContext()).thenReturn(runtimeContext);
         when(shardingSphereSchema.getMetaData()).thenReturn(shardingSphereMetaData);
         when(shardingSphereSchema.getRules()).thenReturn(Collections.singletonList(primaryReplicaReplicationRule));
@@ -144,7 +144,7 @@ public final class GovernanceSchemaContextsTest {
     
     @Test
     public void assertGetProps() {
-        assertThat(governanceSchemaContexts.getProps(), is(configurationProperties));
+        assertThat(governanceSchemaContexts.getProps(), is(props));
     }
     
     @Test
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/SchemaContext.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/SchemaContext.java
index 7e2dd78..6b682e6 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/SchemaContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/SchemaContext.java
@@ -28,8 +28,6 @@ import org.apache.shardingsphere.infra.context.schema.runtime.RuntimeContext;
 @Getter
 public final class SchemaContext {
     
-    private final String name;
-    
     private final ShardingSphereSchema schema;
     
     private final RuntimeContext runtimeContext;
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/SchemaContextsBuilder.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/SchemaContextsBuilder.java
index 405e9e7..b8d06f3 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/SchemaContextsBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/SchemaContextsBuilder.java
@@ -99,7 +99,7 @@ public final class SchemaContextsBuilder {
         Map<String, DataSource> dataSources = this.dataSources.get(schemaName);
         RuntimeContext runtimeContext = new RuntimeContext(createCachedDatabaseMetaData(dataSources).orElse(null), 
                 executorKernel, ShardingSphereSQLParserEngineFactory.getSQLParserEngine(DatabaseTypes.getTrunkDatabaseTypeName(databaseType)));
-        return new SchemaContext(schemaName, createShardingSphereSchema(schemaName), runtimeContext);
+        return new SchemaContext(createShardingSphereSchema(schemaName), runtimeContext);
     }
     
     private Optional<CachedDatabaseMetaData> createCachedDatabaseMetaData(final Map<String, DataSource> dataSources) throws SQLException {
@@ -115,7 +115,7 @@ public final class SchemaContextsBuilder {
         Map<String, DataSource> dataSources = this.dataSources.get(schemaName);
         Collection<RuleConfiguration> ruleConfigs = this.ruleConfigs.get(schemaName);
         Collection<ShardingSphereRule> rules = ShardingSphereRulesBuilder.build(ruleConfigs, dataSources.keySet());
-        return new ShardingSphereSchema(ruleConfigs, rules, dataSources, createMetaData(schemaName, dataSources, rules));
+        return new ShardingSphereSchema(schemaName, ruleConfigs, rules, dataSources, createMetaData(schemaName, dataSources, rules));
     }
     
     private ShardingSphereMetaData createMetaData(final String schemaName, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> rules) throws SQLException {
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/ShardingSphereSchema.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/ShardingSphereSchema.java
index badfe74..226360c 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/ShardingSphereSchema.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/schema/ShardingSphereSchema.java
@@ -35,6 +35,8 @@ import java.util.Map;
 @Getter
 public final class ShardingSphereSchema {
     
+    private final String name;
+    
     private final Collection<RuleConfiguration> configurations;
     
     private final Collection<ShardingSphereRule> rules;
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/SchemaContextTest.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/SchemaContextTest.java
index 90483d1..b9bd0f2 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/SchemaContextTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/SchemaContextTest.java
@@ -22,34 +22,34 @@ import org.apache.shardingsphere.infra.context.schema.runtime.RuntimeContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.junit.Test;
-import org.mockito.Mockito;
 
 import javax.sql.DataSource;
 import java.util.Collections;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
 
 public final class SchemaContextTest {
     
     @Test
     public void assertIsComplete() {
-        ShardingSphereSchema schema = new ShardingSphereSchema(Collections.singleton(Mockito.mock(RuleConfiguration.class)), 
-                Collections.singleton(Mockito.mock(ShardingSphereRule.class)), Collections.singletonMap("ds", Mockito.mock(DataSource.class)), Mockito.mock(ShardingSphereMetaData.class));
-        assertTrue(new SchemaContext("name", schema, Mockito.mock(RuntimeContext.class)).isComplete());
+        ShardingSphereSchema schema = new ShardingSphereSchema("name", Collections.singleton(mock(RuleConfiguration.class)), 
+                Collections.singleton(mock(ShardingSphereRule.class)), Collections.singletonMap("ds", mock(DataSource.class)), mock(ShardingSphereMetaData.class));
+        assertTrue(new SchemaContext(schema, mock(RuntimeContext.class)).isComplete());
     }
     
     @Test
     public void assertIsNotCompleteWithoutRule() {
-        ShardingSphereSchema schema = new ShardingSphereSchema(Collections.emptyList(), 
-                Collections.emptyList(), Collections.singletonMap("ds", Mockito.mock(DataSource.class)), Mockito.mock(ShardingSphereMetaData.class));
-        assertFalse(new SchemaContext("name", schema, Mockito.mock(RuntimeContext.class)).isComplete());
+        ShardingSphereSchema schema = new ShardingSphereSchema("name", Collections.emptyList(), 
+                Collections.emptyList(), Collections.singletonMap("ds", mock(DataSource.class)), mock(ShardingSphereMetaData.class));
+        assertFalse(new SchemaContext(schema, mock(RuntimeContext.class)).isComplete());
     }
     
     @Test
     public void assertIsNotCompleteWithoutDataSource() {
-        ShardingSphereSchema schema = new ShardingSphereSchema(Collections.singleton(Mockito.mock(RuleConfiguration.class)),
-                Collections.singleton(Mockito.mock(ShardingSphereRule.class)), Collections.emptyMap(), Mockito.mock(ShardingSphereMetaData.class));
-        assertFalse(new SchemaContext("name", schema, Mockito.mock(RuntimeContext.class)).isComplete());
+        ShardingSphereSchema schema = new ShardingSphereSchema("name", Collections.singleton(mock(RuleConfiguration.class)),
+                Collections.singleton(mock(ShardingSphereRule.class)), Collections.emptyMap(), mock(ShardingSphereMetaData.class));
+        assertFalse(new SchemaContext(schema, mock(RuntimeContext.class)).isComplete());
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/ShardingSphereSchemaTest.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/ShardingSphereSchemaTest.java
index a6f17de..107f617 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/ShardingSphereSchemaTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/ShardingSphereSchemaTest.java
@@ -25,6 +25,8 @@ import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 
 import javax.sql.DataSource;
+import java.io.IOException;
+import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -47,8 +49,8 @@ public final class ShardingSphereSchemaTest {
     private DataSource dataSource2;
     
     @Test
-    public void assertCloseDataSources() throws Exception {
-        new ShardingSphereSchema(Collections.emptyList(), Collections.emptyList(), createDataSources(), mock(ShardingSphereMetaData.class)).closeDataSources(Arrays.asList("ds_0", "ds_2"));
+    public void assertCloseDataSources() throws SQLException, IOException {
+        new ShardingSphereSchema("name", Collections.emptyList(), Collections.emptyList(), createDataSources(), mock(ShardingSphereMetaData.class)).closeDataSources(Arrays.asList("ds_0", "ds_2"));
         verify(dataSource0).close();
         verify(dataSource1, times(0)).close();
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/impl/StandardSchemaContextsTest.java b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/impl/StandardSchemaContextsTest.java
index e88a8fe..064f391 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/impl/StandardSchemaContextsTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/schema/impl/StandardSchemaContextsTest.java
@@ -51,7 +51,7 @@ public final class StandardSchemaContextsTest {
         RuntimeContext runtimeContext = mock(RuntimeContext.class, RETURNS_DEEP_STUBS);
         ExecutorKernel executorKernel = mock(ExecutorKernel.class);
         when(runtimeContext.getExecutorKernel()).thenReturn(executorKernel);
-        SchemaContext schemaContext = new SchemaContext("logic_db", mock(ShardingSphereSchema.class), runtimeContext);
+        SchemaContext schemaContext = new SchemaContext(mock(ShardingSphereSchema.class), runtimeContext);
         StandardSchemaContexts standardSchemaContexts = new StandardSchemaContexts(
                 Collections.singletonMap("logic_db", schemaContext), new Authentication(), new ConfigurationProperties(new Properties()), mock(DatabaseType.class));
         standardSchemaContexts.close();
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
index bfee627..fe67ec5 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/AbstractBaseExecutorTest.java
@@ -22,16 +22,12 @@ import lombok.Getter;
 import org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
 import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
 import org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.context.schema.SchemaContext;
 import org.apache.shardingsphere.infra.context.schema.SchemaContexts;
 import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
-import org.apache.shardingsphere.infra.context.schema.runtime.RuntimeContext;
-import org.apache.shardingsphere.infra.context.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypes;
 import org.apache.shardingsphere.infra.executor.kernel.ExecutorKernel;
 import org.apache.shardingsphere.infra.executor.sql.resourced.jdbc.executor.ExecutorExceptionHandler;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.sql.parser.binder.segment.table.TablesContext;
 import org.apache.shardingsphere.sql.parser.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.transaction.ShardingTransactionManagerEngine;
 import org.apache.shardingsphere.transaction.context.TransactionContexts;
@@ -41,7 +37,6 @@ import org.junit.Before;
 import org.mockito.MockitoAnnotations;
 
 import javax.sql.DataSource;
-import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Collections;
 import java.util.LinkedHashMap;
@@ -50,6 +45,7 @@ import java.util.Optional;
 import java.util.Properties;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -68,45 +64,36 @@ public abstract class AbstractBaseExecutorTest {
         setConnection();
     }
     
-    private void setConnection() throws SQLException {
-        SchemaContexts schemaContexts = mock(StandardSchemaContexts.class);
-        SchemaContext schemaContext = mock(SchemaContext.class);
-        RuntimeContext runtimeContext = mock(RuntimeContext.class);
-        ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
-        when(schemaContexts.getDefaultSchemaContext()).thenReturn(schemaContext);
-        when(schemaContext.getRuntimeContext()).thenReturn(runtimeContext);
-        when(runtimeContext.getExecutorKernel()).thenReturn(executorKernel);
-        when(schemaContexts.getProps()).thenReturn(getProperties());
-        when(schemaContext.getSchema()).thenReturn(schema);
+    private void setConnection() {
+        SchemaContexts schemaContexts = mock(StandardSchemaContexts.class, RETURNS_DEEP_STUBS);
+        when(schemaContexts.getDefaultSchemaContext().getRuntimeContext().getExecutorKernel()).thenReturn(executorKernel);
+        when(schemaContexts.getProps()).thenReturn(createConfigurationProperties());
         when(schemaContexts.getDatabaseType()).thenReturn(DatabaseTypes.getActualDatabaseType("H2"));
-        ShardingRule shardingRule = getShardingRule();
-        when(schema.getRules()).thenReturn(Collections.singletonList(shardingRule));
+        ShardingRule shardingRule = mockShardingRule();
+        when(schemaContexts.getDefaultSchemaContext().getSchema().getRules()).thenReturn(Collections.singletonList(shardingRule));
         TransactionContexts transactionContexts = mock(TransactionContexts.class);
         when(transactionContexts.getDefaultTransactionManagerEngine()).thenReturn(new ShardingTransactionManagerEngine());
-        DataSource dataSource = mock(DataSource.class);
-        when(dataSource.getConnection()).thenReturn(mock(Connection.class));
+        DataSource dataSource = mock(DataSource.class, RETURNS_DEEP_STUBS);
         Map<String, DataSource> dataSourceSourceMap = new LinkedHashMap<>(2, 1);
         dataSourceSourceMap.put("ds_0", dataSource);
         dataSourceSourceMap.put("ds_1", dataSource);
         connection = new ShardingSphereConnection(dataSourceSourceMap, schemaContexts, transactionContexts, TransactionType.LOCAL);
     }
     
-    private ShardingRule getShardingRule() {
+    private ShardingRule mockShardingRule() {
         ShardingRule result = mock(ShardingRule.class);
         when(result.findTableRuleByActualTable("table_x")).thenReturn(Optional.empty());
         when(result.isNeedAccumulate(any())).thenReturn(true);
         return result;
     }
     
-    protected final SQLStatementContext<?> getSQLStatementContext() {
-        SQLStatementContext<?> result = mock(SQLStatementContext.class);
-        TablesContext tablesContext = mock(TablesContext.class);
-        when(tablesContext.getTableNames()).thenReturn(Collections.singleton("table_x"));
-        when(result.getTablesContext()).thenReturn(tablesContext);
+    protected final SQLStatementContext<?> createSQLStatementContext() {
+        SQLStatementContext<?> result = mock(SQLStatementContext.class, RETURNS_DEEP_STUBS);
+        when(result.getTablesContext().getTableNames()).thenReturn(Collections.singleton("table_x"));
         return result;
     }
     
-    private ConfigurationProperties getProperties() {
+    private ConfigurationProperties createConfigurationProperties() {
         Properties props = new Properties();
         props.setProperty(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY.getKey(), ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY.getDefaultValue());
         return new ConfigurationProperties(props);
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutorTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutorTest.java
index 6d1be92..eb290c1 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutorTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/PreparedStatementExecutorTest.java
@@ -65,8 +65,8 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
     
     @Test
     public void assertNoStatement() throws SQLException {
-        assertFalse(actual.execute(Collections.emptyList(), getSQLStatementContext()));
-        assertThat(actual.executeUpdate(Collections.emptyList(), getSQLStatementContext()), is(0));
+        assertFalse(actual.execute(Collections.emptyList(), createSQLStatementContext()));
+        assertThat(actual.executeUpdate(Collections.emptyList(), createSQLStatementContext()), is(0));
         assertThat(actual.executeQuery(Collections.emptyList()).size(), is(0));
     }
     
@@ -137,7 +137,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
     public void assertExecuteUpdateForSinglePreparedStatementSuccess() throws SQLException {
         PreparedStatement preparedStatement = getPreparedStatement();
         when(preparedStatement.executeUpdate()).thenReturn(10);
-        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(preparedStatement), false), getSQLStatementContext()), is(10));
+        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(preparedStatement), false), createSQLStatementContext()), is(10));
         verify(preparedStatement).executeUpdate();
     }
     
@@ -147,7 +147,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
         PreparedStatement preparedStatement2 = getPreparedStatement();
         when(preparedStatement1.executeUpdate()).thenReturn(10);
         when(preparedStatement2.executeUpdate()).thenReturn(20);
-        assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), getSQLStatementContext()), is(30));
+        assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), createSQLStatementContext()), is(30));
         verify(preparedStatement1).executeUpdate();
         verify(preparedStatement2).executeUpdate();
     }
@@ -157,7 +157,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
         PreparedStatement preparedStatement = getPreparedStatement();
         SQLException ex = new SQLException("");
         when(preparedStatement.executeUpdate()).thenThrow(ex);
-        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(preparedStatement), false), getSQLStatementContext()), is(0));
+        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(preparedStatement), false), createSQLStatementContext()), is(0));
         verify(preparedStatement).executeUpdate();
     }
     
@@ -169,7 +169,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
                 = new SQLException("");
         when(preparedStatement1.executeUpdate()).thenThrow(ex);
         when(preparedStatement2.executeUpdate()).thenThrow(ex);
-        assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), getSQLStatementContext()), is(0));
+        assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), createSQLStatementContext()), is(0));
         verify(preparedStatement1).executeUpdate();
         verify(preparedStatement2).executeUpdate();
     }
@@ -178,7 +178,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
     public void assertExecuteForSinglePreparedStatementSuccessWithDML() throws SQLException {
         PreparedStatement preparedStatement = getPreparedStatement();
         when(preparedStatement.execute()).thenReturn(false);
-        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), false), getSQLStatementContext()));
+        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), false), createSQLStatementContext()));
         verify(preparedStatement).execute();
     }
     
@@ -188,7 +188,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
         PreparedStatement preparedStatement2 = getPreparedStatement();
         when(preparedStatement1.execute()).thenReturn(false);
         when(preparedStatement2.execute()).thenReturn(false);
-        assertFalse(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), getSQLStatementContext()));
+        assertFalse(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), createSQLStatementContext()));
         verify(preparedStatement1).execute();
         verify(preparedStatement2).execute();
     }
@@ -198,7 +198,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
         PreparedStatement preparedStatement = getPreparedStatement();
         SQLException ex = new SQLException("");
         when(preparedStatement.execute()).thenThrow(ex);
-        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), false), getSQLStatementContext()));
+        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), false), createSQLStatementContext()));
         verify(preparedStatement).execute();
     }
     
@@ -209,7 +209,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
         SQLException ex = new SQLException("");
         when(preparedStatement1.execute()).thenThrow(ex);
         when(preparedStatement2.execute()).thenThrow(ex);
-        assertFalse(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), getSQLStatementContext()));
+        assertFalse(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), false), createSQLStatementContext()));
         verify(preparedStatement1).execute();
         verify(preparedStatement2).execute();
     }
@@ -218,7 +218,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
     public void assertExecuteForSinglePreparedStatementWithDQL() throws SQLException {
         PreparedStatement preparedStatement = getPreparedStatement();
         when(preparedStatement.execute()).thenReturn(true);
-        assertTrue(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), true), getSQLStatementContext()));
+        assertTrue(actual.execute(getExecuteGroups(Collections.singletonList(preparedStatement), true), createSQLStatementContext()));
         verify(preparedStatement).execute();
     }
     
@@ -228,7 +228,7 @@ public final class PreparedStatementExecutorTest extends AbstractBaseExecutorTes
         PreparedStatement preparedStatement2 = getPreparedStatement();
         when(preparedStatement1.execute()).thenReturn(true);
         when(preparedStatement2.execute()).thenReturn(true);
-        assertTrue(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), true), getSQLStatementContext()));
+        assertTrue(actual.execute(getExecuteGroups(Arrays.asList(preparedStatement1, preparedStatement2), true), createSQLStatementContext()));
         verify(preparedStatement1).execute();
         verify(preparedStatement2).execute();
     }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/StatementExecutorTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/StatementExecutorTest.java
index 2dc1dcb..fc5a650 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/StatementExecutorTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/executor/StatementExecutorTest.java
@@ -67,8 +67,8 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     
     @Test
     public void assertNoStatement() throws SQLException {
-        assertFalse(actual.execute(Collections.emptyList(), getSQLStatementContext()));
-        assertThat(actual.executeUpdate(Collections.emptyList(), getSQLStatementContext()), is(0));
+        assertFalse(actual.execute(Collections.emptyList(), createSQLStatementContext()));
+        assertThat(actual.executeUpdate(Collections.emptyList(), createSQLStatementContext()), is(0));
         assertThat(actual.executeQuery(Collections.emptyList()).size(), is(0));
     }
     
@@ -140,7 +140,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteUpdateForSingleStatementSuccess() throws SQLException {
         Statement statement = getStatement();
         when(statement.executeUpdate(DML_SQL)).thenReturn(10);
-        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext()), is(10));
+        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext()), is(10));
         verify(statement).executeUpdate(DML_SQL);
     }
     
@@ -150,7 +150,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         Statement statement2 = getStatement();
         when(statement1.executeUpdate(DML_SQL)).thenReturn(10);
         when(statement2.executeUpdate(DML_SQL)).thenReturn(20);
-        assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(statement1, statement2), false), getSQLStatementContext()), is(30));
+        assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(statement1, statement2), false), createSQLStatementContext()), is(30));
         verify(statement1).executeUpdate(DML_SQL);
         verify(statement2).executeUpdate(DML_SQL);
     }
@@ -160,7 +160,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         Statement statement = getStatement();
         SQLException ex = new SQLException("");
         when(statement.executeUpdate(DML_SQL)).thenThrow(ex);
-        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext()), is(0));
+        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext()), is(0));
         verify(statement).executeUpdate(DML_SQL);
     }
     
@@ -171,7 +171,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         SQLException ex = new SQLException("");
         when(statement1.executeUpdate(DML_SQL)).thenThrow(ex);
         when(statement2.executeUpdate(DML_SQL)).thenThrow(ex);
-        assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(statement1, statement2), false), getSQLStatementContext()), is(0));
+        assertThat(actual.executeUpdate(getExecuteGroups(Arrays.asList(statement1, statement2), false), createSQLStatementContext()), is(0));
         verify(statement1).executeUpdate(DML_SQL);
         verify(statement2).executeUpdate(DML_SQL);
     }
@@ -180,7 +180,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteUpdateWithAutoGeneratedKeys() throws SQLException {
         Statement statement = getStatement();
         when(statement.executeUpdate(DML_SQL, Statement.NO_GENERATED_KEYS)).thenReturn(10);
-        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext(), Statement.NO_GENERATED_KEYS), is(10));
+        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), Statement.NO_GENERATED_KEYS), is(10));
         verify(statement).executeUpdate(DML_SQL, Statement.NO_GENERATED_KEYS);
     }
     
@@ -188,7 +188,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteUpdateWithColumnIndexes() throws SQLException {
         Statement statement = getStatement();
         when(statement.executeUpdate(DML_SQL, new int[] {1})).thenReturn(10);
-        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext(), new int[] {1}), is(10));
+        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), new int[] {1}), is(10));
         verify(statement).executeUpdate(DML_SQL, new int[] {1});
     }
     
@@ -206,7 +206,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteUpdateWithColumnNames() throws SQLException {
         Statement statement = getStatement();
         when(statement.executeUpdate(DML_SQL, new String[] {"col"})).thenReturn(10);
-        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext(), new String[] {"col"}), is(10));
+        assertThat(actual.executeUpdate(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), new String[] {"col"}), is(10));
         verify(statement).executeUpdate(DML_SQL, new String[] {"col"});
     }
     
@@ -214,7 +214,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteForSingleStatementSuccessWithDML() throws SQLException {
         Statement statement = getStatement();
         when(statement.execute(DML_SQL)).thenReturn(false);
-        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext()));
+        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext()));
         verify(statement).execute(DML_SQL);
     }
     
@@ -224,7 +224,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         Statement statement2 = getStatement();
         when(statement1.execute(DML_SQL)).thenReturn(false);
         when(statement2.execute(DML_SQL)).thenReturn(false);
-        assertFalse(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), false), getSQLStatementContext()));
+        assertFalse(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), false), createSQLStatementContext()));
         verify(statement1).execute(DML_SQL);
         verify(statement2).execute(DML_SQL);
     }
@@ -234,7 +234,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         Statement statement = getStatement();
         SQLException ex = new SQLException("");
         when(statement.execute(DML_SQL)).thenThrow(ex);
-        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext()));
+        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext()));
         verify(statement).execute(DML_SQL);
     }
     
@@ -245,7 +245,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         SQLException ex = new SQLException("");
         when(statement1.execute(DML_SQL)).thenThrow(ex);
         when(statement2.execute(DML_SQL)).thenThrow(ex);
-        assertFalse(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), false), getSQLStatementContext()));
+        assertFalse(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), false), createSQLStatementContext()));
         verify(statement1).execute(DML_SQL);
         verify(statement2).execute(DML_SQL);
     }
@@ -254,7 +254,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteForSingleStatementWithDQL() throws SQLException {
         Statement statement = getStatement();
         when(statement.execute(DQL_SQL)).thenReturn(true);
-        assertTrue(actual.execute(getExecuteGroups(Collections.singletonList(statement), true), getSQLStatementContext()));
+        assertTrue(actual.execute(getExecuteGroups(Collections.singletonList(statement), true), createSQLStatementContext()));
         verify(statement).execute(DQL_SQL);
     }
     
@@ -264,7 +264,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         Statement statement2 = getStatement();
         when(statement1.execute(DQL_SQL)).thenReturn(true);
         when(statement2.execute(DQL_SQL)).thenReturn(true);
-        assertTrue(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), true), getSQLStatementContext()));
+        assertTrue(actual.execute(getExecuteGroups(Arrays.asList(statement1, statement2), true), createSQLStatementContext()));
         verify(statement1).execute(DQL_SQL);
         verify(statement2).execute(DQL_SQL);
     }
@@ -273,7 +273,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteWithAutoGeneratedKeys() throws SQLException {
         Statement statement = getStatement();
         when(statement.execute(DML_SQL, Statement.NO_GENERATED_KEYS)).thenReturn(false);
-        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext(), Statement.NO_GENERATED_KEYS));
+        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), Statement.NO_GENERATED_KEYS));
         verify(statement).execute(DML_SQL, Statement.NO_GENERATED_KEYS);
     }
 
@@ -281,7 +281,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteWithColumnIndexes() throws SQLException {
         Statement statement = getStatement();
         when(statement.execute(DML_SQL, new int[] {1})).thenReturn(false);
-        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext(), new int[] {1}));
+        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), new int[] {1}));
         verify(statement).execute(DML_SQL, new int[] {1});
     }
     
@@ -289,7 +289,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
     public void assertExecuteWithColumnNames() throws SQLException {
         Statement statement = getStatement();
         when(statement.execute(DML_SQL, new String[] {"col"})).thenReturn(false);
-        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext(), new String[] {"col"}));
+        assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext(), new String[] {"col"}));
         verify(statement).execute(DML_SQL, new String[] {"col"});
     }
     
@@ -300,7 +300,7 @@ public final class StatementExecutorTest extends AbstractBaseExecutorTest {
         SQLException ex = new SQLException("");
         when(statement.execute(DML_SQL)).thenThrow(ex);
         try {
-            assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), getSQLStatementContext()));
+            assertFalse(actual.execute(getExecuteGroups(Collections.singletonList(statement), false), createSQLStatementContext()));
         } catch (final SQLException ignored) {
         }
     }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
index ee20dec..7b987d5 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
@@ -47,8 +47,8 @@ public final class ConnectionAdapterTest extends AbstractShardingSphereDataSourc
     @After
     public void tearDown() {
         TransactionTypeHolder.clear();
-        XAShardingTransactionManagerFixture.getINVOCATIONS().clear();
-        BASEShardingTransactionManagerFixture.getINVOCATIONS().clear();
+        XAShardingTransactionManagerFixture.getInvocations().clear();
+        BASEShardingTransactionManagerFixture.getInvocations().clear();
     }
     
     @Test
@@ -97,9 +97,9 @@ public final class ConnectionAdapterTest extends AbstractShardingSphereDataSourc
         try (ShardingSphereConnection actual = getShardingSphereDataSource().getConnection()) {
             actual.setAutoCommit(false);
             assertTrue(actual.getShardingTransactionManager().isInTransaction());
-            assertThat(XAShardingTransactionManagerFixture.getINVOCATIONS().size(), is(1));
+            assertThat(XAShardingTransactionManagerFixture.getInvocations().size(), is(1));
             actual.setAutoCommit(false);
-            assertThat(XAShardingTransactionManagerFixture.getINVOCATIONS().size(), is(1));
+            assertThat(XAShardingTransactionManagerFixture.getInvocations().size(), is(1));
         } finally {
             TransactionTypeHolder.clear();
         }
@@ -119,7 +119,7 @@ public final class ConnectionAdapterTest extends AbstractShardingSphereDataSourc
         TransactionTypeHolder.set(TransactionType.XA);
         try (ShardingSphereConnection actual = getShardingSphereDataSource().getConnection()) {
             actual.commit();
-            assertTrue(XAShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.COMMIT));
+            assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.COMMIT));
         } finally {
             TransactionTypeHolder.clear();
         }
@@ -131,7 +131,7 @@ public final class ConnectionAdapterTest extends AbstractShardingSphereDataSourc
         try (ShardingSphereConnection actual = getShardingSphereDataSource().getConnection()) {
             actual.setAutoCommit(false);
             actual.setAutoCommit(true);
-            assertTrue(XAShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.COMMIT));
+            assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.COMMIT));
         } finally {
             TransactionTypeHolder.clear();
         }
@@ -151,7 +151,7 @@ public final class ConnectionAdapterTest extends AbstractShardingSphereDataSourc
         TransactionTypeHolder.set(TransactionType.XA);
         try (ShardingSphereConnection actual = getShardingSphereDataSource().getConnection()) {
             actual.rollback();
-            assertTrue(XAShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.ROLLBACK));
+            assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.ROLLBACK));
         } finally {
             TransactionTypeHolder.clear();
         }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
index 45fc3c2..7551a26 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
@@ -19,11 +19,9 @@ package org.apache.shardingsphere.driver.jdbc.core.connection;
 
 import org.apache.shardingsphere.driver.jdbc.core.fixture.BASEShardingTransactionManagerFixture;
 import org.apache.shardingsphere.driver.jdbc.core.fixture.XAShardingTransactionManagerFixture;
-import org.apache.shardingsphere.infra.context.schema.SchemaContext;
 import org.apache.shardingsphere.infra.context.schema.SchemaContexts;
-import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
-import org.apache.shardingsphere.infra.context.schema.runtime.RuntimeContext;
 import org.apache.shardingsphere.infra.context.schema.ShardingSphereSchema;
+import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypes;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
@@ -48,6 +46,7 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -78,14 +77,10 @@ public final class ShardingSphereConnectionTest {
     
     @Before
     public void setUp() {
-        schemaContexts = mock(StandardSchemaContexts.class);
-        SchemaContext schemaContext = mock(SchemaContext.class);
+        schemaContexts = mock(StandardSchemaContexts.class, RETURNS_DEEP_STUBS);
         ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
-        RuntimeContext runtimeContext = mock(RuntimeContext.class);
-        when(schemaContexts.getDefaultSchemaContext()).thenReturn(schemaContext);
-        when(schemaContext.getSchema()).thenReturn(schema);
         when(schemaContexts.getDatabaseType()).thenReturn(DatabaseTypes.getActualDatabaseType("H2"));
-        when(schemaContext.getRuntimeContext()).thenReturn(runtimeContext);
+        when(schemaContexts.getDefaultSchemaContext().getSchema()).thenReturn(schema);
         transactionContexts = mock(TransactionContexts.class);
         when(transactionContexts.getDefaultTransactionManagerEngine()).thenReturn(new ShardingTransactionManagerEngine());
         ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
@@ -98,8 +93,8 @@ public final class ShardingSphereConnectionTest {
         try {
             connection.close();
             TransactionTypeHolder.clear();
-            XAShardingTransactionManagerFixture.getINVOCATIONS().clear();
-            BASEShardingTransactionManagerFixture.getINVOCATIONS().clear();
+            XAShardingTransactionManagerFixture.getInvocations().clear();
+            BASEShardingTransactionManagerFixture.getInvocations().clear();
         } catch (final SQLException ignored) {
         }
     }
@@ -118,22 +113,22 @@ public final class ShardingSphereConnectionTest {
     public void assertXATransactionOperation() throws SQLException {
         connection = new ShardingSphereConnection(dataSourceMap, schemaContexts, transactionContexts, TransactionType.XA);
         connection.setAutoCommit(false);
-        assertTrue(XAShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.BEGIN));
+        assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.BEGIN));
         connection.commit();
-        assertTrue(XAShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.COMMIT));
+        assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.COMMIT));
         connection.rollback();
-        assertTrue(XAShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.ROLLBACK));
+        assertTrue(XAShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.ROLLBACK));
     }
     
     @Test
     public void assertBASETransactionOperation() throws SQLException {
         connection = new ShardingSphereConnection(dataSourceMap, schemaContexts, transactionContexts, TransactionType.BASE);
         connection.setAutoCommit(false);
-        assertTrue(BASEShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.BEGIN));
+        assertTrue(BASEShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.BEGIN));
         connection.commit();
-        assertTrue(BASEShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.COMMIT));
+        assertTrue(BASEShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.COMMIT));
         connection.rollback();
-        assertTrue(BASEShardingTransactionManagerFixture.getINVOCATIONS().contains(TransactionOperationType.ROLLBACK));
+        assertTrue(BASEShardingTransactionManagerFixture.getInvocations().contains(TransactionOperationType.ROLLBACK));
     }
     
     @Test
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
index 86e04ab..730ddbd 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaDataTest.java
@@ -23,8 +23,6 @@ import org.apache.shardingsphere.driver.jdbc.core.resultset.DatabaseMetaDataResu
 import org.apache.shardingsphere.infra.context.schema.SchemaContext;
 import org.apache.shardingsphere.infra.context.schema.SchemaContexts;
 import org.apache.shardingsphere.infra.context.schema.runtime.CachedDatabaseMetaData;
-import org.apache.shardingsphere.infra.context.schema.runtime.RuntimeContext;
-import org.apache.shardingsphere.infra.context.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -50,6 +48,7 @@ import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -93,14 +92,10 @@ public final class ShardingSphereDatabaseMetaDataTest {
         when(shardingSphereConnection.getConnection(anyString())).thenReturn(connection);
         when(shardingSphereConnection.getDataSourceMap()).thenReturn(dataSourceMap);
         when(shardingSphereConnection.getSchemaContexts()).thenReturn(schemaContexts);
-        SchemaContext schemaContext = mock(SchemaContext.class);
-        ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
-        RuntimeContext runtimeContext = mock(RuntimeContext.class);
+        SchemaContext schemaContext = mock(SchemaContext.class, RETURNS_DEEP_STUBS);
         when(schemaContexts.getDefaultSchemaContext()).thenReturn(schemaContext);
-        when(schemaContext.getSchema()).thenReturn(schema);
-        when(schemaContext.getRuntimeContext()).thenReturn(runtimeContext);
-        when(runtimeContext.getCachedDatabaseMetaData()).thenReturn(cachedDatabaseMetaData);
-        when(schema.getRules()).thenReturn(Collections.singletonList(mockShardingRule()));
+        when(schemaContext.getRuntimeContext().getCachedDatabaseMetaData()).thenReturn(cachedDatabaseMetaData);
+        when(schemaContext.getSchema().getRules()).thenReturn(Collections.singletonList(mockShardingRule()));
         shardingSphereDatabaseMetaData = new ShardingSphereDatabaseMetaData(shardingSphereConnection);
     }
     
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/fixture/AbstractShardingTransactionManagerFixture.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/fixture/AbstractShardingTransactionManagerFixture.java
index 0e9848e..f6e9a3d 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/fixture/AbstractShardingTransactionManagerFixture.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/fixture/AbstractShardingTransactionManagerFixture.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.driver.jdbc.core.fixture;
 
-import lombok.Getter;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.transaction.core.ResourceDataSource;
 import org.apache.shardingsphere.transaction.core.TransactionOperationType;
@@ -33,11 +32,19 @@ import java.util.Map;
 
 public abstract class AbstractShardingTransactionManagerFixture implements ShardingTransactionManager {
     
-    @Getter
     private static final Collection<TransactionOperationType> INVOCATIONS = new LinkedList<>();
     
     private final Map<String, DataSource> dataSourceMap = new HashMap<>();
     
+    /**
+     * Get invocations.
+     * 
+     * @return invocations
+     */
+    public static Collection<TransactionOperationType> getInvocations() {
+        return INVOCATIONS;
+    }
+    
     @Override
     public final void init(final DatabaseType databaseType, final Collection<ResourceDataSource> resourceDataSources) {
         for (ResourceDataSource each : resourceDataSources) {
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
index 35b8e27..a1c78b6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/JDBCDatabaseCommunicationEngine.java
@@ -95,7 +95,7 @@ public final class JDBCDatabaseCommunicationEngine implements DatabaseCommunicat
             refreshStrategy.get().refreshMetaData(logicSQLContext.getSchemaContext().getSchema().getMetaData(), ProxyContext.getInstance().getSchemaContexts().getDatabaseType(),
                     logicSQLContext.getSchemaContext().getSchema().getDataSources(), sqlStatementContext, this::loadTableMetaData);
             GovernanceEventBus.getInstance().post(
-                    new MetaDataPersistEvent(logicSQLContext.getSchemaContext().getName(), logicSQLContext.getSchemaContext().getSchema().getMetaData().getRuleSchemaMetaData()));
+                    new MetaDataPersistEvent(logicSQLContext.getSchemaContext().getSchema().getName(), logicSQLContext.getSchemaContext().getSchema().getMetaData().getRuleSchemaMetaData()));
         }
     }
     
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/query/QueryHeaderBuilder.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/query/QueryHeaderBuilder.java
index 7d46c44..44d0e2f 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/query/QueryHeaderBuilder.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/query/QueryHeaderBuilder.java
@@ -66,7 +66,7 @@ public final class QueryHeaderBuilder {
     }
     
     private static QueryHeader build(final ResultSetMetaData resultSetMetaData, final SchemaContext schema, final String columnName, final int columnIndex) throws SQLException {
-        String schemaName = schema.getName();
+        String schemaName = schema.getSchema().getName();
         String actualTableName = resultSetMetaData.getTableName(columnIndex);
         Optional<DataNodeRoutedRule> dataNodeRoutedRule = schema.getSchema().getRules().stream().filter(each -> each instanceof DataNodeRoutedRule).findFirst().map(rule -> (DataNodeRoutedRule) rule);
         String tableName;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
index 0ceb45f..3d485c3 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/BackendConnectionTest.java
@@ -108,7 +108,7 @@ public final class BackendConnectionTest {
         for (int i = 0; i < 10; i++) {
             String name = String.format(SCHEMA_PATTERN, i);
             RuntimeContext runtimeContext = mock(RuntimeContext.class);
-            SchemaContext schemaContext = new SchemaContext(name, mock(ShardingSphereSchema.class), runtimeContext);
+            SchemaContext schemaContext = new SchemaContext(mock(ShardingSphereSchema.class), runtimeContext);
             result.put(name, schemaContext);
         }
         return result;
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
index f6f21af..ea132c0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/datasource/JDBCBackendDataSourceTest.java
@@ -23,8 +23,6 @@ import org.apache.shardingsphere.infra.auth.Authentication;
 import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
 import org.apache.shardingsphere.infra.context.schema.SchemaContext;
 import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
-import org.apache.shardingsphere.infra.context.schema.runtime.RuntimeContext;
-import org.apache.shardingsphere.infra.context.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
 import org.apache.shardingsphere.infra.executor.sql.ConnectionMode;
 import org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.fixture.CallTimeRecordDataSource;
@@ -79,13 +77,9 @@ public final class JDBCBackendDataSourceTest {
     }
     
     private Map<String, SchemaContext> createSchemaContextMap() {
-        SchemaContext schemaContext = mock(SchemaContext.class);
-        ShardingSphereSchema shardingSphereSchema = mock(ShardingSphereSchema.class);
-        RuntimeContext runtimeContext = mock(RuntimeContext.class);
-        when(shardingSphereSchema.getDataSources()).thenReturn(mockDataSources(2));
-        when(schemaContext.getName()).thenReturn("schema");
-        when(schemaContext.getSchema()).thenReturn(shardingSphereSchema);
-        when(schemaContext.getRuntimeContext()).thenReturn(runtimeContext);
+        SchemaContext schemaContext = mock(SchemaContext.class, RETURNS_DEEP_STUBS);
+        when(schemaContext.getSchema().getName()).thenReturn("schema");
+        when(schemaContext.getSchema().getDataSources()).thenReturn(mockDataSources(2));
         return Collections.singletonMap("schema", schemaContext);
     }
     
@@ -98,8 +92,7 @@ public final class JDBCBackendDataSourceTest {
     
     private TransactionContexts createTransactionContexts() {
         TransactionContexts result = mock(TransactionContexts.class, RETURNS_DEEP_STUBS);
-        ShardingTransactionManagerEngine transactionManagerEngine = mock(ShardingTransactionManagerEngine.class);
-        when(result.getEngines().get("schema")).thenReturn(transactionManagerEngine);
+        when(result.getEngines().get("schema")).thenReturn(mock(ShardingTransactionManagerEngine.class));
         return result;
     }
     
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
index 03fab4a..af20f2b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/context/ProxyContextTest.java
@@ -22,8 +22,6 @@ import org.apache.shardingsphere.infra.config.properties.ConfigurationProperties
 import org.apache.shardingsphere.infra.context.schema.SchemaContext;
 import org.apache.shardingsphere.infra.context.schema.SchemaContexts;
 import org.apache.shardingsphere.infra.context.schema.impl.StandardSchemaContexts;
-import org.apache.shardingsphere.infra.context.schema.runtime.RuntimeContext;
-import org.apache.shardingsphere.infra.context.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
 import org.apache.shardingsphere.jdbc.test.MockedDataSource;
 import org.apache.shardingsphere.transaction.context.TransactionContexts;
@@ -41,7 +39,11 @@ import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -57,7 +59,7 @@ public final class ProxyContextTest {
         Field schemaContexts = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
         schemaContexts.setAccessible(true);
         schemaContexts.set(ProxyContext.getInstance(),
-                new StandardSchemaContexts(getSchemaContextMap(mockDataSourceMap), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
+                new StandardSchemaContexts(mockSchemaContextMap(mockDataSourceMap), new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
         Optional<DataSource> actual = ProxyContext.getInstance().getDataSourceSample();
         assertThat(actual, is(Optional.of(mockDataSourceMap.get("ds_1"))));
     }
@@ -74,40 +76,24 @@ public final class ProxyContextTest {
     
     @Test
     public void assertSchemaExists() throws NoSuchFieldException, IllegalAccessException {
-        SchemaContext schemaContext = mock(SchemaContext.class);
-        ShardingSphereSchema shardingSphereSchema = mock(ShardingSphereSchema.class);
-        RuntimeContext runtimeContext = mock(RuntimeContext.class);
-        when(shardingSphereSchema.getDataSources()).thenReturn(Collections.emptyMap());
-        when(schemaContext.getName()).thenReturn("schema");
-        when(schemaContext.getSchema()).thenReturn(shardingSphereSchema);
-        when(schemaContext.getRuntimeContext()).thenReturn(runtimeContext);
-        Map<String, SchemaContext> schemaContextsMap = Collections.singletonMap("schema", schemaContext);
+        Map<String, SchemaContext> schemaContextsMap = mockSchemaContextMap(Collections.emptyMap());
         Field schemaContexts = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
         schemaContexts.setAccessible(true);
         schemaContexts.set(ProxyContext.getInstance(), new StandardSchemaContexts(schemaContextsMap, new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
-        boolean exists1 = ProxyContext.getInstance().schemaExists("schema");
-        assertThat(true, is(exists1));
-        boolean exists2 = ProxyContext.getInstance().schemaExists("schema_2");
-        assertThat(false, is(exists2));
+        assertTrue(ProxyContext.getInstance().schemaExists("schema"));
+        assertFalse(ProxyContext.getInstance().schemaExists("schema_2"));
     }
     
     @Test
     public void assertGetSchema() throws NoSuchFieldException, IllegalAccessException {
-        SchemaContext schemaContext = mock(SchemaContext.class);
-        ShardingSphereSchema shardingSphereSchema = mock(ShardingSphereSchema.class);
-        RuntimeContext runtimeContext = mock(RuntimeContext.class);
-        when(shardingSphereSchema.getDataSources()).thenReturn(Collections.emptyMap());
-        when(schemaContext.getName()).thenReturn("schema");
-        when(schemaContext.getSchema()).thenReturn(shardingSphereSchema);
-        when(schemaContext.getRuntimeContext()).thenReturn(runtimeContext);
-        Map<String, SchemaContext> schemaContextsMap = Collections.singletonMap("schema", schemaContext);
+        Map<String, SchemaContext> schemaContextsMap = mockSchemaContextMap(Collections.emptyMap());
         Field schemaContexts = ProxyContext.getInstance().getClass().getDeclaredField("schemaContexts");
         schemaContexts.setAccessible(true);
         schemaContexts.set(ProxyContext.getInstance(), new StandardSchemaContexts(schemaContextsMap, new Authentication(), new ConfigurationProperties(new Properties()), new MySQLDatabaseType()));
-        assertThat(null, is(ProxyContext.getInstance().getSchema(null)));
-        assertThat(null, is(ProxyContext.getInstance().getSchema("")));
-        assertThat(null, is(ProxyContext.getInstance().getSchema("schema1")));
-        assertThat(schemaContext, is(ProxyContext.getInstance().getSchema("schema")));
+        assertNull(ProxyContext.getInstance().getSchema(null));
+        assertNull(ProxyContext.getInstance().getSchema(""));
+        assertNull(ProxyContext.getInstance().getSchema("schema1"));
+        assertThat(schemaContextsMap.get("schema"), is(ProxyContext.getInstance().getSchema("schema")));
     }
     
     @Test
@@ -127,14 +113,10 @@ public final class ProxyContextTest {
         return result;
     }
     
-    private Map<String, SchemaContext> getSchemaContextMap(final Map<String, DataSource> mockDataSourceMap) {
-        SchemaContext schemaContext = mock(SchemaContext.class);
-        ShardingSphereSchema shardingSphereSchema = mock(ShardingSphereSchema.class);
-        RuntimeContext runtimeContext = mock(RuntimeContext.class);
-        when(shardingSphereSchema.getDataSources()).thenReturn(mockDataSourceMap);
-        when(schemaContext.getName()).thenReturn("schema");
-        when(schemaContext.getSchema()).thenReturn(shardingSphereSchema);
-        when(schemaContext.getRuntimeContext()).thenReturn(runtimeContext);
+    private Map<String, SchemaContext> mockSchemaContextMap(final Map<String, DataSource> mockDataSourceMap) {
+        SchemaContext schemaContext = mock(SchemaContext.class, RETURNS_DEEP_STUBS);
+        when(schemaContext.getSchema().getName()).thenReturn("schema");
+        when(schemaContext.getSchema().getDataSources()).thenReturn(mockDataSourceMap);
         return Collections.singletonMap("schema", schemaContext);
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/response/query/QueryHeaderBuilderTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/response/query/QueryHeaderBuilderTest.java
index 066d7c4..61bd099 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/response/query/QueryHeaderBuilderTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/response/query/QueryHeaderBuilderTest.java
@@ -51,83 +51,83 @@ public final class QueryHeaderBuilderTest {
     
     @Test
     public void assertQueryHeaderSchema() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertThat(header.getSchema(), is("sharding_schema"));
     }
     
     @Test
     public void assertQueryHeaderTable() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertThat(header.getTable(), is("t_logic_order"));
     }
     
     @Test
     public void assertQueryHeaderColumnLabel() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertThat(header.getColumnLabel(), is("order_id"));
     }
     
     @Test
     public void assertQueryHeaderColumnNameWithoutProjectionsContext() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertThat(header.getColumnName(), is("order_id"));
     }
     
     @Test
     public void assertQueryHeaderColumnNameFromProjectionsContext() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createProjectionsContext(), createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createProjectionsContext(), createResultSetMetaData(), createSchemaContext(), 1);
         assertThat(header.getColumnName(), is("order_id"));
     }
     
     @Test
     public void assertQueryHeaderColumnNameFromMetaData() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createProjectionsContext(), createResultSetMetaData(), getSchemaContext(), 2);
+        QueryHeader header = QueryHeaderBuilder.build(createProjectionsContext(), createResultSetMetaData(), createSchemaContext(), 2);
         assertThat(header.getColumnName(), is("expr"));
     }
     
     @Test
     public void assertQueryHeaderColumnLength() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertThat(header.getColumnLength(), is(1));
     }
     
     @Test
     public void assertQueryHeaderColumnType() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertThat(header.getColumnType(), is(Types.INTEGER));
     }
     
     @Test
     public void assertQueryHeaderDecimals() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertThat(header.getDecimals(), is(1));
     }
     
     @Test
     public void assertQueryHeaderSigned() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertTrue(header.isSigned());
     }
     
     @Test
     public void assertQueryHeaderPrimaryKey() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertTrue(header.isPrimaryKey());
     }
     
     @Test
     public void assertQueryHeaderNotNull() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertTrue(header.isNotNull());
     }
     
     @Test
     public void assertQueryHeaderAutoIncrement() throws SQLException {
-        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), getSchemaContext(), 1);
+        QueryHeader header = QueryHeaderBuilder.build(createResultSetMetaData(), createSchemaContext(), 1);
         assertTrue(header.isAutoIncrement());
     }
     
-    private SchemaContext getSchemaContext() {
+    private SchemaContext createSchemaContext() {
         SchemaContext result = mock(SchemaContext.class);
         ColumnMetaData columnMetaData = new ColumnMetaData("order_id", Types.INTEGER, "int", true, false, false);
         SchemaMetaData schemaMetaData = mock(SchemaMetaData.class);
@@ -145,7 +145,7 @@ public final class QueryHeaderBuilderTest {
         ShardingRule shardingRule = mock(ShardingRule.class);
         when(shardingRule.findLogicTableByActualTable("t_order")).thenReturn(Optional.of("t_logic_order"));
         when(shardingSphereSchema.getRules()).thenReturn(Collections.singletonList(shardingRule));
-        when(result.getName()).thenReturn("sharding_schema");
+        when(result.getSchema().getName()).thenReturn("sharding_schema");
         return result;
     }
     
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
index ea26956..67180d8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/admin/RDLBackendHandlerTest.java
@@ -144,7 +144,7 @@ public final class RDLBackendHandlerTest {
     }
     
     private Map<String, SchemaContext> getSchemaContextMap() {
-        SchemaContext result = new SchemaContext("schema", null, null);
+        SchemaContext result = new SchemaContext(null, null);
         return Collections.singletonMap("schema", result);
     }
     
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
index b71b877..625eb1d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/explain/ShardingCTLExplainBackendHandlerTest.java
@@ -65,9 +65,9 @@ public final class ShardingCTLExplainBackendHandlerTest {
     
     private Map<String, SchemaContext> getSchemaContextMap() {
         RuntimeContext runtimeContext = new RuntimeContext(null, null, new ShardingSphereSQLParserEngine(new StandardSQLParserEngine("MySQL")));
-        ShardingSphereSchema schema = new ShardingSphereSchema(Collections.emptyList(),
+        ShardingSphereSchema schema = new ShardingSphereSchema("schema", Collections.emptyList(),
                 Collections.singleton(mock(ShardingSphereRule.class)), Collections.singletonMap("ds0", mock(DataSource.class)), mock(ShardingSphereMetaData.class, RETURNS_DEEP_STUBS));
-        return Collections.singletonMap("schema", new SchemaContext("schema", schema, runtimeContext));
+        return Collections.singletonMap("schema", new SchemaContext(schema, runtimeContext));
     }
     
     @Test
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
index a3ea27f..af77495 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/text/sctl/hint/ShardingCTLHintBackendHandlerTest.java
@@ -213,7 +213,7 @@ public final class ShardingCTLHintBackendHandlerTest {
                 new RuleSchemaMetaData(new SchemaMetaData(ImmutableMap.of("user", mock(TableMetaData.class))), Collections.emptyMap()), "sharding_db"));
         when(shardingSphereSchema.getRules()).thenReturn(Collections.singleton(mock(ShardingSphereRule.class)));
         when(shardingSphereSchema.getDataSources()).thenReturn(Collections.singletonMap("ds", mock(DataSource.class)));
-        SchemaContext result = new SchemaContext("schema", shardingSphereSchema, null);
+        SchemaContext result = new SchemaContext(shardingSphereSchema, null);
         return Collections.singletonMap("schema", result);
     }
     
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
index 7138341..e0c10fc 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/MySQLFrontendEngineTest.java
@@ -174,7 +174,7 @@ public final class MySQLFrontendEngineTest {
             String name = String.format(SCHEMA, i);
             ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
             RuntimeContext runtimeContext = mock(RuntimeContext.class);
-            result.put(name, new SchemaContext(name, schema, runtimeContext));
+            result.put(name, new SchemaContext(schema, runtimeContext));
         }
         return result;
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
index 1ca7a79..6007674 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/auth/MySQLAuthenticationHandlerTest.java
@@ -132,7 +132,7 @@ public final class MySQLAuthenticationHandlerTest {
             String name = String.format(SCHEMA_PATTERN, i);
             ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
             RuntimeContext runtimeContext = mock(RuntimeContext.class);
-            result.put(name, new SchemaContext(name, schema, runtimeContext));
+            result.put(name, new SchemaContext(schema, runtimeContext));
         }
         return result;
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
index 79db13a..dbc3baa 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/parse/PostgreSQLComParseExecutorTest.java
@@ -73,13 +73,13 @@ public final class PostgreSQLComParseExecutorTest {
     
     private Map<String, SchemaContext> getSchemaContextMap() {
         RuntimeContext runtimeContext = mock(RuntimeContext.class);
-        ShardingSphereSchema sphereSchema = mock(ShardingSphereSchema.class);
+        ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
         ShardingSphereSQLParserEngine parserEngine = mock(ShardingSphereSQLParserEngine.class);
         SQLStatement sqlStatement = mock(SQLStatement.class);
         when(runtimeContext.getSqlParserEngine()).thenReturn(parserEngine);
         when(parserEngine.parse(eq("sql"), eq(true))).thenReturn(sqlStatement);
         when(sqlStatement.getParameterCount()).thenReturn(1);
-        SchemaContext schemaContext = new SchemaContext("name", sphereSchema, runtimeContext);
+        SchemaContext schemaContext = new SchemaContext(schema, runtimeContext);
         return Collections.singletonMap("schema", schemaContext);
     }