You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/08/01 10:26:02 UTC

[shardingsphere] branch master updated: Add MockedRuleConfiguration into test-fixture (#19750)

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

panjuan 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 f2fd4a0c29d Add MockedRuleConfiguration into test-fixture (#19750)
f2fd4a0c29d is described below

commit f2fd4a0c29d3754a76a73e1a24eeecddda7bfaef
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Aug 1 18:25:54 2022 +0800

    Add MockedRuleConfiguration into test-fixture (#19750)
---
 .../shardingsphere-proxy-bootstrap/pom.xml             |  7 +++++++
 .../proxy/fixture/RuleConfigurationFixtureChecker.java | 10 +++++-----
 .../proxy/fixture/YamlRuleConfigurationFixture.java    |  3 ++-
 .../fixture/YamlRuleConfigurationSwapperFixture.java   | 13 +++++++------
 ...pache.shardingsphere.infra.config.RuleConfiguration | 18 ------------------
 .../test/fixture/rule/MockedRuleConfiguration.java     |  8 +++++---
 6 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/pom.xml b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/pom.xml
index 1b66f2bc7da..61a55c684ef 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/pom.xml
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/pom.xml
@@ -104,6 +104,13 @@
             <version>${project.version}</version>
         </dependency>
         
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-test-fixture</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        
         <dependency>
             <groupId>org.postgresql</groupId>
             <artifactId>postgresql</artifactId>
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/RuleConfigurationFixtureChecker.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/RuleConfigurationFixtureChecker.java
index 6217a6f1284..f5d81063361 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/RuleConfigurationFixtureChecker.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/RuleConfigurationFixtureChecker.java
@@ -19,16 +19,16 @@ package org.apache.shardingsphere.proxy.fixture;
 
 import org.apache.shardingsphere.infra.config.rule.checker.RuleConfigurationChecker;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.test.fixture.rule.MockedRuleConfiguration;
 
 import javax.sql.DataSource;
 import java.util.Collection;
 import java.util.Map;
 
-public final class RuleConfigurationFixtureChecker implements RuleConfigurationChecker<RuleConfigurationFixture> {
+public final class RuleConfigurationFixtureChecker implements RuleConfigurationChecker<MockedRuleConfiguration> {
     
     @Override
-    public void check(final String databaseName, final RuleConfigurationFixture config,
-                      final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> rules) {
+    public void check(final String databaseName, final MockedRuleConfiguration config, final Map<String, DataSource> dataSourceMap, final Collection<ShardingSphereRule> rules) {
     }
     
     @Override
@@ -37,7 +37,7 @@ public final class RuleConfigurationFixtureChecker implements RuleConfigurationC
     }
     
     @Override
-    public Class<RuleConfigurationFixture> getTypeClass() {
-        return RuleConfigurationFixture.class;
+    public Class<MockedRuleConfiguration> getTypeClass() {
+        return MockedRuleConfiguration.class;
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/YamlRuleConfigurationFixture.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/YamlRuleConfigurationFixture.java
index a065edda446..d1cf915c616 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/YamlRuleConfigurationFixture.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/YamlRuleConfigurationFixture.java
@@ -21,6 +21,7 @@ import lombok.Getter;
 import lombok.Setter;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
 import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRuleConfiguration;
+import org.apache.shardingsphere.test.fixture.rule.MockedRuleConfiguration;
 
 @Getter
 @Setter
@@ -30,6 +31,6 @@ public final class YamlRuleConfigurationFixture implements YamlRuleConfiguration
     
     @Override
     public Class<? extends RuleConfiguration> getRuleConfigurationType() {
-        return RuleConfigurationFixture.class;
+        return MockedRuleConfiguration.class;
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/YamlRuleConfigurationSwapperFixture.java b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/YamlRuleConfigurationSwapperFixture.java
index 131301c0e95..0c50e1fa5f6 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/YamlRuleConfigurationSwapperFixture.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -18,24 +18,25 @@
 package org.apache.shardingsphere.proxy.fixture;
 
 import org.apache.shardingsphere.infra.yaml.config.swapper.YamlRuleConfigurationSwapper;
+import org.apache.shardingsphere.test.fixture.rule.MockedRuleConfiguration;
 
-public final class YamlRuleConfigurationSwapperFixture implements YamlRuleConfigurationSwapper<YamlRuleConfigurationFixture, RuleConfigurationFixture> {
+public final class YamlRuleConfigurationSwapperFixture implements YamlRuleConfigurationSwapper<YamlRuleConfigurationFixture, MockedRuleConfiguration> {
     
     @Override
-    public Class<RuleConfigurationFixture> getTypeClass() {
-        return RuleConfigurationFixture.class;
+    public Class<MockedRuleConfiguration> getTypeClass() {
+        return MockedRuleConfiguration.class;
     }
     
     @Override
-    public YamlRuleConfigurationFixture swapToYamlConfiguration(final RuleConfigurationFixture data) {
+    public YamlRuleConfigurationFixture swapToYamlConfiguration(final MockedRuleConfiguration data) {
         YamlRuleConfigurationFixture result = new YamlRuleConfigurationFixture();
         result.setName(data.getName());
         return result;
     }
     
     @Override
-    public RuleConfigurationFixture swapToObject(final YamlRuleConfigurationFixture yamlConfig) {
-        return new RuleConfigurationFixture(yamlConfig.getName());
+    public MockedRuleConfiguration swapToObject(final YamlRuleConfigurationFixture yamlConfig) {
+        return new MockedRuleConfiguration(yamlConfig.getName());
     }
     
     @Override
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.RuleConfiguration b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.RuleConfiguration
deleted file mode 100644
index cc15380929e..00000000000
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.RuleConfiguration
+++ /dev/null
@@ -1,18 +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.
-#
-
-org.apache.shardingsphere.proxy.fixture.RuleConfigurationFixture
diff --git a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/RuleConfigurationFixture.java b/shardingsphere-test/shardingsphere-test-fixture/src/main/java/org/apache/shardingsphere/test/fixture/rule/MockedRuleConfiguration.java
similarity index 80%
rename from shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/RuleConfigurationFixture.java
rename to shardingsphere-test/shardingsphere-test-fixture/src/main/java/org/apache/shardingsphere/test/fixture/rule/MockedRuleConfiguration.java
index ea197a80ac9..a0731eac041 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/test/java/org/apache/shardingsphere/proxy/fixture/RuleConfigurationFixture.java
+++ b/shardingsphere-test/shardingsphere-test-fixture/src/main/java/org/apache/shardingsphere/test/fixture/rule/MockedRuleConfiguration.java
@@ -15,16 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.proxy.fixture;
+package org.apache.shardingsphere.test.fixture.rule;
 
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
-import org.apache.shardingsphere.infra.config.rule.function.EnhancedRuleConfiguration;
 
+/**
+ * Mocked rule configuration.
+ */
 @RequiredArgsConstructor
 @Getter
-public final class RuleConfigurationFixture implements RuleConfiguration, EnhancedRuleConfiguration {
+public final class MockedRuleConfiguration implements RuleConfiguration {
     
     private final String name;
 }