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 14a2d75cc9b Add test cases on ShadowRuleConfigurationChecker (#33521)
14a2d75cc9b is described below
commit 14a2d75cc9b00668c1cc0b63c01520c023918211
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Nov 4 00:38:12 2024 +0800
Add test cases on ShadowRuleConfigurationChecker (#33521)
* Add ShadowDataSourceMappingsFinder
* Add ShadowDataSourceMappingsFinder
* Add ShadowDataSourceMappingsFinder
* Add ShadowDataSourceMappingsFinder
* Add test cases on ShadowRuleConfigurationChecker
---
.../checker/ShadowRuleConfigurationCheckerTest.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
index cbe581d5484..fca4809e4ee 100644
---
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
+++
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/checker/ShadowRuleConfigurationCheckerTest.java
@@ -27,6 +27,7 @@ import
org.apache.shardingsphere.shadow.config.table.ShadowTableConfiguration;
import
org.apache.shardingsphere.shadow.exception.metadata.MissingRequiredProductionDataSourceException;
import
org.apache.shardingsphere.shadow.exception.metadata.MissingRequiredShadowDataSourceException;
import
org.apache.shardingsphere.shadow.exception.metadata.NotImplementHintShadowAlgorithmException;
+import
org.apache.shardingsphere.shadow.exception.metadata.ShadowDataSourceMappingNotFoundException;
import org.apache.shardingsphere.test.fixture.jdbc.MockedDataSource;
import org.apache.shardingsphere.test.util.PropertiesBuilder;
import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
@@ -88,6 +89,21 @@ class ShadowRuleConfigurationCheckerTest {
return result;
}
+ @Test
+ void assertCheckWithInvalidShadowTableDataSourcesReferences() {
+ assertThrows(ShadowDataSourceMappingNotFoundException.class,
+ () -> ruleConfigChecker.check("foo_db",
createRuleConfigurationWithInvalidShadowTableDataSourcesReferences(),
createDataSourceMap(), Collections.emptyList()));
+ }
+
+ private ShadowRuleConfiguration
createRuleConfigurationWithInvalidShadowTableDataSourcesReferences() {
+ ShadowRuleConfiguration result = new ShadowRuleConfiguration();
+ result.setShadowAlgorithms(Collections.singletonMap("foo-algo", new
AlgorithmConfiguration("SQL_HINT", new Properties())));
+ result.setDefaultShadowAlgorithmName("foo-algo");
+ result.setDataSources(Collections.singleton(new
ShadowDataSourceConfiguration("foo_ds", "prod_ds", "shadow_ds")));
+ result.setTables(Collections.singletonMap("foo_tbl", new
ShadowTableConfiguration(Collections.singletonList("bar_ds"), new
LinkedList<>(Collections.singleton("foo-algo")))));
+ return result;
+ }
+
@Test
void assertCheckWithInvalidShadowTableAlgorithmsReferences() {
assertThrows(MissingRequiredAlgorithmException.class,