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 848a483  ADD RDL unit test for springBoot (#7672)
848a483 is described below

commit 848a483251f43a9323b8d70a807ac0f2a0f8a7ad
Author: Juan Pan(Trista) <[email protected]>
AuthorDate: Wed Sep 30 23:38:15 2020 +0800

    ADD RDL unit test for springBoot (#7672)
---
 .../sharding/spring/boot/ShardingSpringBootStarterTest.java       | 8 ++++++++
 .../src/test/resources/application-sharding.properties            | 6 ++++++
 2 files changed, 14 insertions(+)

diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/java/org/apache/shardingsphere/sharding/spring/boot/ShardingSpringBootStarterTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/java/org/apache/shardingsphere/sharding/spring/boot/ShardingSpringBootStarterTest.java
index 3186ec5..59a0cfd 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/java/org/apache/shardingsphere/sharding/spring/boot/ShardingSpringBootStarterTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/java/org/apache/shardingsphere/sharding/spring/boot/ShardingSpringBootStarterTest.java
@@ -21,6 +21,7 @@ import com.google.common.collect.Lists;
 import 
org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.algorithm.keygen.SnowflakeKeyGenerateAlgorithm;
 import 
org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm;
+import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
 import org.junit.Test;
@@ -83,6 +84,7 @@ public class ShardingSpringBootStarterTest {
     
     private void assertShardingConfigurationTables() {
         assertThat(shardingRuleConfiguration.getTables().size(), is(2));
+        assertThat(shardingRuleConfiguration.getAutoTables().size(), is(1));
         List<ShardingTableRuleConfiguration> 
shardingTableRuleConfigurationList = 
Lists.newArrayList(shardingRuleConfiguration.getTables());
         assertThat(shardingTableRuleConfigurationList.get(0).getLogicTable(), 
is("t_order"));
         
assertThat(shardingTableRuleConfigurationList.get(0).getActualDataNodes(), 
is("ds_$->{0..1}.t_order_$->{0..1}"));
@@ -98,6 +100,12 @@ public class ShardingSpringBootStarterTest {
         
assertThat(shardingTableRuleConfigurationList.get(1).getTableShardingStrategy().getShardingAlgorithmName(),
 is("orderItemTableShardingAlgorithm"));
         
assertThat(shardingTableRuleConfigurationList.get(1).getKeyGenerateStrategy().getColumn(),
 is("order_item_id"));
         
assertThat(shardingTableRuleConfigurationList.get(1).getKeyGenerateStrategy().getKeyGeneratorName(),
 is("keyGenerator"));
+        List<ShardingAutoTableRuleConfiguration> 
autoShardingTableRuleConfigurationList = 
Lists.newArrayList(shardingRuleConfiguration.getAutoTables());
+        
assertThat(autoShardingTableRuleConfigurationList.get(0).getLogicTable(), 
is("t_order_auto"));
+        
assertThat(autoShardingTableRuleConfigurationList.get(0).getActualDataSources(),
 is("ds0, ds1"));
+        
assertThat(autoShardingTableRuleConfigurationList.get(0).getShardingStrategy(), 
instanceOf(StandardShardingStrategyConfiguration.class));
+        assertThat(((StandardShardingStrategyConfiguration) 
autoShardingTableRuleConfigurationList.get(0).getShardingStrategy()).getShardingColumn(),
 is("order_id"));
+        
assertThat(autoShardingTableRuleConfigurationList.get(0).getShardingStrategy().getShardingAlgorithmName(),
 is("mod"));
     }
     
     private void assertShardingConfigurationBindingTableGroups() {
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/resources/application-sharding.properties
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/resources/application-sharding.properties
index c95ae15..86e3498 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/resources/application-sharding.properties
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-boot-starter/src/test/resources/application-sharding.properties
@@ -46,5 +46,11 @@ 
spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard
 
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
 
spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=keyGenerator
 
+spring.shardingsphere.rules.sharding.auto-tables.t_order_auto.actual-data-sources=ds0,
 ds1
+
+spring.shardingsphere.rules.sharding.auto-tables.t_order_auto.sharding-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.auto-tables.t_order_auto.sharding-strategy.standard.sharding-algorithm-name=mod
+
+
 spring.shardingsphere.rules.sharding.binding-tables=t_order,t_order_item
 spring.shardingsphere.rules.sharding.broadcast-tables=t_config

Reply via email to