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 072e6868a7d Fix18823 (#18857)
072e6868a7d is described below
commit 072e6868a7d7c9d9d2cde441cb970f0b2409988f
Author: Da Xiang Huang <[email protected]>
AuthorDate: Thu Jul 7 12:19:36 2022 +0800
Fix18823 (#18857)
* fix 18823
Co-authored-by: RunQi Zhao <[email protected]>
---
.../database/type/DatabaseTypeEngineTest.java | 36 ++++++++++++----------
1 file changed, 20 insertions(+), 16 deletions(-)
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngineTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngineTest.java
index f268f4a0991..0e22d9091ca 100644
---
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngineTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/database/type/DatabaseTypeEngineTest.java
@@ -17,30 +17,29 @@
package org.apache.shardingsphere.infra.database.type;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Properties;
+import javax.sql.DataSource;
import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
import
org.apache.shardingsphere.infra.config.database.impl.DataSourceProvidedDatabaseConfiguration;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
import
org.apache.shardingsphere.infra.database.type.dialect.MariaDBDatabaseType;
import org.apache.shardingsphere.infra.database.type.dialect.MySQLDatabaseType;
+import
org.apache.shardingsphere.infra.database.type.dialect.PostgreSQLDatabaseType;
import org.apache.shardingsphere.infra.fixture.FixtureRuleConfiguration;
import org.junit.Test;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
public final class DatabaseTypeEngineTest {
@Test
@@ -190,11 +189,16 @@ public final class DatabaseTypeEngineTest {
}
@Test
- public void assertGetProtocolType() {
+ public void assertGetProtocolType() throws SQLException {
Properties props = new Properties();
props.setProperty(ConfigurationPropertyKey.PROXY_FRONTEND_DATABASE_PROTOCOL_TYPE.getKey(),
"H2");
DatabaseConfiguration databaseConfig = new
DataSourceProvidedDatabaseConfiguration(Collections.emptyMap(),
Collections.singleton(new FixtureRuleConfiguration()));
assertThat(DatabaseTypeEngine.getProtocolType(Collections.singletonMap("logic_db",
databaseConfig), new ConfigurationProperties(props)),
instanceOf(MySQLDatabaseType.class));
+
props.setProperty(ConfigurationPropertyKey.PROXY_FRONTEND_DATABASE_PROTOCOL_TYPE.getKey(),
"");
+
assertThat(DatabaseTypeEngine.getProtocolType(Collections.singletonMap("logic_db",
databaseConfig), new ConfigurationProperties(props)),
instanceOf(MySQLDatabaseType.class));
+ DataSource datasource =
mockDataSource(DatabaseTypeFactory.getInstance("PostgreSQL"));
+ databaseConfig = new
DataSourceProvidedDatabaseConfiguration(Collections.singletonMap("",
datasource), Collections.singleton(new FixtureRuleConfiguration()));
+
assertThat(DatabaseTypeEngine.getProtocolType(Collections.singletonMap("logic_db",
databaseConfig), new ConfigurationProperties(props)),
instanceOf(PostgreSQLDatabaseType.class));
}
@Test