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 3bd8866054b Decouple MySQL dependencies on single-core test cases (#35222) 3bd8866054b is described below commit 3bd8866054bfcbe4f76e20c54d00147ee64036a1 Author: Liang Zhang <zhangli...@apache.org> AuthorDate: Sat Apr 19 00:37:39 2025 +0800 Decouple MySQL dependencies on single-core test cases (#35222) --- .../single/route/engine/engine/SingleRouteEngineTest.java | 13 ++++++------- .../single/rule/builder/SingleRuleBuilderTest.java | 10 +++------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/engine/engine/SingleRouteEngineTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/engine/engine/SingleRouteEngineTest.java index 0ed003fa0b6..b0ea2ccca6e 100644 --- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/engine/engine/SingleRouteEngineTest.java +++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/engine/engine/SingleRouteEngineTest.java @@ -17,7 +17,6 @@ package org.apache.shardingsphere.single.route.engine.engine; -import org.apache.shardingsphere.infra.database.mysql.type.MySQLDatabaseType; import org.apache.shardingsphere.infra.datanode.DataNode; import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.table.TableExistsException; import org.apache.shardingsphere.infra.hint.HintValueContext; @@ -64,8 +63,8 @@ class SingleRouteEngineTest { @Test void assertRouteInSameDataSource() throws SQLException { - SingleRouteEngine engine = new SingleRouteEngine(mockQualifiedTables(), null, mock(HintValueContext.class)); - SingleRule singleRule = new SingleRule(new SingleRuleConfiguration(), "foo_db", new MySQLDatabaseType(), createDataSourceMap(), Collections.emptyList()); + SingleRouteEngine engine = new SingleRouteEngine(mockQualifiedTables(), null, mock()); + SingleRule singleRule = new SingleRule(new SingleRuleConfiguration(), "foo_db", mock(), createDataSourceMap(), Collections.emptyList()); singleRule.getAttributes().getAttribute(DataNodeRuleAttribute.class).getAllDataNodes().put("t_order", Collections.singleton(mockDataNode("t_order"))); singleRule.getAttributes().getAttribute(DataNodeRuleAttribute.class).getAllDataNodes().put("t_order_item", Collections.singleton(mockDataNode("t_order_item"))); RouteContext routeContext = new RouteContext(); @@ -97,8 +96,8 @@ class SingleRouteEngineTest { void assertRouteWithoutSingleRule() throws SQLException { MySQLCreateTableStatement sqlStatement = new MySQLCreateTableStatement(); sqlStatement.setIfNotExists(false); - SingleRouteEngine engine = new SingleRouteEngine(mockQualifiedTables(), sqlStatement, mock(HintValueContext.class)); - SingleRule singleRule = new SingleRule(new SingleRuleConfiguration(), "foo_db", new MySQLDatabaseType(), createDataSourceMap(), Collections.emptyList()); + SingleRouteEngine engine = new SingleRouteEngine(mockQualifiedTables(), sqlStatement, mock()); + SingleRule singleRule = new SingleRule(new SingleRuleConfiguration(), "foo_db", mock(), createDataSourceMap(), Collections.emptyList()); RouteContext routeContext = new RouteContext(); engine.route(routeContext, singleRule); List<RouteUnit> routeUnits = new ArrayList<>(routeContext.getRouteUnits()); @@ -114,9 +113,9 @@ class SingleRouteEngineTest { void assertRouteWithDefaultSingleRule() throws SQLException { MySQLCreateTableStatement sqlStatement = new MySQLCreateTableStatement(); sqlStatement.setIfNotExists(false); - SingleRouteEngine engine = new SingleRouteEngine(mockQualifiedTables(), sqlStatement, mock(HintValueContext.class)); + SingleRouteEngine engine = new SingleRouteEngine(mockQualifiedTables(), sqlStatement, mock()); SingleRule singleRule = - new SingleRule(new SingleRuleConfiguration(Collections.emptyList(), "ds_0"), "foo_db", new MySQLDatabaseType(), createDataSourceMap(), Collections.emptyList()); + new SingleRule(new SingleRuleConfiguration(Collections.emptyList(), "ds_0"), "foo_db", mock(), createDataSourceMap(), Collections.emptyList()); RouteContext routeContext = new RouteContext(); engine.route(routeContext, singleRule); List<RouteUnit> routeUnits = new ArrayList<>(routeContext.getRouteUnits()); diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/SingleRuleBuilderTest.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/SingleRuleBuilderTest.java index c5097e456c3..177da339420 100644 --- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/SingleRuleBuilderTest.java +++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/rule/builder/SingleRuleBuilderTest.java @@ -17,9 +17,6 @@ package org.apache.shardingsphere.single.rule.builder; -import org.apache.shardingsphere.infra.database.mysql.type.MySQLDatabaseType; -import org.apache.shardingsphere.infra.instance.ComputeNodeInstanceContext; -import org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData; import org.apache.shardingsphere.infra.rule.ShardingSphereRule; import org.apache.shardingsphere.infra.rule.builder.database.DatabaseRuleBuilder; import org.apache.shardingsphere.infra.rule.scope.DatabaseRule; @@ -41,8 +38,7 @@ class SingleRuleBuilderTest { @Test void assertBuild() { DatabaseRuleBuilder builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class).iterator().next(); - DatabaseRule actual = builder.build(mock(SingleRuleConfiguration.class), "", - new MySQLDatabaseType(), mock(ResourceMetaData.class), Collections.singleton(mock(ShardingSphereRule.class, RETURNS_DEEP_STUBS)), mock(ComputeNodeInstanceContext.class)); + DatabaseRule actual = builder.build(mock(SingleRuleConfiguration.class), "", mock(), mock(), Collections.singleton(mock(ShardingSphereRule.class, RETURNS_DEEP_STUBS)), mock()); assertThat(actual, instanceOf(SingleRule.class)); } @@ -50,8 +46,8 @@ class SingleRuleBuilderTest { @Test void assertBuildWithDefaultDataSource() { DatabaseRuleBuilder builder = OrderedSPILoader.getServices(DatabaseRuleBuilder.class).iterator().next(); - DatabaseRule actual = builder.build(new SingleRuleConfiguration(Collections.emptyList(), "foo_ds"), "", new MySQLDatabaseType(), mock(ResourceMetaData.class), - Collections.singleton(mock(ShardingSphereRule.class, RETURNS_DEEP_STUBS)), mock(ComputeNodeInstanceContext.class)); + DatabaseRule actual = builder.build( + new SingleRuleConfiguration(Collections.emptyList(), "foo_ds"), "", mock(), mock(), Collections.singleton(mock(ShardingSphereRule.class, RETURNS_DEEP_STUBS)), mock()); assertThat(actual, instanceOf(SingleRule.class)); } }