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/08/19 10:32:55 UTC
[shardingsphere] branch master updated: Add more assertions for
algothrims (#6936)
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 2494506 Add more assertions for algothrims (#6936)
2494506 is described below
commit 2494506368342cb0dd4f9d40f4addf5a7bb3324b
Author: zhang jian <35...@users.noreply.github.com>
AuthorDate: Wed Aug 19 18:32:37 2020 +0800
Add more assertions for algothrims (#6936)
* Add more test cases for ShardingSpringNamespaceTest#6909
* Add more test cases for root rule configuration YAML swapper #6848
---
.../namespace/ShardingSpringNamespaceTest.java | 38 ++++++++++++++++++----
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
index 1d932c7..39a6914 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/test/java/org/apache/shardingsphere/sharding/spring/namespace/ShardingSpringNamespaceTest.java
@@ -19,10 +19,14 @@ package org.apache.shardingsphere.sharding.spring.namespace;
import org.apache.shardingsphere.sharding.algorithm.sharding.inline.InlineShardingAlgorithm;
import org.apache.shardingsphere.sharding.algorithm.sharding.mod.ModShardingAlgorithm;
+import org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
+import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration;
+import org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
import org.apache.shardingsphere.sharding.api.sharding.complex.ComplexKeysShardingAlgorithm;
import org.apache.shardingsphere.sharding.api.sharding.hint.HintShardingAlgorithm;
+import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
@@ -52,12 +56,30 @@ public final class ShardingSpringNamespaceTest extends AbstractJUnit4SpringConte
private HintShardingAlgorithm<?> hintShardingAlgorithm;
@Resource
+ private KeyGenerateAlgorithm incrementAlgorithm;
+
+ @Resource
private StandardShardingStrategyConfiguration dataSourceShardingStrategy;
@Resource
private StandardShardingStrategyConfiguration orderTableShardingStrategy;
@Resource
+ private StandardShardingStrategyConfiguration modStrategy;
+
+ @Resource
+ private ComplexShardingStrategyConfiguration complexStrategy;
+
+ @Resource
+ private HintShardingStrategyConfiguration hintShardingStrategy;
+
+ @Resource
+ private KeyGenerateStrategyConfiguration defaultKeyGenerator;
+
+ @Resource
+ private KeyGenerateStrategyConfiguration orderKeyGenerator;
+
+ @Resource
private NoneShardingStrategyConfiguration noneStrategy;
@Test
@@ -102,17 +124,19 @@ public final class ShardingSpringNamespaceTest extends AbstractJUnit4SpringConte
@Test
public void assertModStrategy() {
- // TODO
+ assertThat(modStrategy.getShardingColumn(), is("order_id"));
+ assertThat(modStrategy.getShardingAlgorithmName(), is("modShardingAlgorithm"));
}
@Test
public void assertComplexStrategy() {
- // TODO
+ assertThat(complexStrategy.getShardingColumns(), is("order_id,user_id"));
+ assertThat(complexStrategy.getShardingAlgorithmName(), is("complexShardingAlgorithm"));
}
@Test
public void assertHintStrategy() {
- // TODO
+ assertThat(hintShardingStrategy.getShardingAlgorithmName(), is("hintShardingAlgorithm"));
}
@Test
@@ -122,17 +146,19 @@ public final class ShardingSpringNamespaceTest extends AbstractJUnit4SpringConte
@Test
public void assertIncrementAlgorithm() {
- // TODO
+ assertThat(incrementAlgorithm.getType(), is("INCREMENT"));
}
@Test
public void assertDefaultKeyGenerator() {
- // TODO
+ assertThat(defaultKeyGenerator.getColumn(), is("id"));
+ assertThat(defaultKeyGenerator.getKeyGeneratorName(), is("incrementAlgorithm"));
}
@Test
public void assertOrderKeyGenerator() {
- // TODO
+ assertThat(orderKeyGenerator.getColumn(), is("order_id"));
+ assertThat(orderKeyGenerator.getKeyGeneratorName(), is("incrementAlgorithm"));
}
@Test