daleyzou opened a new issue, #27988:
URL: https://github.com/apache/shardingsphere/issues/27988

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   -- 5.4.1-SNAPSHOT
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   -- ShardingSphere-JDBC
   
   ### Expected behavior
   -- Pass all single tests
   
   ### Actual behavior
   -- actual.getProperties() cannot pass, no corresponding value is set
   ### Reason analyze (If you can)
   in c3p0, class for AbstractComboPooledDataSource, The method of setting 
properties is as follows
   `
   public Properties getProperties() {
           return this.dmds.getProperties();
       }
   
       public void setProperties(Properties properties) {
           if (diff(this.dmds.getProperties(), properties)) {
               this.dmds.setProperties(properties);
               this.resetPoolManager(false);
           }
   
       }
   `
   If we need to get and set the value of properties through reflection, we 
need to call these two methods through reflection instead of directly setting 
the properties attribute.
   
   
   ### Example codes for reproduce this issue (such as a github link).
   `
   
   class C3P0DataSourcePoolCreatorTest {
       @Test
       void assertCreateDataSource() {
           ComboPooledDataSource actual = (ComboPooledDataSource) 
DataSourcePoolCreator.create(new 
DataSourceProperties(ComboPooledDataSource.class.getName(), 
createDataSourceProperties()));
           assertThat(actual.getJdbcUrl(), is("jdbc:mock://127.0.0.1/foo_ds"));
            assertThat(actual.getUser(), is("root"));
            assertThat(actual.getPassword(), is("root"));
            // c3p0 will automatically add username and password to properties  
{@see DriverManagerDataSource#setUser}
           assertThat(actual.getProperties(), is(
                   PropertiesBuilder.build(new 
PropertiesBuilder.Property("foo", "foo_value"), new 
PropertiesBuilder.Property("bar", "bar_value"),
                           new PropertiesBuilder.Property("password", "root"), 
new PropertiesBuilder.Property("user", "root")
                           )));
       }
   
       private Map<String, Object> createDataSourceProperties() {
           Map<String, Object> result = new HashMap<>();
           result.put("url", "jdbc:mock://127.0.0.1/foo_ds");
           result.put("driverClassName", MockedDataSource.class.getName());
           result.put("username", "root");
           result.put("password", "root");
           result.put("properties", PropertiesBuilder.build(new 
PropertiesBuilder.Property("foo", "foo_value"),new 
PropertiesBuilder.Property("bar", "bar_value")));
           return result;
       }
   `


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to