You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2022/01/14 22:06:14 UTC

[shardingsphere] branch master updated: Remove useless DataSourcePoolCreatorUtil (#14794)

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

menghaoran 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 1c84492  Remove useless DataSourcePoolCreatorUtil (#14794)
1c84492 is described below

commit 1c844923a9f1da68f8d06934e3ee325f06717bc3
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Jan 15 06:05:01 2022 +0800

    Remove useless DataSourcePoolCreatorUtil (#14794)
    
    * Remove useless DataSourcePoolCreatorUtil
    
    * Move test cases
    
    * Fix test cases
---
 .../pool/creator/DataSourcePoolCreatorUtil.java    | 56 --------------
 .../pool/creator/DataSourceReflection.java         |  4 +-
 .../props/DataSourcePropertiesCreator.java         | 11 +++
 .../DataSourcePoolCreatorTest.java}                | 51 +++++++++++--
 .../creator/DataSourcePoolCreatorUtilTest.java     | 57 --------------
 ...Data.java => MockedDataSourcePoolMetaData.java} | 21 +++--
 .../impl/HikariDataSourcePoolCreatorTest.java      | 89 ----------------------
 .../props/DataSourcePropertiesCreatorTest.java     | 19 ++++-
 ...datasource.pool.metadata.DataSourcePoolMetaData |  2 +-
 .../core/connection/ConnectionManagerTest.java     |  9 ++-
 .../mode/manager/ContextManager.java               |  4 +-
 .../cluster/ClusterContextManagerBuilder.java      |  3 +-
 .../StandaloneContextManagerBuilder.java           |  3 +-
 .../rql/resource/DataSourceQueryResultSet.java     |  4 +-
 .../shardingsphere/test/mock/MockedDataSource.java |  3 +
 15 files changed, 100 insertions(+), 236 deletions(-)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
deleted file mode 100644
index 7461fd4..0000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtil.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.config.datasource.pool.creator;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
-import org.apache.shardingsphere.infra.config.datasource.props.DataSourcePropertiesCreator;
-
-import javax.sql.DataSource;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-/**
- * Data source converter.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DataSourcePoolCreatorUtil {
-    
-    /**
-     * Get data source map.
-     *
-     * @param dataSourcePropsMap data source properties map
-     * @return data source map
-     */
-    public static Map<String, DataSource> getDataSourceMap(final Map<String, DataSourceProperties> dataSourcePropsMap) {
-        return dataSourcePropsMap.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> DataSourcePoolCreator.create(entry.getValue()), (a, b) -> b, LinkedHashMap::new));
-    }
-    
-    /**
-     * Get data source configuration map.
-     *
-     * @param dataSourceMap data source map
-     * @return data source properties map
-     */
-    public static Map<String, DataSourceProperties> getDataSourcePropertiesMap(final Map<String, DataSource> dataSourceMap) {
-        return dataSourceMap.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> DataSourcePropertiesCreator.create(entry.getValue()), (a, b) -> b, LinkedHashMap::new));
-    }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourceReflection.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourceReflection.java
index fc76f98..7e159ab 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourceReflection.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourceReflection.java
@@ -160,7 +160,7 @@ public final class DataSourceReflection {
         if (null == dataSourcePropsFieldName || null == jdbcUrlFieldName) {
             return;
         }
-        Properties targetDataSourceProps = getDataSourcePropertiesFieldName(dataSourcePropsFieldName);
+        Properties targetDataSourceProps = getDataSourceProperties(dataSourcePropsFieldName);
         String jdbcUrl = getJdbcUrl(jdbcUrlFieldName);
         DataSourceMetaData dataSourceMetaData = DatabaseTypeRegistry.getDatabaseTypeByURL(jdbcUrl).getDataSourceMetaData(jdbcUrl, null);
         Properties queryProps = dataSourceMetaData.getQueryProperties();
@@ -178,7 +178,7 @@ public final class DataSourceReflection {
     }
     
     @SneakyThrows(ReflectiveOperationException.class)
-    private Properties getDataSourcePropertiesFieldName(final String dataSourcePropsFieldName) {
+    private Properties getDataSourceProperties(final String dataSourcePropsFieldName) {
         return (Properties) dataSource.getClass().getMethod(getGetterMethodName(dataSourcePropsFieldName)).invoke(dataSource);
     }
     
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
index b07ece9..d4d1d94 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreator.java
@@ -27,6 +27,7 @@ import javax.sql.DataSource;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 /**
  * Data source properties creator.
@@ -36,6 +37,16 @@ public final class DataSourcePropertiesCreator {
     
     /**
      * Create data source properties.
+     *
+     * @param dataSourceMap data source map
+     * @return created data source properties
+     */
+    public static Map<String, DataSourceProperties> create(final Map<String, DataSource> dataSourceMap) {
+        return dataSourceMap.entrySet().stream().collect(Collectors.toMap(Entry::getKey, entry -> create(entry.getValue()), (a, b) -> b, LinkedHashMap::new));
+    }
+    
+    /**
+     * Create data source properties.
      * 
      * @param dataSource data source
      * @return created data source properties
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorTest.java
similarity index 53%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorTest.java
index 0a5362b..40d839b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/DefaultDataSourcePoolCreatorTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorTest.java
@@ -15,22 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.infra.config.datasource.pool.metadata.impl;
+package org.apache.shardingsphere.infra.config.datasource.pool.creator;
 
+import com.zaxxer.hikari.HikariDataSource;
 import org.apache.commons.dbcp2.BasicDataSource;
-import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
 import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.junit.Test;
 
+import javax.sql.CommonDataSource;
 import javax.sql.DataSource;
 import java.util.HashMap;
 import java.util.Map;
 
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertThat;
 
-public final class DefaultDataSourcePoolCreatorTest {
+public final class DataSourcePoolCreatorTest {
     
     @Test
     public void assertCreateMap() {
@@ -38,18 +41,18 @@ public final class DefaultDataSourcePoolCreatorTest {
         dataSourcePropsMap.put("foo_ds", createDataSourceProperties());
         Map<String, DataSource> actual = DataSourcePoolCreator.create(dataSourcePropsMap);
         assertThat(actual.size(), is(1));
-        assertDataSource((BasicDataSource) actual.get("foo_ds"));
+        assertDataSource((MockedDataSource) actual.get("foo_ds"));
     }
     
     @Test
     public void assertCreate() {
-        BasicDataSource actual = (BasicDataSource) DataSourcePoolCreator.create(createDataSourceProperties());
+        MockedDataSource actual = (MockedDataSource) DataSourcePoolCreator.create(createDataSourceProperties());
         assertThat(actual.getDriverClassName(), is(MockedDataSource.class.getName()));
         assertDataSource(actual);
     }
     
     private DataSourceProperties createDataSourceProperties() {
-        DataSourceProperties result = new DataSourceProperties(BasicDataSource.class.getName());
+        DataSourceProperties result = new DataSourceProperties(MockedDataSource.class.getName());
         result.getProps().put("driverClassName", MockedDataSource.class.getName());
         result.getProps().put("url", "jdbc:mock://127.0.0.1/foo_ds");
         result.getProps().put("username", "root");
@@ -57,9 +60,43 @@ public final class DefaultDataSourcePoolCreatorTest {
         return result;
     }
     
-    private void assertDataSource(final BasicDataSource actual) {
+    private void assertDataSource(final MockedDataSource actual) {
         assertThat(actual.getUrl(), is("jdbc:mock://127.0.0.1/foo_ds"));
         assertThat(actual.getUsername(), is("root"));
         assertThat(actual.getPassword(), is("root"));
+        assertThat(actual.getMaxPoolSize(), is(100));
+        assertNull(actual.getMinPoolSize());
+    }
+    
+    @Test
+    public void assertCreateDefaultDataSource() {
+        assertThat(DataSourcePoolCreator.create(createDefaultDataSourceProperties()), instanceOf(CommonDataSource.class));
+    }
+    
+    private DataSourceProperties createDefaultDataSourceProperties() {
+        Map<String, Object> props = new HashMap<>();
+        props.put("driverClassName", MockedDataSource.class.getName());
+        props.put("url", "jdbc:mock://127.0.0.1/foo_ds");
+        props.put("username", "root");
+        props.put("password", "root");
+        DataSourceProperties result = new DataSourceProperties(BasicDataSource.class.getName());
+        result.getProps().putAll(props);
+        return result;
+    }
+    
+    @Test
+    public void assertCreateHikariDataSource() {
+        assertThat(DataSourcePoolCreator.create(createHikariDataSourceProperties()), instanceOf(HikariDataSource.class));
+    }
+    
+    private DataSourceProperties createHikariDataSourceProperties() {
+        Map<String, Object> props = new HashMap<>();
+        props.put("jdbcUrl", "jdbc:mock://127.0.0.1/foo_ds");
+        props.put("driverClassName", MockedDataSource.class.getName());
+        props.put("username", "root");
+        props.put("password", "root");
+        DataSourceProperties result = new DataSourceProperties(HikariDataSource.class.getName());
+        result.getProps().putAll(props);
+        return result;
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
deleted file mode 100644
index 7dcfd69..0000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/creator/DataSourcePoolCreatorUtilTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.config.datasource.pool.creator;
-
-import org.apache.commons.dbcp2.BasicDataSource;
-import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
-import org.junit.Test;
-
-import javax.sql.DataSource;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-
-public final class DataSourcePoolCreatorUtilTest {
-    
-    @Test
-    public void assertGetDataSourcePropertiesMap() {
-        Map<String, DataSourceProperties> actual = DataSourcePoolCreatorUtil.getDataSourcePropertiesMap(createDataSourceMap());
-        assertThat(actual.size(), is(2));
-        assertNotNull(actual.get("ds_0"));
-        assertNotNull(actual.get("ds_1"));
-    }
-    
-    private Map<String, DataSource> createDataSourceMap() {
-        Map<String, DataSource> result = new LinkedHashMap<>(2, 1);
-        result.put("ds_0", createDataSource("ds_0"));
-        result.put("ds_1", createDataSource("ds_1"));
-        return result;
-    }
-    
-    private DataSource createDataSource(final String name) {
-        BasicDataSource result = new BasicDataSource();
-        result.setDriverClassName("com.mysql.jdbc.Driver");
-        result.setUrl("jdbc:mysql://localhost:3306/" + name);
-        result.setUsername("root");
-        result.setPassword("root");
-        return result;
-    }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/FixtureDataSourcePoolMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/MockedDataSourcePoolMetaData.java
similarity index 73%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/FixtureDataSourcePoolMetaData.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/MockedDataSourcePoolMetaData.java
index 3ba33cf..4fa5724 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/FixtureDataSourcePoolMetaData.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/fixture/MockedDataSourcePoolMetaData.java
@@ -23,38 +23,43 @@ import org.apache.shardingsphere.test.mock.MockedDataSource;
 import java.util.HashMap;
 import java.util.Map;
 
-public final class FixtureDataSourcePoolMetaData implements DataSourcePoolMetaData {
+public final class MockedDataSourcePoolMetaData implements DataSourcePoolMetaData {
     
     @Override
     public Map<String, Object> getDefaultProperties() {
-        return null;
+        Map<String, Object> result = new HashMap<>(1, 1);
+        result.put("maxPoolSize", 100);
+        return result;
     }
     
     @Override
     public Map<String, Object> getInvalidProperties() {
         Map<String, Object> result = new HashMap<>(2, 1);
-        result.put("minimumIdle", -1);
-        result.put("maximumPoolSize", -1);
+        result.put("maxPoolSize", -1);
+        result.put("minPoolSize", -1);
         return result;
     }
     
     @Override
     public Map<String, String> getPropertySynonyms() {
-        return null;
+        Map<String, String> result = new HashMap<>(2, 1);
+        result.put("maxPoolSize", "maxPoolSize");
+        result.put("minPoolSize", "minPoolSize");
+        return result;
     }
     
     @Override
     public String getJdbcUrlFieldName() {
-        return null;
+        return "url";
     }
     
     @Override
     public String getJdbcUrlPropertiesFieldName() {
-        return null;
+        return "jdbcUrlProperties";
     }
     
     @Override
     public String getType() {
-        return MockedDataSource.class.getCanonicalName();
+        return MockedDataSource.class.getName();
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/HikariDataSourcePoolCreatorTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/HikariDataSourcePoolCreatorTest.java
deleted file mode 100644
index caf9c3b..0000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/pool/metadata/impl/HikariDataSourcePoolCreatorTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.config.datasource.pool.metadata.impl;
-
-import com.zaxxer.hikari.HikariDataSource;
-import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
-import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
-import org.apache.shardingsphere.test.mock.MockedDataSource;
-import org.junit.Test;
-
-import javax.sql.DataSource;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class HikariDataSourcePoolCreatorTest {
-    
-    @Test
-    public void assertCreate() {
-        DataSource dataSource = DataSourcePoolCreator.create(createDataSourceProperties());
-        assertThat(dataSource, instanceOf(HikariDataSource.class));
-        HikariDataSource hikariDataSource = (HikariDataSource) dataSource;
-        assertThat(hikariDataSource.getJdbcUrl(), is("jdbc:mysql://127.0.0.1/foo_ds"));
-        assertThat(hikariDataSource.getDriverClassName(), is(MockedDataSource.class.getName()));
-        assertThat(hikariDataSource.getUsername(), is("root"));
-        assertThat(hikariDataSource.getPassword(), is("root"));
-        assertThat(hikariDataSource.getMaximumPoolSize(), is(10));
-        assertThat(hikariDataSource.getMinimumIdle(), is(1));
-        assertProperties(hikariDataSource.getDataSourceProperties());
-    }
-    
-    private DataSourceProperties createDataSourceProperties() {
-        Map<String, Object> props = new HashMap<>();
-        props.put("jdbcUrl", "jdbc:mysql://127.0.0.1/foo_ds");
-        props.put("driverClassName", MockedDataSource.class.getName());
-        props.put("username", "root");
-        props.put("password", "root");
-        props.put("maxPoolSize", 10);
-        props.put("minPoolSize", 1);
-        props.put("dataSourceProperties", createJdbcUrlProperties());
-        DataSourceProperties result = new DataSourceProperties(HikariDataSource.class.getName());
-        result.getProps().putAll(props);
-        return result;
-    }
-    
-    private Properties createJdbcUrlProperties() {
-        Properties result = new Properties();
-        result.put("prepStmtCacheSqlLimit", 1024);
-        result.put("cachePrepStmts", true);
-        result.put("prepStmtCacheSize", 1000);
-        return result;
-    }
-    
-    private void assertProperties(final Properties actual) {
-        assertThat(actual.get("prepStmtCacheSqlLimit"), is(1024));
-        assertThat(actual.get("cachePrepStmts"), is(true));
-        assertThat(actual.get("prepStmtCacheSize"), is(1000));
-        assertThat(actual.get("useServerPrepStmts"), is(Boolean.TRUE.toString()));
-        assertThat(actual.get("useLocalSessionState"), is(Boolean.TRUE.toString()));
-        assertThat(actual.get("rewriteBatchedStatements"), is(Boolean.TRUE.toString()));
-        assertThat(actual.get("cacheResultSetMetadata"), is(Boolean.FALSE.toString()));
-        assertThat(actual.get("cacheServerConfiguration"), is(Boolean.TRUE.toString()));
-        assertThat(actual.get("elideSetAutoCommits"), is(Boolean.TRUE.toString()));
-        assertThat(actual.get("maintainTimeStats"), is(Boolean.FALSE.toString()));
-        assertThat(actual.get("netTimeoutForStreamingResults"), is("0"));
-        assertThat(actual.get("tinyInt1isBit"), is(Boolean.FALSE.toString()));
-        assertThat(actual.get("useSSL"), is(Boolean.FALSE.toString()));
-        assertThat(actual.get("serverTimezone"), is("UTC"));
-    }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
index 3e5d652..f1120b7 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/config/datasource/props/DataSourcePropertiesCreatorTest.java
@@ -21,6 +21,8 @@ import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.junit.Test;
 
 import javax.sql.DataSource;
+import java.util.HashMap;
+import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
@@ -28,14 +30,23 @@ import static org.junit.Assert.assertThat;
 public final class DataSourcePropertiesCreatorTest {
     
     @Test
+    public void assertCreateMap() {
+        Map<String, DataSource> dataSourceMap = new HashMap<>(2, 1);
+        dataSourceMap.put("foo_ds", createDataSource());
+        Map<String, DataSourceProperties> actual = DataSourcePropertiesCreator.create(dataSourceMap);
+        assertThat(actual.size(), is(1));
+        assertThat(actual.get("foo_ds"), is(createDataSourceProperties()));
+    }
+    
+    @Test
     public void assertCreate() {
         assertThat(DataSourcePropertiesCreator.create(createDataSource()), is(createDataSourceProperties()));
     }
     
     private DataSource createDataSource() {
         MockedDataSource result = new MockedDataSource();
-        result.setDriverClassName("org.h2.Driver");
-        result.setUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL");
+        result.setDriverClassName(MockedDataSource.class.getName());
+        result.setUrl("jdbc:mock://127.0.0.1/foo_ds");
         result.setUsername("root");
         result.setPassword("root");
         return result;
@@ -43,8 +54,8 @@ public final class DataSourcePropertiesCreatorTest {
     
     private DataSourceProperties createDataSourceProperties() {
         DataSourceProperties result = new DataSourceProperties(MockedDataSource.class.getName());
-        result.getProps().put("driverClassName", "org.h2.Driver");
-        result.getProps().put("url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL");
+        result.getProps().put("driverClassName", MockedDataSource.class.getName());
+        result.getProps().put("url", "jdbc:mock://127.0.0.1/foo_ds");
         result.getProps().put("username", "root");
         result.getProps().put("password", "root");
         result.getProps().put("maximumPoolSize", "-1");
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData
index 209599a..22f1d0d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.config.datasource.pool.metadata.DataSourcePoolMetaData
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-org.apache.shardingsphere.infra.config.datasource.pool.metadata.fixture.FixtureDataSourcePoolMetaData
+org.apache.shardingsphere.infra.config.datasource.pool.metadata.fixture.MockedDataSourcePoolMetaData
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
index ffa0871..304cdbb 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ConnectionManagerTest.java
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.infra.instance.definition.InstanceType;
 import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.persist.MetaDataPersistService;
+import org.apache.shardingsphere.test.mock.MockedDataSource;
 import org.apache.shardingsphere.traffic.rule.TrafficRule;
 import org.apache.shardingsphere.transaction.rule.TransactionRule;
 import org.junit.After;
@@ -89,9 +90,9 @@ public final class ConnectionManagerTest {
     }
     
     private Map<String, DataSource> mockTrafficDataSourceMap() {
-        Map<String, DataSource> trafficDataSourceMap = new LinkedHashMap<>();
-        trafficDataSourceMap.put("127.0.0.1@3307", mock(DataSource.class));
-        return trafficDataSourceMap;
+        Map<String, DataSource> result = new LinkedHashMap<>();
+        result.put("127.0.0.1@3307", new MockedDataSource());
+        return result;
     }
     
     private MetaDataPersistService mockMetaDataPersistService() {
@@ -127,7 +128,7 @@ public final class ConnectionManagerTest {
     
     private Map<String, DataSource> mockDataSourceMap() throws SQLException {
         Map<String, DataSource> result = new HashMap<>(2, 1);
-        result.put("ds", mock(DataSource.class, RETURNS_DEEP_STUBS));
+        result.put("ds", new MockedDataSource());
         DataSource invalidDataSource = mock(DataSource.class);
         when(invalidDataSource.getConnection()).thenThrow(new SQLException());
         result.put("invalid_ds", invalidDataSource);
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
index 29203d2..a9873e2 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManager.java
@@ -22,8 +22,8 @@ import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
-import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
 import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
+import org.apache.shardingsphere.infra.config.datasource.props.DataSourcePropertiesCreator;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.federation.optimizer.context.planner.OptimizerPlannerContextFactory;
@@ -375,7 +375,7 @@ public final class ContextManager implements AutoCloseable {
     }
     
     private boolean isModifiedDataSource(final Map<String, DataSource> originalDataSources, final String dataSourceName, final DataSourceProperties dataSourceProps) {
-        DataSourceProperties originalDataSourceProps = DataSourcePoolCreatorUtil.getDataSourcePropertiesMap(originalDataSources).get(dataSourceName);
+        DataSourceProperties originalDataSourceProps = DataSourcePropertiesCreator.create(originalDataSources).get(dataSourceName);
         return null != originalDataSourceProps && !dataSourceProps.equals(originalDataSourceProps);
     }
     
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
index 9e04a54..4e9d900 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-cluster-mode/shardingsphere-cluster-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/ClusterContextManagerBuilder.java
@@ -22,7 +22,6 @@ import com.google.common.base.Strings;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
-import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
 import org.apache.shardingsphere.infra.config.datasource.pool.destroyer.DataSourcePoolDestroyerFactory;
 import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import org.apache.shardingsphere.infra.config.datasource.props.DataSourcePropertiesCreator;
@@ -159,7 +158,7 @@ public final class ClusterContextManagerBuilder implements ContextManagerBuilder
     private Map<String, Map<String, DataSourceProperties>> getDataSourcePropertiesMap(final Map<String, Map<String, DataSource>> dataSourcesMap) {
         Map<String, Map<String, DataSourceProperties>> result = new LinkedHashMap<>(dataSourcesMap.size(), 1);
         for (Entry<String, Map<String, DataSource>> entry : dataSourcesMap.entrySet()) {
-            result.put(entry.getKey(), DataSourcePoolCreatorUtil.getDataSourcePropertiesMap(entry.getValue()));
+            result.put(entry.getKey(), DataSourcePropertiesCreator.create(entry.getValue()));
         }
         return result;
     }
diff --git a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
index 35fac74..db20421 100644
--- a/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-type/shardingsphere-standalone-mode/shardingsphere-standalone-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/standalone/StandaloneContextManagerBuilder.java
@@ -21,7 +21,6 @@ import com.google.common.base.Strings;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreator;
-import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
 import org.apache.shardingsphere.infra.config.datasource.pool.destroyer.DataSourcePoolDestroyerFactory;
 import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
 import org.apache.shardingsphere.infra.config.datasource.props.DataSourcePropertiesCreator;
@@ -112,7 +111,7 @@ public final class StandaloneContextManagerBuilder implements ContextManagerBuil
     private Map<String, Map<String, DataSourceProperties>> getDataSourcePropertiesMaps(final Map<String, Map<String, DataSource>> dataSourcesMap) {
         Map<String, Map<String, DataSourceProperties>> result = new LinkedHashMap<>(dataSourcesMap.size(), 1);
         for (Entry<String, Map<String, DataSource>> entry : dataSourcesMap.entrySet()) {
-            result.put(entry.getKey(), DataSourcePoolCreatorUtil.getDataSourcePropertiesMap(entry.getValue()));
+            result.put(entry.getKey(), DataSourcePropertiesCreator.create(entry.getValue()));
         }
         return result;
     }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/DataSourceQueryResultSet.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/DataSourceQueryResultSet.java
index 1fc9113..c4c64c7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/DataSourceQueryResultSet.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/rql/resource/DataSourceQueryResultSet.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.proxy.backend.text.distsql.rql.resource;
 import com.google.gson.Gson;
 import org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
 import org.apache.shardingsphere.infra.config.datasource.props.DataSourceProperties;
-import org.apache.shardingsphere.infra.config.datasource.pool.creator.DataSourcePoolCreatorUtil;
+import org.apache.shardingsphere.infra.config.datasource.props.DataSourcePropertiesCreator;
 import org.apache.shardingsphere.infra.database.metadata.DataSourceMetaData;
 import org.apache.shardingsphere.infra.distsql.query.DistSQLResultSet;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
@@ -53,7 +53,7 @@ public final class DataSourceQueryResultSet implements DistSQLResultSet {
         Optional<MetaDataPersistService> persistService = ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaDataPersistService();
         dataSourcePropsMap = persistService.isPresent()
                 ? persistService.get().getDataSourceService().load(metaData.getName())
-                : DataSourcePoolCreatorUtil.getDataSourcePropertiesMap(metaData.getResource().getDataSources());
+                : DataSourcePropertiesCreator.create(metaData.getResource().getDataSources());
         dataSourceNames = dataSourcePropsMap.keySet().iterator();
     }
     
diff --git a/shardingsphere-test/shardingsphere-test-common/src/main/java/org/apache/shardingsphere/test/mock/MockedDataSource.java b/shardingsphere-test/shardingsphere-test-common/src/main/java/org/apache/shardingsphere/test/mock/MockedDataSource.java
index a55994f..0d6adf2 100644
--- a/shardingsphere-test/shardingsphere-test-common/src/main/java/org/apache/shardingsphere/test/mock/MockedDataSource.java
+++ b/shardingsphere-test/shardingsphere-test-common/src/main/java/org/apache/shardingsphere/test/mock/MockedDataSource.java
@@ -25,6 +25,7 @@ import java.io.PrintWriter;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.List;
+import java.util.Properties;
 import java.util.logging.Logger;
 
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -53,6 +54,8 @@ public final class MockedDataSource implements DataSource {
     
     private List<String> connectionInitSqls;
     
+    private Properties jdbcUrlProperties;
+    
     @SuppressWarnings("MagicConstant")
     @Override
     public Connection getConnection() throws SQLException {