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 f2d1ed9 Use yaml config file to setup database-datetime module
(#16225)
f2d1ed9 is described below
commit f2d1ed9e2e6529f7e52044117c775cf944f1202d
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Mar 21 00:27:11 2022 +0800
Use yaml config file to setup database-datetime module (#16225)
* Refactor DatabaseSQLEntryFactory
* Refactor DatabaseDatetimeService
* Unify exception
* Refactor DatabaseDatetimeService
* Refactor TimeServiceConfiguration
* Refactor TimeServiceConfigurationTest
* Refactor TimeServiceConfiguration
* Refactor TimeServiceConfiguration
* Refactor TimeServiceConfiguration
* Refactor TimeServiceConfiguration
* Add DatabaseDatetimeServiceTest
* Update DatabaseDatetimeService
* Fix checkstyle
* Fix checkstyle
---
.../shardingsphere-database-datetime/pom.xml | 6 +-
.../{impl => }/DatabaseDatetimeService.java | 21 +++---
.../database/TimeServiceConfiguration.java | 76 ----------------------
.../database/config/TimeServiceConfiguration.java | 70 ++++++++++++++++++++
.../NoDatabaseSQLEntrySupportException.java | 26 --------
.../exception/TimeServiceInitException.java | 30 ---------
.../datetime/database/impl/TimeServiceFactory.java | 41 ------------
.../datetime/database/spi/DatabaseSQLEntry.java | 12 +---
...eSQLEntry.java => DatabaseSQLEntryFactory.java} | 40 +++++-------
.../spi/dialect/MySQLDatabaseSQLEntry.java | 4 +-
.../spi/dialect/OracleDatabaseSQLEntry.java | 4 +-
.../spi/dialect/PostgreSQLDatabaseSQLEntry.java | 4 +-
.../spi/dialect/SQLServerDatabaseSQLEntry.java | 4 +-
...ngsphere.datetime.database.spi.DatabaseSQLEntry | 4 +-
...e.shardingsphere.infra.datetime.DatetimeService | 2 +-
.../database/DatabaseDatetimeServiceTest.java} | 19 +++---
.../datetime/database/PropertiesUtils.java | 65 ------------------
.../{ => config}/TimeServiceConfigurationTest.java | 16 ++---
.../database/fixture/FixtureDatabaseSQLEntry.java | 36 ----------
.../database/impl/DatabaseDatetimeServiceTest.java | 58 -----------------
.../database/impl/TimeServiceFactoryTest.java | 35 ----------
...ngsphere.datetime.database.spi.DatabaseSQLEntry | 18 -----
.../resources/time-service.yaml} | 11 ++--
23 files changed, 139 insertions(+), 463 deletions(-)
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 1d9f1bb..de9bb1a 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
@@ -40,10 +40,8 @@
</dependency>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-test-common</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
</dependency>
</dependencies>
</project>
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/DatabaseDatetimeService.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
similarity index 65%
rename from
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/DatabaseDatetimeService.java
rename to
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
index 2f419a5..0f82cca 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/DatabaseDatetimeService.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeService.java
@@ -15,10 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.datetime.database.impl;
+package org.apache.shardingsphere.datetime.database;
-import lombok.RequiredArgsConstructor;
+import
org.apache.shardingsphere.datetime.database.config.TimeServiceConfiguration;
+import org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntryFactory;
import org.apache.shardingsphere.infra.datetime.DatetimeService;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -30,23 +32,26 @@ import java.util.Date;
/**
* Database datetime service.
*/
-@RequiredArgsConstructor
public final class DatabaseDatetimeService implements DatetimeService {
- private final DataSource dataSource;
-
- private final String sql;
+ private final TimeServiceConfiguration timeServiceConfig =
TimeServiceConfiguration.getInstance();
@Override
public Date getDatetime() {
+ try {
+ return loadDatetime(timeServiceConfig.getDataSource(),
DatabaseSQLEntryFactory.newInstance(timeServiceConfig.getDatabaseType()).getSQL());
+ } catch (final SQLException ex) {
+ throw new ShardingSphereException("Load timestamp from database
error!", ex);
+ }
+ }
+
+ private Date loadDatetime(final DataSource dataSource, final String sql)
throws SQLException {
try (Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement =
connection.prepareStatement(sql)) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
resultSet.next();
return (Date) resultSet.getObject(1);
}
- } catch (final SQLException ignore) {
}
- return new Date();
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/TimeServiceConfiguration.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/TimeServiceConfiguration.java
deleted file mode 100644
index a5be4c4..0000000
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/TimeServiceConfiguration.java
+++ /dev/null
@@ -1,76 +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.datetime.database;
-
-import lombok.Getter;
-import
org.apache.shardingsphere.datetime.database.exception.TimeServiceInitException;
-
-import javax.sql.DataSource;
-import java.beans.IntrospectionException;
-import java.beans.PropertyDescriptor;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Properties;
-
-/**
- * Time service configuration.
- */
-@Getter
-public final class TimeServiceConfiguration {
-
- private static final TimeServiceConfiguration CONFIG = new
TimeServiceConfiguration();
-
- private String driverClassName;
-
- private DataSource dataSource;
-
- private TimeServiceConfiguration() {
- init();
- }
-
- private void init() {
- try (InputStream inputStream =
TimeServiceConfiguration.class.getResourceAsStream("/time-service.properties"))
{
- Properties props = new Properties();
- props.load(inputStream);
- String dataSourceType = (String) props.remove("dataSourceType");
- driverClassName = props.getProperty("driverClassName");
- Class<?> dataSourceClass = Class.forName(dataSourceType);
- dataSource = (DataSource)
dataSourceClass.getConstructor().newInstance();
- for (String each : props.stringPropertyNames()) {
- PropertyDescriptor propertyDescriptor = new
PropertyDescriptor(each, dataSourceClass);
- Method writeMethod = propertyDescriptor.getWriteMethod();
- writeMethod.invoke(dataSource, props.getProperty(each));
- }
- } catch (final ClassNotFoundException | InstantiationException |
IllegalAccessException | IntrospectionException | InvocationTargetException |
IOException ex) {
- throw new TimeServiceInitException("please check your
time-service.properties", ex);
- } catch (final NoSuchMethodException ex) {
- throw new TimeServiceInitException(ex.getMessage(), ex);
- }
- }
-
- /**
- * Get configuration instance.
- *
- * @return time service configuration
- */
- public static TimeServiceConfiguration getInstance() {
- return CONFIG;
- }
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/config/TimeServiceConfiguration.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/config/TimeServiceConfiguration.java
new file mode 100644
index 0000000..971dbb2
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/config/TimeServiceConfiguration.java
@@ -0,0 +1,70 @@
+/*
+ * 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.datetime.database.config;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.DatabaseTypeRecognizer;
+import
org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator;
+import org.apache.shardingsphere.infra.exception.ShardingSphereException;
+import
org.apache.shardingsphere.infra.yaml.config.swapper.YamlDataSourceConfigurationSwapper;
+import org.yaml.snakeyaml.Yaml;
+
+import javax.sql.DataSource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Time service configuration.
+ */
+@Getter
+public final class TimeServiceConfiguration {
+
+ private static final TimeServiceConfiguration INSTANCE = new
TimeServiceConfiguration();
+
+ private static final String CONFIG_FILE = "time-service.yaml";
+
+ private final DataSource dataSource;
+
+ private final DatabaseType databaseType;
+
+ private TimeServiceConfiguration() {
+ dataSource = DataSourcePoolCreator.create(new
YamlDataSourceConfigurationSwapper().swapToDataSourceProperties(loadDataSourceConfiguration()));
+ databaseType =
DatabaseTypeRecognizer.getDatabaseType(Collections.singleton(dataSource));
+ }
+
+ @SuppressWarnings("unchecked")
+ private Map<String, Object> loadDataSourceConfiguration() {
+ try (InputStream inputStream =
getClass().getClassLoader().getResourceAsStream(CONFIG_FILE)) {
+ return new Yaml().loadAs(inputStream, Map.class);
+ } catch (final IOException ex) {
+ throw new ShardingSphereException("Cannot load " + CONFIG_FILE +
"file.", ex);
+ }
+ }
+
+ /**
+ * Get time service configuration instance.
+ *
+ * @return time service configuration
+ */
+ public static TimeServiceConfiguration getInstance() {
+ return INSTANCE;
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/NoDatabaseSQLEntrySupportException.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/NoDatabaseSQLEntrySupportException.java
deleted file mode 100644
index ba9a5c0..0000000
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/NoDatabaseSQLEntrySupportException.java
+++ /dev/null
@@ -1,26 +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.datetime.database.exception;
-
-/**
- * No database SQL entry support.
- */
-public final class NoDatabaseSQLEntrySupportException extends RuntimeException
{
-
- private static final long serialVersionUID = 2153295582601133739L;
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/TimeServiceInitException.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/TimeServiceInitException.java
deleted file mode 100644
index 293243f..0000000
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/TimeServiceInitException.java
+++ /dev/null
@@ -1,30 +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.datetime.database.exception;
-
-/**
- * Time service init exception.
- */
-public final class TimeServiceInitException extends RuntimeException {
-
- private static final long serialVersionUID = -834638295454826244L;
-
- public TimeServiceInitException(final String message, final Throwable
cause) {
- super(message, cause);
- }
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactory.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactory.java
deleted file mode 100644
index a3244e1..0000000
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactory.java
+++ /dev/null
@@ -1,41 +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.datetime.database.impl;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.infra.datetime.DatetimeService;
-import org.apache.shardingsphere.datetime.database.TimeServiceConfiguration;
-import org.apache.shardingsphere.datetime.database.spi.SPIDataBaseSQLEntry;
-
-/**
- * Time service factory.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class TimeServiceFactory {
-
- /**
- * Create time service by {@link TimeServiceConfiguration}.
- *
- * @return time service instance
- */
- public static DatetimeService createTimeService() {
- TimeServiceConfiguration timeServiceConfig =
TimeServiceConfiguration.getInstance();
- return new DatabaseDatetimeService(timeServiceConfig.getDataSource(),
new SPIDataBaseSQLEntry(timeServiceConfig.getDriverClassName()).getSQL());
- }
-}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntry.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntry.java
index 64d75b6..2956470 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntry.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntry.java
@@ -17,10 +17,12 @@
package org.apache.shardingsphere.datetime.database.spi;
+import org.apache.shardingsphere.spi.typed.TypedSPI;
+
/**
* Database SQL entry.
*/
-public interface DatabaseSQLEntry {
+public interface DatabaseSQLEntry extends TypedSPI {
/**
* Get SQL for getting time.
@@ -28,12 +30,4 @@ public interface DatabaseSQLEntry {
* @return SQL
*/
String getSQL();
-
- /**
- * Determine whether it supports.
- *
- * @param driverClassName driver class name
- * @return support or not
- */
- boolean isSupport(String driverClassName);
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SPIDataBaseSQLEntry.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntryFactory.java
similarity index 55%
rename from
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SPIDataBaseSQLEntry.java
rename to
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntryFactory.java
index 775fe63..de9fcf1 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SPIDataBaseSQLEntry.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntryFactory.java
@@ -17,38 +17,32 @@
package org.apache.shardingsphere.datetime.database.spi;
-import lombok.RequiredArgsConstructor;
-import
org.apache.shardingsphere.datetime.database.exception.NoDatabaseSQLEntrySupportException;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.spi.typed.TypedSPIRegistry;
-import java.util.Collection;
+import java.util.Properties;
/**
- * SPI for DatabaseSQLEntry.
+ * Database SQL entry factory.
*/
-@RequiredArgsConstructor
-public final class SPIDataBaseSQLEntry implements DatabaseSQLEntry {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class DatabaseSQLEntryFactory {
static {
ShardingSphereServiceLoader.register(DatabaseSQLEntry.class);
}
- private final Collection<DatabaseSQLEntry> sqlEntries =
ShardingSphereServiceLoader.getSingletonServiceInstances(DatabaseSQLEntry.class);
-
- private final String driverClassName;
-
- @Override
- public String getSQL() {
- for (DatabaseSQLEntry each : sqlEntries) {
- if (each.isSupport(driverClassName)) {
- return each.getSQL();
- }
- }
- throw new NoDatabaseSQLEntrySupportException();
- }
-
- @Override
- public boolean isSupport(final String driverClassName) {
- return true;
+ /**
+ * Create new instance of database SQL entry.
+ *
+ * @param databaseType database type
+ * @return new instance of database SQL entry
+ */
+ public static DatabaseSQLEntry newInstance(final DatabaseType
databaseType) {
+ return TypedSPIRegistry.getRegisteredService(DatabaseSQLEntry.class,
DatabaseTypeRegistry.getTrunkDatabaseTypeName(databaseType), new Properties());
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/MySQLDatabaseSQLEntry.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/MySQLDatabaseSQLEntry.java
index 6fd8e49..f93fdd5 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/MySQLDatabaseSQLEntry.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/MySQLDatabaseSQLEntry.java
@@ -30,7 +30,7 @@ public final class MySQLDatabaseSQLEntry implements
DatabaseSQLEntry {
}
@Override
- public boolean isSupport(final String driverClassName) {
- return driverClassName.contains("mysql") ||
driverClassName.contains("mariadb");
+ public String getType() {
+ return "MySQL";
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/OracleDatabaseSQLEntry.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/OracleDatabaseSQLEntry.java
index 02a6edb..fe85529 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/OracleDatabaseSQLEntry.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/OracleDatabaseSQLEntry.java
@@ -30,7 +30,7 @@ public final class OracleDatabaseSQLEntry implements
DatabaseSQLEntry {
}
@Override
- public boolean isSupport(final String driverClassName) {
- return driverClassName.contains("oracle");
+ public String getType() {
+ return "Oracle";
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/PostgreSQLDatabaseSQLEntry.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/PostgreSQLDatabaseSQLEntry.java
index 55ba476..125cc4a 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/PostgreSQLDatabaseSQLEntry.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/PostgreSQLDatabaseSQLEntry.java
@@ -30,7 +30,7 @@ public final class PostgreSQLDatabaseSQLEntry implements
DatabaseSQLEntry {
}
@Override
- public boolean isSupport(final String driverClassName) {
- return driverClassName.contains("postgresql");
+ public String getType() {
+ return "PostgreSQL";
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/SQLServerDatabaseSQLEntry.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/SQLServerDatabaseSQLEntry.java
index 9d77807..3f5910b 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/SQLServerDatabaseSQLEntry.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/dialect/SQLServerDatabaseSQLEntry.java
@@ -30,7 +30,7 @@ public final class SQLServerDatabaseSQLEntry implements
DatabaseSQLEntry {
}
@Override
- public boolean isSupport(final String driverClassName) {
- return driverClassName.contains("sqlserver");
+ public String getType() {
+ return "SQLServer";
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/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/main/resources/META-INF/services/org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry
index dc8b16e..1a9ffba 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/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/main/resources/META-INF/services/org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry
@@ -15,7 +15,7 @@
# limitations under the License.
#
-org.apache.shardingsphere.datetime.database.spi.dialect.MySQLDatabaseSQLEntry
org.apache.shardingsphere.datetime.database.spi.dialect.PostgreSQLDatabaseSQLEntry
-org.apache.shardingsphere.datetime.database.spi.dialect.OracleDatabaseSQLEntry
+org.apache.shardingsphere.datetime.database.spi.dialect.MySQLDatabaseSQLEntry
org.apache.shardingsphere.datetime.database.spi.dialect.SQLServerDatabaseSQLEntry
+org.apache.shardingsphere.datetime.database.spi.dialect.OracleDatabaseSQLEntry
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
index f52f04f..e561d96 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.datetime.database.DatabaseDatetimeServiceDelegate
+org.apache.shardingsphere.datetime.database.DatabaseDatetimeService
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceDelegate.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceTest.java
similarity index 71%
rename from
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceDelegate.java
rename to
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceTest.java
index ede581a..85a7577 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceDelegate.java
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceTest.java
@@ -18,19 +18,18 @@
package org.apache.shardingsphere.datetime.database;
import org.apache.shardingsphere.infra.datetime.DatetimeService;
-import org.apache.shardingsphere.datetime.database.impl.TimeServiceFactory;
+import org.junit.Test;
import java.util.Date;
-/**
- * Delegate database datetime service.
- */
-public final class DatabaseDatetimeServiceDelegate implements DatetimeService {
-
- private static final DatetimeService INSTANCE =
TimeServiceFactory.createTimeService();
+import static org.junit.Assert.assertTrue;
+
+public final class DatabaseDatetimeServiceTest {
- @Override
- public Date getDatetime() {
- return INSTANCE.getDatetime();
+ @Test
+ public void assertGetDateTime() {
+ Date currentDate = new Date();
+ DatetimeService datetimeService = new DatabaseDatetimeService();
+ assertTrue(datetimeService.getDatetime().getTime() >=
currentDate.getTime());
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/PropertiesUtils.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/PropertiesUtils.java
deleted file mode 100644
index add23dc..0000000
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/PropertiesUtils.java
+++ /dev/null
@@ -1,65 +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.datetime.database;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class PropertiesUtils {
-
- private static final File FILE = new
File(PropertiesUtils.class.getResource("/").getPath() +
"time-service.properties");
-
- /**
- * Create a time-service.properties file.
- *
- * @param driverClassName driver class name
- * @param sql SQL
- */
- public static void createProperties(final String driverClassName, final
String sql) {
- try {
- Properties props = new Properties();
- props.setProperty("dataSourceType",
"com.zaxxer.hikari.HikariDataSource");
- props.setProperty("jdbcUrl", "jdbc:test");
- props.setProperty("username", "root");
- props.setProperty("password", "root");
- props.setProperty("driverClassName", driverClassName);
- if (null != sql) {
- props.setProperty("sql", sql);
- }
- FileOutputStream stream = new FileOutputStream(FILE);
- props.store(stream, null);
- stream.close();
- } catch (final IOException ignore) {
- }
- }
-
- /**
- * Delete time-service.properties.
- *
- * @return true if delete successfully or false
- */
- public static boolean remove() {
- return FILE.delete();
- }
-}
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/config/TimeServiceConfigurationTest.java
similarity index 64%
rename from
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
rename to
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/config/TimeServiceConfigurationTest.java
index 686e07a..5c0c9ee 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/config/TimeServiceConfigurationTest.java
@@ -15,20 +15,20 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.datetime.database;
+package org.apache.shardingsphere.datetime.database.config;
-import org.apache.shardingsphere.test.mock.MockedDataSource;
+import com.zaxxer.hikari.HikariDataSource;
import org.junit.Test;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
public final class TimeServiceConfigurationTest {
@Test
- public void assertInitDataSource() {
- PropertiesUtils.createProperties(MockedDataSource.class.getName(),
null);
- assertNotNull(TimeServiceConfiguration.getInstance().getDataSource());
- assertTrue(PropertiesUtils.remove());
+ public void assertGetInstance() {
+
assertThat(TimeServiceConfiguration.getInstance().getDatabaseType().getName(),
is("H2"));
+ assertThat(TimeServiceConfiguration.getInstance().getDataSource(),
instanceOf(HikariDataSource.class));
}
}
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatabaseSQLEntry.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
deleted file mode 100644
index c3aedfe..0000000
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/fixture/FixtureDatabaseSQLEntry.java
+++ /dev/null
@@ -1,36 +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.datetime.database.fixture;
-
-import org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry;
-
-/**
- * Fixture entry.
- */
-public final class FixtureDatabaseSQLEntry implements DatabaseSQLEntry {
-
- @Override
- public String getSQL() {
- return "SELECT 1";
- }
-
- @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/DatabaseDatetimeServiceTest.java
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/impl/DatabaseDatetimeServiceTest.java
deleted file mode 100644
index 6047646..0000000
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/impl/DatabaseDatetimeServiceTest.java
+++ /dev/null
@@ -1,58 +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.datetime.database.impl;
-
-import org.apache.shardingsphere.infra.datetime.DatetimeService;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import javax.sql.DataSource;
-import java.sql.SQLException;
-import java.util.Date;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class DatabaseDatetimeServiceTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private DataSource dataSource;
-
- private final String sql = "SELECT NOW()";
-
- @Test
- public void assertMySQLDateTime() throws SQLException {
-
when(dataSource.getConnection().prepareStatement(sql).executeQuery().getObject(1)).thenReturn(new
Date());
- DatetimeService datetimeService = new
DatabaseDatetimeService(dataSource, sql);
- assertFalse(datetimeService.isDefault());
- assertNotNull(datetimeService.getDatetime());
- }
-
- @Test
- public void assertNoExceptionInDateTimeService() throws SQLException {
- when(dataSource.getConnection().prepareStatement(sql)).thenThrow(new
SQLException());
- DatetimeService datetimeService = new
DatabaseDatetimeService(dataSource, sql);
- assertFalse(datetimeService.isDefault());
- assertNotNull(datetimeService.getDatetime());
- }
-}
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
deleted file mode 100644
index f807a0a..0000000
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactoryTest.java
+++ /dev/null
@@ -1,35 +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.datetime.database.impl;
-
-import org.apache.shardingsphere.datetime.database.PropertiesUtils;
-import org.apache.shardingsphere.test.mock.MockedDataSource;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public final class TimeServiceFactoryTest {
-
- @Test
- public void assertCreateDateTimeService() {
- 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
deleted file mode 100644
index 2430cce..0000000
---
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
+++ /dev/null
@@ -1,18 +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.
-#
-
-org.apache.shardingsphere.datetime.database.fixture.FixtureDatabaseSQLEntry
diff --git
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/time-service.properties
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/time-service.yaml
similarity index 79%
rename from
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/time-service.properties
rename to
shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/time-service.yaml
index 5989888..69a5196 100644
---
a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/time-service.properties
+++
b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/time-service.yaml
@@ -15,8 +15,9 @@
# limitations under the License.
#
-#dataSourceType=
-#driverClassName=
-#username=
-#password=
-#url=
+dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+driverClassName: org.h2.Driver
+jdbcUrl:
jdbc:h2:mem:db_write;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
+username: sa
+password:
+maxTotal: 100