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 e87097a7148 Refactor parse of properties (#29043)
e87097a7148 is described below

commit e87097a7148e1dde025d2aa7c8c4c20a7e3f1e9a
Author: ChenJiaHao <[email protected]>
AuthorDate: Thu Nov 16 10:40:20 2023 +0800

    Refactor parse of properties (#29043)
---
 .../distsql/handler/query/ShowEncryptRuleExecutorTest.java        | 2 +-
 .../mask/distsql/handler/query/ShowMaskRuleExecutorTest.java      | 2 +-
 .../handler/query/ShowReadwriteSplittingRuleExecutorTest.java     | 4 ++--
 .../distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java     | 2 +-
 .../shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java    | 2 +-
 .../shadow/distsql/query/ShowShadowRuleExecutorTest.java          | 4 ++--
 .../sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java | 2 +-
 .../sharding/distsql/query/ShowShardingTableRuleExecutorTest.java | 6 +++---
 .../distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java   | 2 +-
 .../distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java | 2 +-
 .../apache/shardingsphere/infra/props/PropertiesConverter.java    | 4 ++--
 .../shardingsphere/infra/props/PropertiesConverterTest.java       | 4 ++--
 .../distsql/handler/query/ShowTrafficRuleExecutorTest.java        | 8 ++++----
 .../distsql/handler/query/ShowTransactionRuleExecutorTest.java    | 4 ++--
 .../handler/update/AlterTransactionRuleStatementUpdaterTest.java  | 4 ++--
 15 files changed, 26 insertions(+), 26 deletions(-)

diff --git 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
index 02d4d7ff7e3..a334774dc1d 100644
--- 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
+++ 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/query/ShowEncryptRuleExecutorTest.java
@@ -58,7 +58,7 @@ class ShowEncryptRuleExecutorTest {
         assertThat(row.getCell(4), is("user_assisted"));
         assertThat(row.getCell(5), is("user_like"));
         assertThat(row.getCell(6), is("md5"));
-        assertThat(row.getCell(7), is(""));
+        assertThat(row.getCell(7), is("{}"));
         assertThat(row.getCell(8), is(""));
         assertThat(row.getCell(9), is(""));
         assertThat(row.getCell(10), is(""));
diff --git 
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
 
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
index a6e59fc54e5..096704a189f 100644
--- 
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
+++ 
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/query/ShowMaskRuleExecutorTest.java
@@ -55,7 +55,7 @@ class ShowMaskRuleExecutorTest {
         assertThat(row.getCell(1), is("t_mask"));
         assertThat(row.getCell(2), is("user_id"));
         assertThat(row.getCell(3), is("md5"));
-        assertThat(row.getCell(4), is(""));
+        assertThat(row.getCell(4), is("{}"));
     }
     
     @Test
diff --git 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
index f13e12bc5ea..9e7b0db50cf 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ShowReadwriteSplittingRuleExecutorTest.java
@@ -74,7 +74,7 @@ class ShowReadwriteSplittingRuleExecutorTest {
         assertThat(row.getCell(3), is("ds_slave_0,ds_slave_1"));
         assertThat(row.getCell(4), is("DYNAMIC"));
         assertThat(row.getCell(5), is("random"));
-        assertThat(row.getCell(6), is("read_weight=2:1"));
+        assertThat(row.getCell(6), is("{\"read_weight\":\"2:1\"}"));
     }
     
     @Test
@@ -94,7 +94,7 @@ class ShowReadwriteSplittingRuleExecutorTest {
         assertThat(row.getCell(3), is("ds_slave_0,ds_slave_1"));
         assertThat(row.getCell(4), is("DYNAMIC"));
         assertThat(row.getCell(5), is("random"));
-        assertThat(row.getCell(6), is("read_weight=2:1"));
+        assertThat(row.getCell(6), is("{\"read_weight\":\"2:1\"}"));
     }
     
     private Map<String, Object> createExportedData() {
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java
index 6b3b9b7df39..ca468726974 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowDefaultShadowAlgorithmExecutorTest.java
@@ -53,7 +53,7 @@ class ShowDefaultShadowAlgorithmExecutorTest {
         LocalDataQueryResultRow row = iterator.next();
         assertThat(row.getCell(1), is("shadowAlgorithmName"));
         assertThat(row.getCell(2), is("sql_hint"));
-        assertThat(row.getCell(3), is("foo=bar"));
+        assertThat(row.getCell(3), is("{\"foo\":\"bar\"}"));
     }
     
     @Test
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java
index b2a0bd7c760..de7c4e52302 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowAlgorithmsExecutorTest.java
@@ -53,7 +53,7 @@ class ShowShadowAlgorithmsExecutorTest {
         LocalDataQueryResultRow row = iterator.next();
         assertThat(row.getCell(1), is("shadowAlgorithmName"));
         assertThat(row.getCell(2), is("sql_hint"));
-        assertThat(row.getCell(3), is("foo=bar"));
+        assertThat(row.getCell(3), is("{\"foo\":\"bar\"}"));
         assertThat(row.getCell(4), is("false"));
     }
     
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
index 593cabbd9f8..91270ddc484 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/query/ShowShadowRuleExecutorTest.java
@@ -56,14 +56,14 @@ class ShowShadowRuleExecutorTest {
         assertThat(row.getCell(3), is("source"));
         assertThat(row.getCell(4), is("shadow"));
         assertThat(row.getCell(5), is("REGEX_MATCH"));
-        assertThat(row.getCell(6), is(""));
+        assertThat(row.getCell(6), is("{}"));
         row = iterator.next();
         assertThat(row.getCell(1), is("t_order_item"));
         assertThat(row.getCell(2), is("shadow_rule"));
         assertThat(row.getCell(3), is("source"));
         assertThat(row.getCell(4), is("shadow"));
         assertThat(row.getCell(5), is("REGEX_MATCH"));
-        assertThat(row.getCell(6), is(""));
+        assertThat(row.getCell(6), is("{}"));
     }
     
     @Test
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java
index 936ce1a39fc..53281fbb36d 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingAlgorithmExecutorTest.java
@@ -52,7 +52,7 @@ class ShowShardingAlgorithmExecutorTest {
         LocalDataQueryResultRow row = iterator.next();
         assertThat(row.getCell(1), is("database_inline"));
         assertThat(row.getCell(2), is("INLINE"));
-        assertThat(row.getCell(3), is("algorithm-expression=ds_${user_id % 
2}"));
+        assertThat(row.getCell(3), 
is("{\"algorithm-expression\":\"ds_${user_id % 2}\"}"));
     }
     
     private ShardingSphereDatabase mockDatabase() {
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
index 981bed6af95..63e737d7de8 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowShardingTableRuleExecutorTest.java
@@ -62,14 +62,14 @@ class ShowShardingTableRuleExecutorTest {
         assertThat(row.getCell(4), is("STANDARD"));
         assertThat(row.getCell(5), is("user_id"));
         assertThat(row.getCell(6), is("INLINE"));
-        assertThat(row.getCell(7), is("algorithm-expression=ds_${user_id % 
2}"));
+        assertThat(row.getCell(7), 
is("{\"algorithm-expression\":\"ds_${user_id % 2}\"}"));
         assertThat(row.getCell(8), is("STANDARD"));
         assertThat(row.getCell(9), is("order_id"));
         assertThat(row.getCell(10), is("INLINE"));
-        assertThat(row.getCell(11), 
is("algorithm-expression=t_order_${order_id % 2}"));
+        assertThat(row.getCell(11), 
is("{\"algorithm-expression\":\"t_order_${order_id % 2}\"}"));
         assertThat(row.getCell(12), is("order_id"));
         assertThat(row.getCell(13), is("SNOWFLAKE"));
-        assertThat(row.getCell(14), is(""));
+        assertThat(row.getCell(14), is("{}"));
         assertThat(row.getCell(15), is("DML_SHARDING_CONDITIONS"));
         assertThat(row.getCell(16), is("true"));
     }
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java
index ed8f3db4f02..fc0b7940942 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingAlgorithmsExecutorTest.java
@@ -54,7 +54,7 @@ class ShowUnusedShardingAlgorithmsExecutorTest {
         LocalDataQueryResultRow row = iterator.next();
         assertThat(row.getCell(1), is("database_inline"));
         assertThat(row.getCell(2), is("INLINE"));
-        assertThat(row.getCell(3), is("algorithm-expression=ds_${user_id % 
2}"));
+        assertThat(row.getCell(3), 
is("{\"algorithm-expression\":\"ds_${user_id % 2}\"}"));
     }
     
     @Test
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
index ea1b40a2c3a..40b33b7bce9 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/query/ShowUnusedShardingKeyGeneratorExecutorTest.java
@@ -53,7 +53,7 @@ class ShowUnusedShardingKeyGeneratorExecutorTest {
         LocalDataQueryResultRow row = iterator.next();
         assertThat(row.getCell(1), is("uuid_key_generator"));
         assertThat(row.getCell(2), is("UUID"));
-        assertThat(row.getCell(3), is(""));
+        assertThat(row.getCell(3), is("{}"));
     }
     
     @Test
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java
index 8c5cc71be29..b795f478603 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/props/PropertiesConverter.java
@@ -19,9 +19,9 @@ package org.apache.shardingsphere.infra.props;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.util.json.JsonUtils;
 
 import java.util.Properties;
-import java.util.stream.Collectors;
 
 /**
  * Properties converter.
@@ -36,6 +36,6 @@ public final class PropertiesConverter {
      * @return converted string content
      */
     public static String convert(final Properties props) {
-        return props.entrySet().stream().map(entry -> String.join("=", 
entry.getKey().toString(), 
entry.getValue().toString())).sorted().collect(Collectors.joining(","));
+        return JsonUtils.toJsonString(props);
     }
 }
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/props/PropertiesConverterTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/props/PropertiesConverterTest.java
index ecfb8872947..657899a3290 100644
--- 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/props/PropertiesConverterTest.java
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/props/PropertiesConverterTest.java
@@ -30,11 +30,11 @@ class PropertiesConverterTest {
     
     @Test
     void assertConvert() {
-        assertThat(PropertiesConverter.convert(PropertiesBuilder.build(new 
Property("foo", "foo_value"), new Property("bar", "bar_value"))), 
is("bar=bar_value,foo=foo_value"));
+        assertThat(PropertiesConverter.convert(PropertiesBuilder.build(new 
Property("foo", "foo_value"), new Property("bar", "bar_value"))), 
is("{\"bar\":\"bar_value\",\"foo\":\"foo_value\"}"));
     }
     
     @Test
     void assertConvertEmptyProperties() {
-        assertThat(PropertiesConverter.convert(new Properties()), is(""));
+        assertThat(PropertiesConverter.convert(new Properties()), is("{}"));
     }
 }
diff --git 
a/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java
 
b/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java
index 1cf1fa176bb..95f8d5aff0e 100644
--- 
a/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java
+++ 
b/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/query/ShowTrafficRuleExecutorTest.java
@@ -56,16 +56,16 @@ class ShowTrafficRuleExecutorTest {
         assertThat(row.getCell(1), is("rule_name_1"));
         assertThat(row.getCell(2), is("olap,order_by"));
         assertThat(row.getCell(3), is("SQL_MATCH"));
-        assertThat(row.getCell(4), is("sql=select * from t_order"));
+        assertThat(row.getCell(4), is("{\"sql\":\"select * from t_order\"}"));
         assertThat(row.getCell(5), is("RANDOM"));
-        assertThat(row.getCell(6), is(""));
+        assertThat(row.getCell(6), is("{}"));
         row = iterator.next();
         assertThat(row.getCell(1), is("rule_name_2"));
         assertThat(row.getCell(2), is("oltp"));
         assertThat(row.getCell(3), is("SQL_HINT"));
-        assertThat(row.getCell(4), is(""));
+        assertThat(row.getCell(4), is("{}"));
         assertThat(row.getCell(5), is("ROBIN"));
-        assertThat(row.getCell(6), is(""));
+        assertThat(row.getCell(6), is("{}"));
     }
     
     @Test
diff --git 
a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java
 
b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java
index 03846b22f5f..3853f35528f 100644
--- 
a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java
+++ 
b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/query/ShowTransactionRuleExecutorTest.java
@@ -56,8 +56,8 @@ class ShowTransactionRuleExecutorTest {
         assertThat(row.getCell(1), is(TransactionType.XA.name()));
         assertThat(row.getCell(2), is("Atomikos"));
         String props = (String) row.getCell(3);
-        assertTrue(props.contains("databaseName=jbossts"));
-        assertTrue(props.contains("host=127.0.0.1"));
+        assertTrue(props.contains("\"databaseName\":\"jbossts\""));
+        assertTrue(props.contains("\"host\":\"127.0.0.1\""));
     }
     
     @Test
diff --git 
a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleStatementUpdaterTest.java
 
b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleStatementUpdaterTest.java
index d2f84d8c143..cbf543c2e5c 100644
--- 
a/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleStatementUpdaterTest.java
+++ 
b/kernel/transaction/distsql/handler/src/test/java/org/apache/shardingsphere/transaction/distsql/handler/update/AlterTransactionRuleStatementUpdaterTest.java
@@ -54,8 +54,8 @@ class AlterTransactionRuleStatementUpdaterTest {
         assertThat(actual.getProviderType(), is("Atomikos"));
         assertFalse(actual.getProps().isEmpty());
         String props = PropertiesConverter.convert(actual.getProps());
-        assertTrue(props.contains("host=127.0.0.1"));
-        assertTrue(props.contains("databaseName=jbossts"));
+        assertTrue(props.contains("\"host\":\"127.0.0.1\""));
+        assertTrue(props.contains("\"databaseName\":\"jbossts\""));
     }
     
     @Test

Reply via email to