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 99186f9bc7e Add test cases on PropertiesBuilder (#36424)
99186f9bc7e is described below

commit 99186f9bc7e9f0f9117a0f2d0ecd52d99c29c5aa
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Aug 29 00:06:37 2025 +0800

    Add test cases on PropertiesBuilder (#36424)
    
    * Add test cases on PropertiesBuilder
    
    * Add test cases on PropertiesBuilder
---
 .../infra/util/props/PropertiesBuilderTest.java    | 43 ++++++++++++++++++++++
 .../variable/SetDistVariableExecutorTest.java      |  9 ++---
 2 files changed, 46 insertions(+), 6 deletions(-)

diff --git 
a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/props/PropertiesBuilderTest.java
 
b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/props/PropertiesBuilderTest.java
new file mode 100644
index 00000000000..55e710a4300
--- /dev/null
+++ 
b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/props/PropertiesBuilderTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.infra.util.props.PropertiesBuilder.Property;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Properties;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class PropertiesBuilderTest {
+    
+    @SuppressWarnings("UseOfPropertiesAsHashtable")
+    @Test
+    void assertBuild() {
+        Properties props = PropertiesBuilder.build(new Property("string_key", 
"string_value"), new Property("int_key", 1), new Property("list_key", 
Arrays.asList(10, 11)));
+        assertThat(props.size(), is(3));
+        assertThat(props.getProperty("string_key"), is("string_value"));
+        assertNull(props.getProperty("int_key"));
+        assertThat(props.get("int_key"), is(1));
+        assertNull(props.getProperty("list_key"));
+        assertThat(props.get("list_key"), is(Arrays.asList(10, 11)));
+    }
+}
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
index b515b726845..1a379481675 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/variable/SetDistVariableExecutorTest.java
@@ -58,8 +58,7 @@ class SetDistVariableExecutorTest {
         SetDistVariableStatement statement = new 
SetDistVariableStatement("proxy_frontend_flush_threshold", "1024");
         ContextManager contextManager = mockContextManager();
         executor.executeUpdate(statement, contextManager);
-        Object actualValue = 
contextManager.getMetaDataContexts().getMetaData().getProps().getProps().get("proxy-frontend-flush-threshold");
-        assertThat(actualValue.toString(), is("1024"));
+        
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getProps().getProperty("proxy-frontend-flush-threshold"),
 is("1024"));
         
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_FRONTEND_FLUSH_THRESHOLD),
 is(1024));
     }
     
@@ -68,8 +67,7 @@ class SetDistVariableExecutorTest {
         SetDistVariableStatement statement = new 
SetDistVariableStatement("proxy_meta_data_collector_enabled", "false");
         ContextManager contextManager = mockContextManager();
         executor.executeUpdate(statement, contextManager);
-        Object actualValue = 
contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getProps().get("proxy-meta-data-collector-enabled");
-        assertThat(actualValue.toString(), is("false"));
+        
assertThat(contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getProps().getProperty("proxy-meta-data-collector-enabled"),
 is(Boolean.FALSE.toString()));
         
assertThat(contextManager.getMetaDataContexts().getMetaData().getTemporaryProps().getValue(TemporaryConfigurationPropertyKey.PROXY_META_DATA_COLLECTOR_ENABLED),
 is(false));
     }
     
@@ -78,8 +76,7 @@ class SetDistVariableExecutorTest {
         SetDistVariableStatement statement = new 
SetDistVariableStatement("proxy_frontend_database_protocol_type", "Fixture");
         ContextManager contextManager = mockContextManager();
         executor.executeUpdate(statement, contextManager);
-        Object actualValue = 
contextManager.getMetaDataContexts().getMetaData().getProps().getProps().get("proxy-frontend-database-protocol-type");
-        assertThat(actualValue.toString(), is("FIXTURE"));
+        
assertThat(contextManager.getMetaDataContexts().getMetaData().getProps().getProps().getProperty("proxy-frontend-database-protocol-type"),
 is("FIXTURE"));
         assertThat(((DatabaseType) 
contextManager.getMetaDataContexts().getMetaData().getProps().getValue(ConfigurationPropertyKey.PROXY_FRONTEND_DATABASE_PROTOCOL_TYPE)).getType(),
 is("FIXTURE"));
     }
     

Reply via email to