From 1b69b7b6cdc709aef024b4a7f1c1102e261ccdfd Mon Sep 17 00:00:00 2001 From: zhangliang Date: Sun, 5 Nov 2023 20:57:31 +0800 Subject: [PATCH] Refactor MySQLIncrementalDumperTest --- .../DataSourcePoolPropertiesValidatorTest.java | 7 +++++++ .../ingest/MySQLIncrementalDumperTest.java | 7 +++++++ ...ImportDatabaseConfigurationUpdaterTest.java | 7 +++++++ .../META-INF/services/java.sql.Driver | 18 ------------------ 4 files changed, 21 insertions(+), 18 deletions(-) delete mode 100644 test/fixture/database/src/main/resources/META-INF/services/java.sql.Driver diff --git a/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/props/validator/DataSourcePoolPropertiesValidatorTest.java b/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/props/validator/DataSourcePoolPropertiesValidatorTest.java index 550db2e08ee43..548c50901f895 100644 --- a/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/props/validator/DataSourcePoolPropertiesValidatorTest.java +++ b/infra/data-source-pool/core/src/test/java/org/apache/shardingsphere/infra/datasource/pool/props/validator/DataSourcePoolPropertiesValidatorTest.java @@ -19,6 +19,8 @@ import com.zaxxer.hikari.HikariDataSource; import org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties; +import org.apache.shardingsphere.test.fixture.jdbc.MockedDriver; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.util.Collections; @@ -27,6 +29,11 @@ class DataSourcePoolPropertiesValidatorTest { + @BeforeAll + static void setUp() throws ClassNotFoundException { + Class.forName(MockedDriver.class.getName()); + } + @Test void assertValidate() { assertTrue(DataSourcePoolPropertiesValidator.validate( diff --git a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumperTest.java b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumperTest.java index 93f6d1623ad49..c83e3ede6d324 100644 --- a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumperTest.java +++ b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/MySQLIncrementalDumperTest.java @@ -41,6 +41,8 @@ import org.apache.shardingsphere.data.pipeline.mysql.ingest.binlog.event.PlaceholderEvent; import org.apache.shardingsphere.data.pipeline.mysql.ingest.binlog.event.UpdateRowsEvent; import org.apache.shardingsphere.data.pipeline.mysql.ingest.binlog.event.WriteRowsEvent; +import org.apache.shardingsphere.test.fixture.jdbc.MockedDriver; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -78,6 +80,11 @@ class MySQLIncrementalDumperTest { private PipelineTableMetaData pipelineTableMetaData; + @BeforeAll + static void init() throws ClassNotFoundException { + Class.forName(MockedDriver.class.getName()); + } + @BeforeEach void setUp() throws SQLException { IncrementalDumperContext dumperContext = createDumperContext(); diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java index 0e4172ab153ee..561df445c2855 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java @@ -34,8 +34,10 @@ import org.apache.shardingsphere.mode.manager.ContextManager; import org.apache.shardingsphere.proxy.backend.context.ProxyContext; import org.apache.shardingsphere.proxy.backend.util.YamlDatabaseConfigurationImportExecutor; +import org.apache.shardingsphere.test.fixture.jdbc.MockedDriver; import org.apache.shardingsphere.test.mock.AutoMockExtension; import org.apache.shardingsphere.test.mock.StaticMockSettings; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.internal.configuration.plugins.Plugins; @@ -58,6 +60,11 @@ class ImportDatabaseConfigurationUpdaterTest { private ImportDatabaseConfigurationUpdater importDatabaseConfigUpdater; + @BeforeAll + static void setUp() throws ClassNotFoundException { + Class.forName(MockedDriver.class.getName()); + } + @Test void assertImportDatabaseExecutorForSharding() throws SQLException { assertExecute("sharding_db", "/conf/import/config-sharding.yaml"); diff --git a/test/fixture/database/src/main/resources/META-INF/services/java.sql.Driver b/test/fixture/database/src/main/resources/META-INF/services/java.sql.Driver deleted file mode 100644 index 72fac4d815d5f..0000000000000 --- a/test/fixture/database/src/main/resources/META-INF/services/java.sql.Driver +++ /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.test.fixture.jdbc.MockedDriver