This is an automated email from the ASF dual-hosted git repository.
panjuan 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 8753980 Revise HikariCP scope for shardingsphere-database-datetime
(#16219)
8753980 is described below
commit 875398000b5b27c513211ce9d76dc6760a215ba9
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Mar 20 19:24:00 2022 +0800
Revise HikariCP scope for shardingsphere-database-datetime (#16219)
---
.../shardingsphere-infra-common/pom.xml | 1 +
.../shardingsphere-database-datetime/pom.xml | 20 ++++-------------
.../database/TimeServiceConfigurationTest.java | 6 ++---
.../FixtureDatabaseSQLEntry.java} | 26 ++++++++++++----------
.../database/impl/TimeServiceFactoryTest.java | 7 +++---
...ngsphere.datetime.database.spi.DatabaseSQLEntry | 18 +++++++++++++++
.../shardingsphere-integration-test-suite/pom.xml | 1 -
7 files changed, 43 insertions(+), 36 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/pom.xml
b/shardingsphere-infra/shardingsphere-infra-common/pom.xml
index 7347963..13c6fdb 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/pom.xml
+++ b/shardingsphere-infra/shardingsphere-infra-common/pom.xml
@@ -57,6 +57,7 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
+
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/pom.xml
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/pom.xml
index 8aee66d..1d9f1bb 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/pom.xml
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/pom.xml
@@ -33,7 +33,6 @@
<artifactId>shardingsphere-infra-datetime-spi</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-sharding-core</artifactId>
@@ -41,21 +40,10 @@
</dependency>
<dependency>
- <groupId>org.postgresql</groupId>
- <artifactId>postgresql</artifactId>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- </dependency>
- <dependency>
- <groupId>com.microsoft.sqlserver</groupId>
- <artifactId>mssql-jdbc</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.zaxxer</groupId>
- <artifactId>HikariCP</artifactId>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-test-common</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
index f0d66b4..686e07a 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.datetime.database;
+import org.apache.shardingsphere.test.mock.MockedDataSource;
import org.junit.Test;
import static org.junit.Assert.assertNotNull;
@@ -26,9 +27,8 @@ public final class TimeServiceConfigurationTest {
@Test
public void assertInitDataSource() {
- PropertiesUtils.createProperties("com.mysql.jdbc.Driver", null);
- TimeServiceConfiguration config =
TimeServiceConfiguration.getInstance();
- assertNotNull(config.getDataSource());
+ PropertiesUtils.createProperties(MockedDataSource.class.getName(),
null);
+ assertNotNull(TimeServiceConfiguration.getInstance().getDataSource());
assertTrue(PropertiesUtils.remove());
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatabaseSQLEntry.java
similarity index 61%
copy from
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
copy to
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatabaseSQLEntry.java
index f0d66b4..c3aedfe 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatabaseSQLEntry.java
@@ -15,20 +15,22 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.datetime.database;
+package org.apache.shardingsphere.datetime.database.fixture;
-import org.junit.Test;
+import org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public final class TimeServiceConfigurationTest {
+/**
+ * Fixture entry.
+ */
+public final class FixtureDatabaseSQLEntry implements DatabaseSQLEntry {
+
+ @Override
+ public String getSQL() {
+ return "SELECT 1";
+ }
- @Test
- public void assertInitDataSource() {
- PropertiesUtils.createProperties("com.mysql.jdbc.Driver", null);
- TimeServiceConfiguration config =
TimeServiceConfiguration.getInstance();
- assertNotNull(config.getDataSource());
- assertTrue(PropertiesUtils.remove());
+ @Override
+ public boolean isSupport(final String driverClassName) {
+ return driverClassName.contains("mock");
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactoryTest.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactoryTest.java
index b653411..f807a0a 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactoryTest.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactoryTest.java
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.datetime.database.impl;
import org.apache.shardingsphere.datetime.database.PropertiesUtils;
-import org.apache.shardingsphere.infra.datetime.DatetimeService;
+import org.apache.shardingsphere.test.mock.MockedDataSource;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
@@ -28,9 +28,8 @@ public final class TimeServiceFactoryTest {
@Test
public void assertCreateDateTimeService() {
- PropertiesUtils.createProperties("com.mysql.jdbc.Driver", null);
- DatetimeService datetimeService =
TimeServiceFactory.createTimeService();
- assertFalse(datetimeService.isDefault());
+ PropertiesUtils.createProperties(MockedDataSource.class.getName(),
null);
+ assertFalse(TimeServiceFactory.createTimeService().isDefault());
assertTrue(PropertiesUtils.remove());
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry
new file mode 100644
index 0000000..2430cce
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/META-INF/services/org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.datetime.database.fixture.FixtureDatabaseSQLEntry
diff --git
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
index a0d96ff..8e27bc8 100644
---
a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
+++
b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-suite/pom.xml
@@ -55,7 +55,6 @@
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>${hikari-cp.version}</version>
- <scope>compile</scope>
</dependency>
<dependency>