You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/09/07 01:10:43 UTC
[shardingsphere] branch master updated: Fix unit test exception when execute with JDK17 (#20840)
This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng 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 d03e84be9a1 Fix unit test exception when execute with JDK17 (#20840)
d03e84be9a1 is described below
commit d03e84be9a1943d6007ba02af7a81db91dd88fa0
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Wed Sep 7 09:10:34 2022 +0800
Fix unit test exception when execute with JDK17 (#20840)
---
.../audit/DMLShardingConditionsShardingAuditAlgorithmTest.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/audit/DMLShardingConditionsShardingAuditAlgorithmTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/audit/DMLShardingConditionsShardingAuditAlgorithmTest.java
index dd40e150e5d..21865cb47e4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/audit/DMLShardingConditionsShardingAuditAlgorithmTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/algorithm/audit/DMLShardingConditionsShardingAuditAlgorithmTest.java
@@ -21,6 +21,7 @@ import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.check.SQLCheckResult;
import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.sharding.factory.ShardingAuditAlgorithmFactory;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -70,7 +71,7 @@ public final class DMLShardingConditionsShardingAuditAlgorithmTest {
@Test
public void assertAllBroadcastTablesCheck() {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(DMLStatement.class));
- when(database.getRuleMetaData().getSingleRule(ShardingRule.class)).thenReturn(rule);
+ when(database.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.singletonList(rule)));
when(rule.isAllBroadcastTables(sqlStatementContext.getTablesContext().getTableNames())).thenReturn(true);
asserCheckResult(shardingAuditAlgorithm.check(sqlStatementContext, Collections.emptyList(), mock(Grantee.class), database), true, "");
}
@@ -78,7 +79,7 @@ public final class DMLShardingConditionsShardingAuditAlgorithmTest {
@Test
public void assertNotAllShardingTablesCheck() {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(DMLStatement.class));
- when(database.getRuleMetaData().getSingleRule(ShardingRule.class)).thenReturn(rule);
+ when(database.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.singletonList(rule)));
when(rule.isAllBroadcastTables(sqlStatementContext.getTablesContext().getTableNames())).thenReturn(false);
asserCheckResult(shardingAuditAlgorithm.check(sqlStatementContext, Collections.emptyList(), mock(Grantee.class), database), true, "");
}
@@ -86,7 +87,7 @@ public final class DMLShardingConditionsShardingAuditAlgorithmTest {
@Test
public void assertEmptyShardingConditionsCheck() {
when(sqlStatementContext.getSqlStatement()).thenReturn(mock(DMLStatement.class));
- when(database.getRuleMetaData().getSingleRule(ShardingRule.class)).thenReturn(rule);
+ when(database.getRuleMetaData()).thenReturn(new ShardingSphereRuleMetaData(Collections.singletonList(rule)));
when(rule.isAllBroadcastTables(sqlStatementContext.getTablesContext().getTableNames())).thenReturn(false);
when(rule.isShardingTable("t_order")).thenReturn(true);
asserCheckResult(shardingAuditAlgorithm.check(sqlStatementContext, Collections.emptyList(), mock(Grantee.class), database), false, "Not allow DML operation without sharding conditions");