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

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 043c216  Add: add test case for rule builder (#6593) (#6646)
043c216 is described below

commit 043c2167956b0196e8dc389e1aa0fb8eb1287f8f
Author: 孙念君 Sun Nianjun <[email protected]>
AuthorDate: Thu Aug 6 11:54:09 2020 +0800

    Add: add test case for rule builder (#6593) (#6646)
    
    * Add: add test case for rule builder (#6593)
    
    * Add: add final modifier for test case (#6593)
    
    * Add: add final modifier for method parameters (#6593)
    
    * Format: add indent
---
 .../infra/rule/ShardingSphereRulesBuilderTest.java | 39 ++++++++++++++++++
 .../infra/rule/fixture/TestRuleConfiguration.java  | 23 +++++++++++
 .../fixture/TestShardingSphereRuleBuilder.java     | 46 ++++++++++++++++++++++
 ...dingsphere.infra.rule.ShardingSphereRuleBuilder | 18 +++++++++
 4 files changed, 126 insertions(+)

diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/ShardingSphereRulesBuilderTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/ShardingSphereRulesBuilderTest.java
new file mode 100644
index 0000000..c392f57
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/ShardingSphereRulesBuilderTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.infra.rule;
+
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.rule.fixture.TestRuleConfiguration;
+import 
org.apache.shardingsphere.infra.rule.fixture.TestShardingSphereRuleBuilder;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class ShardingSphereRulesBuilderTest {
+    
+    @Test
+    public void assertBuild() {
+        RuleConfiguration ruleConfiguration = new TestRuleConfiguration();
+        Collection<ShardingSphereRule> shardingSphereRules = 
ShardingSphereRulesBuilder.build(Arrays.asList(ruleConfiguration), 
Arrays.asList(""));
+        assertThat(shardingSphereRules, 
is(Arrays.asList(TestShardingSphereRuleBuilder.getShardingSphereRule())));
+    }
+}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestRuleConfiguration.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestRuleConfiguration.java
new file mode 100644
index 0000000..e6941d7
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestRuleConfiguration.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.infra.rule.fixture;
+
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+
+public final class TestRuleConfiguration implements RuleConfiguration {
+}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingSphereRuleBuilder.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingSphereRuleBuilder.java
new file mode 100644
index 0000000..e4843b7
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingSphereRuleBuilder.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.infra.rule.fixture;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRuleBuilder;
+
+import java.util.Collection;
+
+public final class TestShardingSphereRuleBuilder implements 
ShardingSphereRuleBuilder {
+    
+    @Getter
+    private static ShardingSphereRule shardingSphereRule = new 
TestShardingSphereRule();
+    
+    @Override
+    public ShardingSphereRule build(final RuleConfiguration ruleConfiguration, 
final Collection dataSourceNames) {
+        return shardingSphereRule;
+    }
+    
+    @Override
+    public int getOrder() {
+        return 0;
+    }
+    
+    @Override
+    public Class getTypeClass() {
+        return TestRuleConfiguration.class;
+    }
+}
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.ShardingSphereRuleBuilder
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.ShardingSphereRuleBuilder
new file mode 100644
index 0000000..c067124
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.ShardingSphereRuleBuilder
@@ -0,0 +1,18 @@
+#
+# 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.infra.rule.fixture.TestShardingSphereRuleBuilder

Reply via email to