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 b7f039a5e9d Remove useless dependencies on
shardingsphere-infra-context module (#36310)
b7f039a5e9d is described below
commit b7f039a5e9dafa0c53fe042ef5fe75b89adbe586
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Aug 15 11:11:16 2025 +0800
Remove useless dependencies on shardingsphere-infra-context module (#36310)
---
infra/context/pom.xml | 7 -------
.../connection/kernel/KernelProcessorTest.java | 23 +++++++++++-----------
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/infra/context/pom.xml b/infra/context/pom.xml
index 46cf1d2a5b9..90ee3d5286b 100644
--- a/infra/context/pom.xml
+++ b/infra/context/pom.xml
@@ -37,12 +37,5 @@
<artifactId>shardingsphere-infra-executor</artifactId>
<version>${project.version}</version>
</dependency>
-
- <dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-test-infra-fixture-database</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git
a/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
b/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
index 4dd9c334af7..8944cd35880 100644
---
a/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
+++
b/infra/context/src/test/java/org/apache/shardingsphere/infra/connection/kernel/KernelProcessorTest.java
@@ -43,9 +43,9 @@ import
org.apache.shardingsphere.sqltranslator.rule.SQLTranslatorRule;
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.Optional;
import static org.hamcrest.CoreMatchers.is;
@@ -66,23 +66,24 @@ class KernelProcessorTest {
when(connectionContext.getCurrentDatabaseName()).thenReturn(Optional.of("foo_db"));
ShardingSphereMetaData metaData = mock(ShardingSphereMetaData.class);
ResourceMetaData resourceMetaData = mock(ResourceMetaData.class,
RETURNS_DEEP_STUBS);
-
when(resourceMetaData.getStorageUnits()).thenReturn(Collections.singletonMap("ds_0",
mock(StorageUnit.class)));
- ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db",
databaseType, resourceMetaData, new RuleMetaData(mockRule()),
Collections.emptyList());
+
when(resourceMetaData.getStorageUnits()).thenReturn(Collections.singletonMap("ds_0",
mock(StorageUnit.class, RETURNS_DEEP_STUBS)));
+ ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db",
databaseType, resourceMetaData, new RuleMetaData(mockRules()),
Collections.emptyList());
when(metaData.containsDatabase("foo_db")).thenReturn(true);
when(metaData.getDatabase("foo_db")).thenReturn(database);
QueryContext queryContext = new QueryContext(sqlStatementContext,
"SELECT * FROM tbl", Collections.emptyList(), new HintValueContext(),
connectionContext, metaData);
ConfigurationProperties props = new
ConfigurationProperties(PropertiesBuilder.build(new
Property(ConfigurationPropertyKey.SQL_SHOW.getKey(), Boolean.TRUE.toString())));
- ExecutionContext actual = new
KernelProcessor().generateExecutionContext(queryContext, new
RuleMetaData(mockRule()), props);
+ ExecutionContext actual = new
KernelProcessor().generateExecutionContext(queryContext, new
RuleMetaData(mockRules()), props);
assertThat(actual.getExecutionUnits().size(), is(1));
}
- private Collection<ShardingSphereRule> mockRule() {
- Collection<ShardingSphereRule> result = new LinkedList<>();
- SQLTranslatorRule sqlTranslatorRule = mock(SQLTranslatorRule.class);
- when(sqlTranslatorRule.getAttributes()).thenReturn(new
RuleAttributes());
- when(sqlTranslatorRule.translate(any(), any(), any(), any(), any(),
any())).thenReturn(new SQLTranslatorContext("", Collections.emptyList()));
- result.add(sqlTranslatorRule);
- result.add(mockAggregatedDataSourceRule());
+ private Collection<ShardingSphereRule> mockRules() {
+ return Arrays.asList(mockSQLTranslatorRule(),
mockAggregatedDataSourceRule());
+ }
+
+ private SQLTranslatorRule mockSQLTranslatorRule() {
+ SQLTranslatorRule result = mock(SQLTranslatorRule.class);
+ when(result.getAttributes()).thenReturn(new RuleAttributes());
+ when(result.translate(any(), any(), any(), any(), any(),
any())).thenReturn(new SQLTranslatorContext("", Collections.emptyList()));
return result;
}