This is an automated email from the ASF dual-hosted git repository.

sunnianjun 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 83b2554c6c1 Add PropertiesUtils (#30597)
83b2554c6c1 is described below

commit 83b2554c6c1323ad712a7f8cc979ddcc1de17bf1
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Fri Mar 22 01:00:21 2024 +0800

    Add PropertiesUtils (#30597)
    
    * Refactor AlgorithmDistSQLConverter
    
    * Refactor AlgorithmDistSQLConverter
    
    * Add PropertiesUtils
    
    * Add PropertiesUtilsTest
    
    * Refactor PropertiesUtils
    
    * Refactor PropertiesUtils
---
 .../infra/util/props/PropertiesUtils.java          |  4 +-
 .../infra/util/props/PropertiesUtilsTest.java      | 45 ++++++++++++++++++++++
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/props/PropertiesUtils.java
 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/props/PropertiesUtils.java
index 80fd978eecd..03d52080b4c 100644
--- 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/props/PropertiesUtils.java
+++ 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/props/PropertiesUtils.java
@@ -31,10 +31,10 @@ import java.util.TreeMap;
 public final class PropertiesUtils {
     
     /**
-     * Get algorithm properties.
+     * Convert properties To string.
      *
      * @param props properties
-     * @return algorithm properties
+     * @return properties string
      */
     @SuppressWarnings({"unchecked", "rawtypes"})
     public static String toString(final Properties props) {
diff --git 
a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/props/PropertiesUtilsTest.java
 
b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/props/PropertiesUtilsTest.java
new file mode 100644
index 00000000000..bfbf51a9318
--- /dev/null
+++ 
b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/props/PropertiesUtilsTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.util.props;
+
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import org.junit.jupiter.api.Test;
+
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class PropertiesUtilsTest {
+    
+    @Test
+    void assertToStringWithEmptyProperties() {
+        assertThat(PropertiesUtils.toString(new Properties()), is(""));
+    }
+    
+    @Test
+    void assertToStringWithSingleKey() {
+        assertThat(PropertiesUtils.toString(PropertiesBuilder.build(new 
Property("key", "value"))), is("'key'='value'"));
+    }
+    
+    @Test
+    void assertToStringWithMultipleKeys() {
+        assertThat(PropertiesUtils.toString(PropertiesBuilder.build(new 
Property("key1", "value1"), new Property("key2", "value2"))), 
is("'key1'='value1', 'key2'='value2'"));
+    }
+}

Reply via email to