You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/05/20 14:22:53 UTC

[shardingsphere] branch master updated: Simplify RegistryCenterTest (#10408)

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

menghaoran 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 a04dfa5  Simplify RegistryCenterTest (#10408)
a04dfa5 is described below

commit a04dfa5788b93c65ba513d338dbd41e1723592ab
Author: Liang Zhang <te...@163.com>
AuthorDate: Thu May 20 22:22:16 2021 +0800

    Simplify RegistryCenterTest (#10408)
    
    * Simplify RegistryCenterTest
    
    * Rename folder
    
    * Simplify test cases
---
 .../core/registry/RegistryCenterTest.java          | 214 ++++-----------------
 .../config/impl/DataSourceRegistryServiceTest.java |   4 +-
 .../config/impl/GlobalRuleRegistryServiceTest.java |   4 +-
 .../config/impl/SchemaRuleRegistryServiceTest.java |  82 +-------
 .../src/test/resources/yaml/data-source.yaml       |   1 +
 .../data-global-rule.yaml                          |   0
 .../data-schema-rule.yaml}                         |   0
 .../data-source-init-sql.yaml                      |   0
 .../{registryCenter => regcenter}/data-source.yaml |   1 +
 .../data-database-discovery-rule.yaml              |  32 ---
 .../yaml/registryCenter/data-encrypt-rule.yaml     |  29 ---
 .../data-readwrite-splitting-rule.yaml             |  24 ---
 .../yaml/registryCenter/data-shadow-rule.yaml      |  25 ---
 .../registryCenter/data-sharding-encrypt-rule.yaml |  55 ------
 14 files changed, 51 insertions(+), 420 deletions(-)

diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
index ee73d50..1f04bbf 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/RegistryCenterTest.java
@@ -24,6 +24,10 @@ import org.apache.shardingsphere.governance.core.registry.listener.event.metadat
 import org.apache.shardingsphere.governance.core.registry.listener.event.metadata.MetaDataDroppedEvent;
 import org.apache.shardingsphere.governance.core.registry.listener.event.rule.RuleConfigurationsAlteredEvent;
 import org.apache.shardingsphere.governance.core.registry.listener.event.rule.SwitchRuleConfigurationEvent;
+import org.apache.shardingsphere.governance.core.registry.service.config.impl.DataSourceRegistryService;
+import org.apache.shardingsphere.governance.core.registry.service.config.impl.GlobalRuleRegistryService;
+import org.apache.shardingsphere.governance.core.registry.service.config.impl.PropertiesRegistryService;
+import org.apache.shardingsphere.governance.core.registry.service.config.impl.SchemaRuleRegistryService;
 import org.apache.shardingsphere.governance.core.yaml.schema.pojo.YamlSchema;
 import org.apache.shardingsphere.governance.core.yaml.schema.swapper.SchemaYamlSwapper;
 import org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
@@ -59,7 +63,6 @@ import static org.hamcrest.CoreMatchers.hasItems;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.startsWith;
@@ -70,24 +73,26 @@ import static org.mockito.Mockito.when;
 @RunWith(MockitoJUnitRunner.class)
 public final class RegistryCenterTest {
     
-    private static final String SHARDING_RULE_YAML = "yaml/registryCenter/data-sharding-rule.yaml";
-
-    private static final String READWRITE_SPLITTING_RULE_YAML = "yaml/registryCenter/data-readwrite-splitting-rule.yaml";
+    private static final String SHARDING_RULE_YAML = "yaml/regcenter/data-schema-rule.yaml";
     
-    private static final String DB_DISCOVERY_RULE_YAML = "yaml/registryCenter/data-database-discovery-rule.yaml";
+    private static final String GLOBAL_RULE_YAML = "yaml/regcenter/data-global-rule.yaml";
     
-    private static final String ENCRYPT_RULE_YAML = "yaml/registryCenter/data-encrypt-rule.yaml";
+    private static final String META_DATA_YAML = "yaml/schema.yaml";
     
-    private static final String SHADOW_RULE_YAML = "yaml/registryCenter/data-shadow-rule.yaml";
+    @Mock
+    private RegistryCenterRepository registryCenterRepository;
     
-    private static final String GLOBAL_RULE_YAML = "yaml/registryCenter/data-global-rule.yaml";
+    @Mock
+    private DataSourceRegistryService dataSourceService;
     
-    private static final String PROPS_YAML = ConfigurationPropertyKey.SQL_SHOW.getKey() + ": false\n";
+    @Mock
+    private SchemaRuleRegistryService schemaRuleService;
     
-    private static final String META_DATA_YAML = "yaml/schema.yaml";
+    @Mock
+    private GlobalRuleRegistryService globalRuleService;
     
     @Mock
-    private RegistryCenterRepository registryCenterRepository;
+    private PropertiesRegistryService propsService;
     
     @Mock
     private RegistryCacheManager registryCacheManager;
@@ -97,9 +102,17 @@ public final class RegistryCenterTest {
     @Before
     public void setUp() throws ReflectiveOperationException {
         registryCenter = new RegistryCenter(registryCenterRepository);
-        Field field = registryCenter.getClass().getDeclaredField("repository");
+        setField("repository", registryCenterRepository);
+        setField("dataSourceService", dataSourceService);
+        setField("schemaRuleService", schemaRuleService);
+        setField("globalRuleService", globalRuleService);
+        setField("propsService", propsService);
+    }
+    
+    private void setField(final String name, final Object value) throws ReflectiveOperationException {
+        Field field = registryCenter.getClass().getDeclaredField(name);
         field.setAccessible(true);
-        field.set(registryCenter, registryCenterRepository);
+        field.set(registryCenter, value);
     }
     
     @Test
@@ -136,139 +149,27 @@ public final class RegistryCenterTest {
     }
     
     @Test
-    public void assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsExisted() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), any());
+    public void assertPersistConfiguration() {
+        Map<String, DataSourceConfiguration> dataSourceConfigs = createDataSourceConfigurations();
+        Collection<RuleConfiguration> ruleConfigs = createRuleConfigurations();
+        registryCenter.persistConfigurations("sharding_db", dataSourceConfigs, ruleConfigs, false);
+        verify(dataSourceService).persist("sharding_db", dataSourceConfigs, false);
+        verify(schemaRuleService).persist("sharding_db", ruleConfigs, false);
     }
     
     @Test
-    public void assertMoreSchema() {
+    public void assertPersistConfigurationWithMoreSchemas() {
         registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false);
         verify(registryCenterRepository, times(0)).persist("/metadata", "myTest1,myTest2,sharding_db");
     }
     
     @Test
-    public void assertMoreAndContainsSchema() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false);
-        verify(registryCenterRepository, times(0)).persist("/metadata", "myTest1,sharding_db");
-    }
-    
-    @Test
-    public void assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), any());
-    }
-    
-    @Test
-    public void assertPersistConfigurationForShardingRuleWithoutAuthenticationAndIsOverwrite() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), true);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository, times(0)).persist("/metadata/sharding_db/rules", readYAML(SHARDING_RULE_YAML));
-    }
-    
-    @Test
-    public void assertPersistConfigurationForReplicaQueryRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsExisted() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(), false);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), any());
-    }
-    
-    @Test
-    public void assertPersistConfigurationForReplicaQueryRuleWithoutAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(), false);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), any());
-    }
-    
-    @Test
-    public void assertPersistConfigurationForReadwriteSplittingWithoutAuthenticationAndIsOverwrite() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(), true);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository, times(0)).persist("/metadata/sharding_db/rules", readYAML(READWRITE_SPLITTING_RULE_YAML));
-    }
-    
-    @Test
-    public void assertPersistConfigurationForDatabaseDiscoveryRuleWithoutAuthenticationAndIsOverwrite() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createDatabaseDiscoveryRuleConfiguration(), true);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository, times(0)).persist("/metadata/sharding_db/rules", readYAML(DB_DISCOVERY_RULE_YAML));
-    }
-    
-    @Test
-    public void assertPersistConfigurationForShardingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsExisted() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), any());
-    }
-    
-    @Test
-    public void assertPersistConfigurationForShardingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), false);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), any());
-    }
-    
-    @Test
-    public void assertPersistConfigurationForShardingRuleWithAuthenticationAndIsOverwrite() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createRuleConfigurations(), true);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository, times(0)).persist("/metadata/sharding_db/rules", readYAML(SHARDING_RULE_YAML));
-    }
-    
-    @Test
-    public void assertPersistConfigurationForReplicaQueryRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsExisted() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(), false);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), any());
-    }
-    
-    @Test
-    public void assertPersistConfigurationForReadwriteSplittingRuleWithAuthenticationAndIsNotOverwriteAndConfigurationIsNotExisted() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(), false);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), any());
-    }
-    
-    @Test
-    public void assertPersistConfigurationForReadwriteSplittingRuleWithAuthenticationAndIsOverwrite() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createReadwriteSplittingRuleConfiguration(), true);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository, times(0)).persist("/metadata/sharding_db/rules", readYAML(READWRITE_SPLITTING_RULE_YAML));
-    }
-    
-    @Test
-    public void assertPersistConfigurationForDatabaseDiscoveryRuleWithAuthenticationAndIsOverwrite() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createDatabaseDiscoveryRuleConfiguration(), true);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository, times(0)).persist("/metadata/sharding_db/rules", readYAML(DB_DISCOVERY_RULE_YAML));
-    }
-    
-    @Test
-    public void assertPersistConfigurationForEncrypt() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createEncryptRuleConfiguration(), true);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository, times(0)).persist("/metadata/sharding_db/rules", readYAML(ENCRYPT_RULE_YAML));
-    }
-    
-    @Test
-    public void assertNullRuleConfiguration() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), Collections.emptyList(), true);
-    }
-    
-    @Test
-    public void assertPersistConfigurationForShadow() {
-        registryCenter.persistConfigurations("sharding_db", createDataSourceConfigurations(), createShadowRuleConfiguration(), true);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/dataSources"), any());
-        verify(registryCenterRepository, times(0)).persist("/metadata/sharding_db/rules", readYAML(SHADOW_RULE_YAML));
-    }
-    
-    @Test
     public void assertPersistGlobalConfiguration() {
-        registryCenter.persistGlobalConfiguration(createGlobalRuleConfigurations(), createProperties(), true);
-        verify(registryCenterRepository).persist(eq("/rules"), any());
-        verify(registryCenterRepository).persist("/props", PROPS_YAML);
+        Collection<RuleConfiguration> globalRuleConfigs = createGlobalRuleConfigurations();
+        Properties props = createProperties();
+        registryCenter.persistGlobalConfiguration(globalRuleConfigs, props, true);
+        verify(globalRuleService).persist(globalRuleConfigs, true);
+        verify(propsService).persist(props, true);
     }
     
     private Map<String, DataSourceConfiguration> createDataSourceConfigurations() {
@@ -298,26 +199,6 @@ public final class RegistryCenterTest {
     }
     
     @SuppressWarnings("unchecked")
-    private Collection<RuleConfiguration> createReadwriteSplittingRuleConfiguration() {
-        return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(READWRITE_SPLITTING_RULE_YAML), Collection.class));
-    }
-    
-    @SuppressWarnings("unchecked")
-    private Collection<RuleConfiguration> createDatabaseDiscoveryRuleConfiguration() {
-        return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(DB_DISCOVERY_RULE_YAML), Collection.class));
-    }
-    
-    @SuppressWarnings("unchecked")
-    private Collection<RuleConfiguration> createEncryptRuleConfiguration() {
-        return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(ENCRYPT_RULE_YAML), Collection.class));
-    }
-    
-    @SuppressWarnings("unchecked")
-    private Collection<RuleConfiguration> createShadowRuleConfiguration() {
-        return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(SHADOW_RULE_YAML), Collection.class));
-    }
-    
-    @SuppressWarnings("unchecked")
     private Collection<RuleConfiguration> createGlobalRuleConfigurations() {
         return new YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(YamlEngine.unmarshal(readYAML(GLOBAL_RULE_YAML), Collection.class));
     }
@@ -367,18 +248,6 @@ public final class RegistryCenterTest {
     @Test
     public void assertRenewDataSourceEventHasDataSourceConfig() {
         DataSourceAddedEvent event = new DataSourceAddedEvent("sharding_db", createDataSourceConfigurations());
-        String dataSourceYaml = "ds_0:\n"
-            + "  dataSourceClassName: xxx\n"
-            + "  url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false\n"
-            + "  username: root\n"
-            + "  password: root\n"
-            + "  connectionTimeoutMilliseconds: 30000\n"
-            + "  idleTimeoutMilliseconds: 60000\n"
-            + "  maxLifetimeMilliseconds: 1800000\n"
-            + "  maxPoolSize: 50\n"
-            + "  minPoolSize: 1\n"
-            + "  maintenanceIntervalMilliseconds: 30000\n";
-        when(registryCenterRepository.get("/metadata/sharding_db/dataSources")).thenReturn(dataSourceYaml);
         registryCenter.renew(event);
         verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/dataSources"), anyString());
     }
@@ -387,7 +256,7 @@ public final class RegistryCenterTest {
     public void assertRenewRuleEvent() {
         RuleConfigurationsAlteredEvent event = new RuleConfigurationsAlteredEvent("sharding_db", createRuleConfigurations());
         registryCenter.renew(event);
-        verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/rules"), anyString());
+        verify(schemaRuleService).persist(event.getSchemaName(), event.getRuleConfigurations());
     }
     
     @Test
@@ -466,14 +335,13 @@ public final class RegistryCenterTest {
         when(registryCacheManager.loadCache(anyString(), eq("testCacheId"))).thenReturn(readYAML(SHARDING_RULE_YAML));
         SwitchRuleConfigurationEvent event = new SwitchRuleConfigurationEvent("sharding_db", "testCacheId");
         registryCenter.renew(event);
-        verify(registryCenterRepository).persist(eq("/metadata/sharding_db/rules"), anyString());
-        verify(registryCacheManager).deleteCache(eq("/metadata/sharding_db/rules"), eq("testCacheId"));
+        // TODO finish verify
     }
     
     @Test
     public void assertRenewDataSourceAlteredEvent() {
         DataSourceAlteredEvent event = new DataSourceAlteredEvent("sharding_db", createDataSourceConfigurations());
         registryCenter.renew(event);
-        verify(registryCenterRepository).persist(startsWith("/metadata/sharding_db/dataSources"), anyString());
+        verify(dataSourceService).persist(event.getSchemaName(), event.getDataSourceConfigurations());
     }
 }
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/DataSourceRegistryServiceTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/DataSourceRegistryServiceTest.java
index ee8c2e5..8c3b948 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/DataSourceRegistryServiceTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/DataSourceRegistryServiceTest.java
@@ -44,9 +44,9 @@ import static org.mockito.Mockito.when;
 @RunWith(MockitoJUnitRunner.class)
 public final class DataSourceRegistryServiceTest {
     
-    private static final String DATA_SOURCE_YAM = "yaml/registryCenter/data-source.yaml";
+    private static final String DATA_SOURCE_YAM = "yaml/regcenter/data-source.yaml";
     
-    private static final String DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQL = "yaml/registryCenter/data-source-init-sql.yaml";
+    private static final String DATA_SOURCE_YAML_WITH_CONNECTION_INIT_SQL = "yaml/regcenter/data-source-init-sql.yaml";
     
     @Mock
     private RegistryCenterRepository registryCenterRepository;
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/GlobalRuleRegistryServiceTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/GlobalRuleRegistryServiceTest.java
index a261712..3ad6af1 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/GlobalRuleRegistryServiceTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/GlobalRuleRegistryServiceTest.java
@@ -49,7 +49,7 @@ import static org.mockito.Mockito.when;
 @RunWith(MockitoJUnitRunner.class)
 public final class GlobalRuleRegistryServiceTest {
     
-    private static final String GLOBAL_RULE_YAML = "yaml/registryCenter/data-global-rule.yaml";
+    private static final String YAML_DATA = "yaml/regcenter/data-global-rule.yaml";
     
     @Mock
     private RegistryCenterRepository registryCenterRepository;
@@ -66,7 +66,7 @@ public final class GlobalRuleRegistryServiceTest {
     
     @Test
     public void assertLoad() {
-        when(registryCenterRepository.get("/rules")).thenReturn(readYAML(GLOBAL_RULE_YAML));
+        when(registryCenterRepository.get("/rules")).thenReturn(readYAML(YAML_DATA));
         Collection<RuleConfiguration> globalRuleConfigs = globalRuleRegistryService.load();
         assertFalse(globalRuleConfigs.isEmpty());
         Collection<ShardingSphereUser> users = globalRuleConfigs.stream().filter(each -> each instanceof AuthorityRuleConfiguration)
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/SchemaRuleRegistryServiceTest.java b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/SchemaRuleRegistryServiceTest.java
index f24ab66..6600240 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/SchemaRuleRegistryServiceTest.java
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/java/org/apache/shardingsphere/governance/core/registry/service/config/impl/SchemaRuleRegistryServiceTest.java
@@ -18,13 +18,8 @@
 package org.apache.shardingsphere.governance.core.registry.service.config.impl;
 
 import lombok.SneakyThrows;
-import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleConfiguration;
-import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
 import org.apache.shardingsphere.governance.repository.spi.RegistryCenterRepository;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
-import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
-import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.junit.Before;
 import org.junit.Test;
@@ -37,7 +32,6 @@ import java.lang.reflect.Field;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.stream.Collectors;
 
@@ -48,17 +42,7 @@ import static org.mockito.Mockito.when;
 @RunWith(MockitoJUnitRunner.class)
 public final class SchemaRuleRegistryServiceTest {
     
-    private static final String SHARDING_RULE_YAML = "yaml/registryCenter/data-sharding-rule.yaml";
-    
-    private static final String READWRITE_SPLITTING_RULE_YAML = "yaml/registryCenter/data-readwrite-splitting-rule.yaml";
-    
-    private static final String DB_DISCOVERY_RULE_YAML = "yaml/registryCenter/data-database-discovery-rule.yaml";
-    
-    private static final String ENCRYPT_RULE_YAML = "yaml/registryCenter/data-encrypt-rule.yaml";
-    
-    private static final String SHADOW_RULE_YAML = "yaml/registryCenter/data-shadow-rule.yaml";
-    
-    private static final String SHARDING_AND_ENCRYPT_RULE_YAML = "yaml/registryCenter/data-sharding-encrypt-rule.yaml";
+    private static final String YAML_DATA = "yaml/regcenter/data-schema-rule.yaml";
     
     @Mock
     private RegistryCenterRepository registryCenterRepository;
@@ -74,73 +58,15 @@ public final class SchemaRuleRegistryServiceTest {
     }
     
     @Test
-    public void assertLoadShardingAndEncryptRuleConfigurations() {
-        when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(SHARDING_AND_ENCRYPT_RULE_YAML));
-        Collection<RuleConfiguration> ruleConfigurations = schemaRuleRegistryService.load("sharding_db");
-        assertThat(ruleConfigurations.size(), is(2));
-        for (RuleConfiguration each : ruleConfigurations) {
-            if (each instanceof ShardingRuleConfiguration) {
-                ShardingRuleConfiguration shardingRuleConfig = (ShardingRuleConfiguration) each;
-                assertThat(shardingRuleConfig.getTables().size(), is(1));
-                assertThat(shardingRuleConfig.getTables().iterator().next().getLogicTable(), is("t_order"));
-            } else if (each instanceof EncryptRuleConfiguration) {
-                EncryptRuleConfiguration encryptRuleConfig = (EncryptRuleConfiguration) each;
-                assertThat(encryptRuleConfig.getEncryptors().size(), is(2));
-                ShardingSphereAlgorithmConfiguration encryptAlgorithmConfig = encryptRuleConfig.getEncryptors().get("aes_encryptor");
-                assertThat(encryptAlgorithmConfig.getType(), is("AES"));
-                assertThat(encryptAlgorithmConfig.getProps().get("aes-key-value").toString(), is("123456abcd"));
-            }
-        }
-    }
-    
-    @Test
-    public void assertLoadShardingRuleConfiguration() {
-        when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(SHARDING_RULE_YAML));
-        Collection<RuleConfiguration> actual = schemaRuleRegistryService.load("sharding_db");
+    public void assertLoad() {
+        when(registryCenterRepository.get("/metadata/shardingsphere_db/rules")).thenReturn(readYAML(YAML_DATA));
+        Collection<RuleConfiguration> actual = schemaRuleRegistryService.load("shardingsphere_db");
         assertThat(actual.size(), is(1));
         ShardingRuleConfiguration actualShardingRuleConfig = (ShardingRuleConfiguration) actual.iterator().next();
         assertThat(actualShardingRuleConfig.getTables().size(), is(1));
         assertThat(actualShardingRuleConfig.getTables().iterator().next().getLogicTable(), is("t_order"));
     }
     
-    @Test
-    public void assertLoadReadwriteSplittingRuleConfiguration() {
-        when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(READWRITE_SPLITTING_RULE_YAML));
-        Collection<RuleConfiguration> actual = schemaRuleRegistryService.load("sharding_db");
-        ReadwriteSplittingRuleConfiguration config = (ReadwriteSplittingRuleConfiguration) actual.iterator().next();
-        assertThat(config.getDataSources().size(), is(1));
-        assertThat(config.getDataSources().iterator().next().getWriteDataSourceName(), is("write_ds"));
-        assertThat(config.getDataSources().iterator().next().getReadDataSourceNames().size(), is(2));
-    }
-    
-    @Test
-    public void assertLoadDatabaseDiscoveryRuleConfiguration() {
-        when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(DB_DISCOVERY_RULE_YAML));
-        Collection<RuleConfiguration> actual = schemaRuleRegistryService.load("sharding_db");
-        DatabaseDiscoveryRuleConfiguration config = (DatabaseDiscoveryRuleConfiguration) actual.iterator().next();
-        assertThat(config.getDataSources().size(), is(1));
-        assertThat(config.getDataSources().iterator().next().getDataSourceNames().size(), is(3));
-    }
-    
-    @Test
-    public void assertLoadEncryptRuleConfiguration() {
-        when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(ENCRYPT_RULE_YAML));
-        EncryptRuleConfiguration actual = (EncryptRuleConfiguration) schemaRuleRegistryService.load("sharding_db").iterator().next();
-        assertThat(actual.getEncryptors().size(), is(1));
-        ShardingSphereAlgorithmConfiguration encryptAlgorithmConfig = actual.getEncryptors().get("order_encryptor");
-        assertThat(encryptAlgorithmConfig.getType(), is("AES"));
-        assertThat(encryptAlgorithmConfig.getProps().get("aes-key-value").toString(), is("123456"));
-    }
-    
-    @Test
-    public void assertLoadShadowRuleConfiguration() {
-        when(registryCenterRepository.get("/metadata/sharding_db/rules")).thenReturn(readYAML(SHADOW_RULE_YAML));
-        ShadowRuleConfiguration actual = (ShadowRuleConfiguration) schemaRuleRegistryService.load("sharding_db").iterator().next();
-        assertThat(actual.getSourceDataSourceNames(), is(Arrays.asList("ds", "ds1")));
-        assertThat(actual.getShadowDataSourceNames(), is(Arrays.asList("shadow_ds", "shadow_ds1")));
-        assertThat(actual.getColumn(), is("shadow"));
-    }
-    
     @SneakyThrows({IOException.class, URISyntaxException.class})
     private String readYAML(final String yamlFile) {
         return Files.readAllLines(Paths.get(ClassLoader.getSystemResource(yamlFile).toURI()))
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/data-source.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/data-source.yaml
index 7fcc99d..0febc45 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/data-source.yaml
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/data-source.yaml
@@ -14,6 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+
 write_ds:
   dataSourceClassName: com.zaxxer.hikari.HikariDataSource
   url: jdbc:mysql://localhost:3306/demo_write_ds
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-global-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-global-rule.yaml
similarity index 100%
rename from shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-global-rule.yaml
rename to shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-global-rule.yaml
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-schema-rule.yaml
similarity index 100%
rename from shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-rule.yaml
rename to shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-schema-rule.yaml
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source-init-sql.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-source-init-sql.yaml
similarity index 100%
rename from shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source-init-sql.yaml
rename to shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-source-init-sql.yaml
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-source.yaml
similarity index 99%
rename from shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source.yaml
rename to shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-source.yaml
index ad00671..e4f19a8 100644
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-source.yaml
+++ b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/regcenter/data-source.yaml
@@ -14,6 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
+
 ds_0:
   dataSourceClassName: org.apache.shardingsphere.governance.core.registry.MockDataSource
   driverClassName: com.mysql.jdbc.Driver
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
deleted file mode 100644
index 5a3d284..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-database-discovery-rule.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-- !DB_DISCOVERY
-  dataSources:
-    pr_ds:
-      dataSourceNames:
-        - ds_0
-        - ds_1
-        - ds_2
-      discoveryTypeName: mgr
-  discoveryTypes:
-    mgr:
-      type: MGR
-      props:
-        groupName: 92504d5b-6dec-11e8-91ea-246e9612aaf1
-        zkServerLists: 'localhost:2181'
-        keepAliveCron: '0/5 * * * * ?'
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-encrypt-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-encrypt-rule.yaml
deleted file mode 100644
index 10dc2ef..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-encrypt-rule.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-- !ENCRYPT
-    tables:
-      t_order:
-        columns:
-          order_id:
-            cipherColumn: order_id
-            encryptorName: order_encryptor
-    encryptors:
-      order_encryptor:
-        type: AES
-        props:
-          aes-key-value: 123456
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-readwrite-splitting-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-readwrite-splitting-rule.yaml
deleted file mode 100644
index e20f352..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-readwrite-splitting-rule.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-- !READWRITE_SPLITTING
-  dataSources:
-    pr_ds:
-      writeDataSourceName: write_ds
-      readDataSourceNames:
-        - read_ds_0
-        - read_ds_1
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-shadow-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-shadow-rule.yaml
deleted file mode 100644
index d5404ba..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-shadow-rule.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-- !SHADOW
-  column: shadow
-  sourceDataSourceNames:
-    - ds
-    - ds1
-  shadowDataSourceNames:
-    - shadow_ds
-    - shadow_ds1
diff --git a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-encrypt-rule.yaml b/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-encrypt-rule.yaml
deleted file mode 100644
index e5e2f01..0000000
--- a/shardingsphere-governance/shardingsphere-governance-core/src/test/resources/yaml/registryCenter/data-sharding-encrypt-rule.yaml
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-- !SHARDING
-  tables:
-    t_order:
-      actualDataNodes: ds_${0..1}.t_order_${0..1}
-      tableStrategy:
-        standard:
-          shardingColumn: order_id
-          shardingAlgorithmName: table_inline
-      keyGenerateStrategy:
-        column: order_id
-        keyGeneratorName: snowflake
-  shardingAlgorithms:
-    table_inline:
-      type: INLINE
-      props:
-        algorithm-expression: t_order_${order_id % 2}
-  keyGenerators:
-    snowflake:
-      type: SNOWFLAKE
-
-- !ENCRYPT
-  encryptors:
-    aes_encryptor:
-      type: AES
-      props:
-        aes-key-value: 123456abcd
-    md5_encryptor:
-      type: MD5
-  tables:
-    t_encrypt:
-      columns:
-        user_id:
-          plainColumn: user_plain
-          cipherColumn: user_cipher
-          encryptorName: aes_encryptor
-        order_id:
-          cipherColumn: order_cipher
-          encryptorName: md5_encryptor