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 4e0e6cb Add more assertions of MasterSlaveSpringBootStarterTest
#6926 (#7168)
4e0e6cb is described below
commit 4e0e6cbaaac53772ef161d14b0f1889ca1b740f0
Author: zhang jian <[email protected]>
AuthorDate: Mon Aug 31 22:31:15 2020 +0800
Add more assertions of MasterSlaveSpringBootStarterTest #6926 (#7168)
* Add more assertions of MasterSlaveSpringBootStarterTest #6926
* Finish OrchestrationBootstrapTest‘s assertion #7000
recover before
* Add more assertions of MasterSlaveSpringBootStarterTest #6926
---
.../spring/boot/MasterSlaveSpringBootStarterTest.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git
a/shardingsphere-features/shardingsphere-master-slave/shardingsphere-master-slave-spring/shardingsphere-master-slave-spring-boot-starter/src/test/java/org/apache/shardingsphere/masterslave/spring/boot/MasterSlaveSpringBootStarterTest.java
b/shardingsphere-features/shardingsphere-master-slave/shardingsphere-master-slave-spring/shardingsphere-master-slave-spring-boot-starter/src/test/java/org/apache/shardingsphere/masterslave/spring/boot/MasterSlaveSpringBootStarterTest.java
index 64634cb..f1058aa 100644
---
a/shardingsphere-features/shardingsphere-master-slave/shardingsphere-master-slave-spring/shardingsphere-master-slave-spring-boot-starter/src/test/java/org/apache/shardingsphere/masterslave/spring/boot/MasterSlaveSpringBootStarterTest.java
+++
b/shardingsphere-features/shardingsphere-master-slave/shardingsphere-master-slave-spring/shardingsphere-master-slave-spring-boot-starter/src/test/java/org/apache/shardingsphere/masterslave/spring/boot/MasterSlaveSpringBootStarterTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.masterslave.spring.boot;
import
org.apache.shardingsphere.masterslave.algorithm.RandomMasterSlaveLoadBalanceAlgorithm;
import
org.apache.shardingsphere.masterslave.algorithm.config.AlgorithmProvidedMasterSlaveRuleConfiguration;
+import
org.apache.shardingsphere.masterslave.api.config.rule.MasterSlaveDataSourceRuleConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -28,6 +29,8 @@ import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.annotation.Resource;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -49,6 +52,14 @@ public class MasterSlaveSpringBootStarterTest {
@Test
public void assertMasterSlaveRuleConfiguration() {
- // TODO assert MasterSlave Rule Configuration
+ assertThat(masterSlaveRuleConfiguration.getDataSources().size(),
is(1));
+ MasterSlaveDataSourceRuleConfiguration
masterSlaveDataSourceRuleConfiguration =
masterSlaveRuleConfiguration.getDataSources().stream().findFirst().get();
+ assertThat(masterSlaveDataSourceRuleConfiguration.getName(),
is("ds_ms"));
+
assertThat(masterSlaveDataSourceRuleConfiguration.getMasterDataSourceName(),
is("ds_master"));
+
assertThat(masterSlaveDataSourceRuleConfiguration.getLoadBalancerName(),
is("random"));
+
assertThat(masterSlaveDataSourceRuleConfiguration.getSlaveDataSourceNames().size(),
is(2));
+
assertTrue(masterSlaveRuleConfiguration.getDataSources().contains(masterSlaveDataSourceRuleConfiguration));
+
assertThat(masterSlaveRuleConfiguration.getLoadBalanceAlgorithms().size(),
is(1));
+
assertTrue(masterSlaveRuleConfiguration.getLoadBalanceAlgorithms().containsKey("random"));
}
}