This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 82cd91cf007 Use PropertiesBuilder in readwrite-splitting module
(#23269)
82cd91cf007 is described below
commit 82cd91cf0078392e420b05f25c8aa7fa4f8cee1d
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Jan 2 23:42:52 2023 +0800
Use PropertiesBuilder in readwrite-splitting module (#23269)
---
features/readwrite-splitting/core/pom.xml | 6 ++++
...icaWeightReadQueryLoadBalanceAlgorithmTest.java | 35 +++++++---------------
...ionWeightReadQueryLoadBalanceAlgorithmTest.java | 24 ++++-----------
.../WeightReadQueryLoadBalanceAlgorithmTest.java | 23 +++++---------
...writeSplittingRuleConfigurationCheckerTest.java | 8 ++---
.../readwrite-splitting/distsql/handler/pom.xml | 7 +++++
.../query/ReadwriteSplittingRuleResultSetTest.java | 12 ++++----
7 files changed, 45 insertions(+), 70 deletions(-)
diff --git a/features/readwrite-splitting/core/pom.xml
b/features/readwrite-splitting/core/pom.xml
index 5964bc8e03c..da95f1bef63 100644
--- a/features/readwrite-splitting/core/pom.xml
+++ b/features/readwrite-splitting/core/pom.xml
@@ -56,5 +56,11 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-test-util</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithmTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithmTest.java
index baf03c1ebb8..d82040f0616 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithmTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithmTest.java
@@ -21,6 +21,8 @@ import
org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithmFactory;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import
org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
import
org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -31,7 +33,6 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -48,8 +49,8 @@ public final class
FixedReplicaWeightReadQueryLoadBalanceAlgorithmTest {
@Test
public void assertGetSingleReadDataSourceInTransaction() {
- FixedReplicaWeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("FIXED_REPLICA_WEIGHT",
createSingleDataSourceProperties()), ReadQueryLoadBalanceAlgorithm.class);
+ ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
+ new AlgorithmConfiguration("FIXED_REPLICA_WEIGHT",
PropertiesBuilder.build(new Property("test_read_ds_1", "5"))),
ReadQueryLoadBalanceAlgorithm.class);
TransactionConnectionContext context = new
TransactionConnectionContext();
context.setInTransaction(true);
String routeDataSource = loadBalanceAlgorithm.getDataSource("ds",
"test_write_ds", Collections.singletonList("test_read_ds_1"), context);
@@ -57,16 +58,10 @@ public final class
FixedReplicaWeightReadQueryLoadBalanceAlgorithmTest {
assertThat(loadBalanceAlgorithm.getDataSource("ds", "test_write_ds",
Collections.singletonList("test_read_ds_1"), context), is(routeDataSource));
}
- private Properties createSingleDataSourceProperties() {
- Properties result = new Properties();
- result.setProperty("test_read_ds_1", "5");
- return result;
- }
-
@Test
public void assertGetMultipleReadDataSourcesWithoutTransaction() {
- FixedReplicaWeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("FIXED_REPLICA_WEIGHT",
createMultipleDataSourcesProperties()), ReadQueryLoadBalanceAlgorithm.class);
+ ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(new AlgorithmConfiguration(
+ "FIXED_REPLICA_WEIGHT", PropertiesBuilder.build(new
Property("test_read_ds_1", "5"), new Property("test_read_ds_2", "5"))),
ReadQueryLoadBalanceAlgorithm.class);
String writeDataSourceName = "test_write_ds";
String readDataSourceName1 = "test_read_ds_1";
String readDataSourceName2 = "test_read_ds_2";
@@ -81,8 +76,8 @@ public final class
FixedReplicaWeightReadQueryLoadBalanceAlgorithmTest {
@Test
public void assertGetMultipleReadDataSourcesInTransaction() {
- FixedReplicaWeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("FIXED_REPLICA_WEIGHT",
createMultipleDataSourcesProperties()), ReadQueryLoadBalanceAlgorithm.class);
+ ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(new AlgorithmConfiguration(
+ "FIXED_REPLICA_WEIGHT", PropertiesBuilder.build(new
Property("test_read_ds_1", "5"), new Property("test_read_ds_2", "5"))),
ReadQueryLoadBalanceAlgorithm.class);
String writeDataSourceName = "test_write_ds";
String readDataSourceName1 = "test_read_ds_1";
String readDataSourceName2 = "test_read_ds_2";
@@ -95,20 +90,10 @@ public final class
FixedReplicaWeightReadQueryLoadBalanceAlgorithmTest {
assertThat(loadBalanceAlgorithm.getDataSource("ds",
writeDataSourceName, readDataSourceNames, transactionConnectionContext),
is(routeDataSource));
}
- private Properties createMultipleDataSourcesProperties() {
- Properties result = new Properties();
- result.setProperty("test_read_ds_1", "5");
- result.setProperty("test_read_ds_2", "5");
- return result;
- }
-
@Test
public void assertGetDataSourceWhenReadDataSourceChanged() {
- Properties props = new Properties();
- props.setProperty("test_read_ds_1", "1");
- props.setProperty("test_read_ds_2", "2");
- FixedReplicaWeightReadQueryLoadBalanceAlgorithm algorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("FIXED_REPLICA_WEIGHT", props),
ReadQueryLoadBalanceAlgorithm.class);
+ ReadQueryLoadBalanceAlgorithm algorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(new AlgorithmConfiguration(
+ "FIXED_REPLICA_WEIGHT", PropertiesBuilder.build(new
Property("test_read_ds_1", "1"), new Property("test_read_ds_2", "2"))),
ReadQueryLoadBalanceAlgorithm.class);
algorithm.getDataSource("ds", "test_write_ds",
Arrays.asList("test_read_ds_1", "test_read_ds_1"), new
TransactionConnectionContext());
assertThat(algorithm.getDataSource("ds", "test_write_ds",
Collections.singletonList("test_read_ds_1"), new
TransactionConnectionContext()), is("test_read_ds_1"));
}
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithmTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithmTest.java
index 5b31c690018..ab8a9ea138a 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithmTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithmTest.java
@@ -21,6 +21,8 @@ import
org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithmFactory;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import
org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
import
org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -30,7 +32,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -48,23 +49,17 @@ public final class
TransactionWeightReadQueryLoadBalanceAlgorithmTest {
@Test
public void assertGetSingleReadDataSource() {
- TransactionWeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("TRANSACTION_WEIGHT",
createSingleDataSourceProperties()), ReadQueryLoadBalanceAlgorithm.class);
+ ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
+ new AlgorithmConfiguration("TRANSACTION_WEIGHT",
PropertiesBuilder.build(new Property("test_read_ds_1", "5"))),
ReadQueryLoadBalanceAlgorithm.class);
TransactionConnectionContext context = new
TransactionConnectionContext();
context.setInTransaction(true);
assertThat(loadBalanceAlgorithm.getDataSource("ds", "test_write_ds",
Collections.singletonList("test_read_ds_1"), context), is("test_read_ds_1"));
}
- private Properties createSingleDataSourceProperties() {
- Properties result = new Properties();
- result.setProperty("test_read_ds_1", "5");
- return result;
- }
-
@Test
public void assertGetMultipleReadDataSources() {
- TransactionWeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("TRANSACTION_WEIGHT",
createMultipleDataSourcesProperties()), ReadQueryLoadBalanceAlgorithm.class);
+ ReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(new AlgorithmConfiguration(
+ "TRANSACTION_WEIGHT", PropertiesBuilder.build(new
Property("test_read_ds_1", "5"), new Property("test_read_ds_2", "5"))),
ReadQueryLoadBalanceAlgorithm.class);
String writeDataSourceName = "test_write_ds";
String readDataSourceName1 = "test_read_ds_1";
String readDataSourceName2 = "test_read_ds_2";
@@ -76,11 +71,4 @@ public final class
TransactionWeightReadQueryLoadBalanceAlgorithmTest {
assertThat(loadBalanceAlgorithm.getDataSource("ds",
writeDataSourceName, readDataSourceNames, context), notNullValue());
assertThat(loadBalanceAlgorithm.getDataSource("ds",
writeDataSourceName, readDataSourceNames, context), notNullValue());
}
-
- private Properties createMultipleDataSourcesProperties() {
- Properties result = new Properties();
- result.setProperty("test_read_ds_1", "5");
- result.setProperty("test_read_ds_2", "5");
- return result;
- }
}
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithmTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithmTest.java
index 65bfef1a4b9..3babf6b9912 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithmTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithmTest.java
@@ -21,12 +21,13 @@ import
org.apache.shardingsphere.infra.algorithm.ShardingSphereAlgorithmFactory;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import
org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
import
org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -36,20 +37,15 @@ public final class WeightReadQueryLoadBalanceAlgorithmTest {
@Test
public void assertGetSingleReadDataSource() {
- Properties props = new Properties();
- props.setProperty("test_read_ds_1", "5");
WeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("WEIGHT", props),
ReadQueryLoadBalanceAlgorithm.class);
+ new AlgorithmConfiguration("WEIGHT",
PropertiesBuilder.build(new Property("test_read_ds_1", "5"))),
ReadQueryLoadBalanceAlgorithm.class);
assertThat(loadBalanceAlgorithm.getDataSource("ds", "test_write_ds",
Collections.singletonList("test_read_ds_1"), new
TransactionConnectionContext()), is("test_read_ds_1"));
}
@Test
public void assertGetMultipleReadDataSources() {
- Properties props = new Properties();
- props.setProperty("test_read_ds_1", "5");
- props.setProperty("test_read_ds_2", "5");
WeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("WEIGHT", props),
ReadQueryLoadBalanceAlgorithm.class);
+ new AlgorithmConfiguration("WEIGHT",
PropertiesBuilder.build(new Property("test_read_ds_1", "5"), new
Property("test_read_ds_2", "5"))), ReadQueryLoadBalanceAlgorithm.class);
String writeDataSourceName = "test_write_ds";
String readDataSourceName1 = "test_read_ds_1";
String readDataSourceName2 = "test_read_ds_2";
@@ -61,11 +57,8 @@ public final class WeightReadQueryLoadBalanceAlgorithmTest {
@Test
public void assertGetReadDataSourceInTransaction() {
- Properties props = new Properties();
- props.setProperty("test_read_ds_1", "5");
- props.setProperty("test_read_ds_2", "5");
WeightReadQueryLoadBalanceAlgorithm loadBalanceAlgorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
- new AlgorithmConfiguration("WEIGHT", props),
ReadQueryLoadBalanceAlgorithm.class);
+ new AlgorithmConfiguration("WEIGHT",
PropertiesBuilder.build(new Property("test_read_ds_1", "5"), new
Property("test_read_ds_2", "5"))), ReadQueryLoadBalanceAlgorithm.class);
String writeDataSourceName = "test_write_ds";
String readDataSourceName1 = "test_read_ds_1";
String readDataSourceName2 = "test_read_ds_2";
@@ -77,10 +70,8 @@ public final class WeightReadQueryLoadBalanceAlgorithmTest {
@Test
public void assertGetDataSourceWhenReadDataSourceChanged() {
- Properties props = new Properties();
- props.setProperty("test_read_ds_1", "1");
- props.setProperty("test_read_ds_2", "2");
- WeightReadQueryLoadBalanceAlgorithm algorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(new
AlgorithmConfiguration("WEIGHT", props), ReadQueryLoadBalanceAlgorithm.class);
+ WeightReadQueryLoadBalanceAlgorithm algorithm =
ShardingSphereAlgorithmFactory.createAlgorithm(
+ new AlgorithmConfiguration("WEIGHT",
PropertiesBuilder.build(new Property("test_read_ds_1", "1"), new
Property("test_read_ds_2", "2"))), ReadQueryLoadBalanceAlgorithm.class);
algorithm.getDataSource("ds", "test_write_ds",
Arrays.asList("test_read_ds_1", "test_read_ds_1"), new
TransactionConnectionContext());
assertThat(algorithm.getDataSource("ds", "test_write_ds",
Collections.singletonList("test_read_ds_1"), new
TransactionConnectionContext()), is("test_read_ds_1"));
}
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
index bc7cffed31d..37d822cfaf2 100644
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
+++
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
@@ -26,6 +26,8 @@ import
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleCo
import
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
import
org.apache.shardingsphere.readwritesplitting.api.strategy.DynamicReadwriteSplittingStrategyConfiguration;
import
org.apache.shardingsphere.readwritesplitting.api.strategy.StaticReadwriteSplittingStrategyConfiguration;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.Test;
import javax.sql.DataSource;
@@ -34,7 +36,6 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -103,10 +104,7 @@ public final class
ReadwriteSplittingRuleConfigurationCheckerTest {
ReadwriteSplittingRuleConfiguration config =
mock(ReadwriteSplittingRuleConfiguration.class);
List<ReadwriteSplittingDataSourceRuleConfiguration> configs =
Collections.singletonList(createDataSourceRuleConfig("write_ds_0",
Arrays.asList("read_ds_0", "read_ds_1")));
when(config.getDataSources()).thenReturn(configs);
- Properties props = new Properties();
- props.setProperty("read_ds_2", "1");
- props.setProperty("read_ds_1", "2");
- AlgorithmConfiguration algorithm = new
AlgorithmConfiguration("WEIGHT", props);
+ AlgorithmConfiguration algorithm = new
AlgorithmConfiguration("WEIGHT", PropertiesBuilder.build(new
Property("read_ds_2", "1"), new Property("read_ds_1", "2")));
when(config.getLoadBalancers()).thenReturn(Collections.singletonMap("weight_ds",
algorithm));
RuleConfigurationChecker checker =
OrderedSPIRegistry.getRegisteredServicesByClass(RuleConfigurationChecker.class,
Collections.singleton(config.getClass())).get(config.getClass());
checker.check("test", config, mockDataSources(),
Collections.emptyList());
diff --git a/features/readwrite-splitting/distsql/handler/pom.xml
b/features/readwrite-splitting/distsql/handler/pom.xml
index 96c9ff0a3b0..2119e940fae 100644
--- a/features/readwrite-splitting/distsql/handler/pom.xml
+++ b/features/readwrite-splitting/distsql/handler/pom.xml
@@ -48,5 +48,12 @@
<artifactId>shardingsphere-readwrite-splitting-distsql-parser</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-test-util</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleResultSetTest.java
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleResultSetTest.java
index c1dd305505e..dba66e86c37 100644
---
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleResultSetTest.java
+++
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleResultSetTest.java
@@ -19,15 +19,17 @@ package
org.apache.shardingsphere.readwritesplitting.distsql.handler.query;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableConstants;
import
org.apache.shardingsphere.infra.rule.identifier.type.exportable.constant.ExportableItemConstants;
-import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
import
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
import
org.apache.shardingsphere.readwritesplitting.api.strategy.DynamicReadwriteSplittingStrategyConfiguration;
import
org.apache.shardingsphere.readwritesplitting.api.strategy.StaticReadwriteSplittingStrategyConfiguration;
import
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowReadwriteSplittingRulesStatement;
import
org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
import org.junit.Test;
import java.util.Arrays;
@@ -37,11 +39,10 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
-import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
@@ -87,9 +88,8 @@ public final class ReadwriteSplittingRuleResultSetTest {
ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig =
new
ReadwriteSplittingDataSourceRuleConfiguration("readwrite_ds",
new
StaticReadwriteSplittingStrategyConfiguration("ds_primary",
Arrays.asList("ds_slave_0", "ds_slave_1")), null, "test");
- Properties props = new Properties();
- props.setProperty("read_weight", "2:1");
- return new
ReadwriteSplittingRuleConfiguration(Collections.singleton(dataSourceRuleConfig),
Collections.singletonMap("test", new AlgorithmConfiguration("random", props)));
+ return new ReadwriteSplittingRuleConfiguration(
+ Collections.singleton(dataSourceRuleConfig),
Collections.singletonMap("test", new AlgorithmConfiguration("random",
PropertiesBuilder.build(new Property("read_weight", "2:1")))));
}
@Test