This is an automated email from the ASF dual-hosted git repository.

panjuan 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 a9ceffd  Add column value match shadow algorithm (#13291)
a9ceffd is described below

commit a9ceffd979fcb22afdf27ebd5834ffd77e4a6638
Author: gin <[email protected]>
AuthorDate: Tue Oct 26 19:44:05 2021 +0800

    Add column value match shadow algorithm (#13291)
    
    * Add column value match shadow algorithm.
    
    * Update shadow ut.
---
 .../column/ColumnValueMatchShadowAlgorithm.java    | 91 ++++++++++++++++++++++
 ...pache.shardingsphere.shadow.spi.ShadowAlgorithm |  1 +
 .../ColumnValueMatchShadowAlgorithmTest.java       | 79 +++++++++++++++++++
 .../boot/YmlShadowSpringBootStarterTest.java       | 24 +++---
 .../src/test/resources/application-shadow-yml.yml  | 11 ++-
 .../main/resources/META-INF/namespace/shadow.xsd   |  1 +
 .../ShadowAlgorithmSpringNamespaceTest.java        | 24 +++---
 .../shadow-algorithm-application-context.xml       | 12 ++-
 8 files changed, 221 insertions(+), 22 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
new file mode 100644
index 0000000..20a44b8
--- /dev/null
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithm.java
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.shadow.algorithm.shadow.column;
+
+import com.google.common.base.Preconditions;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.shadow.api.shadow.ShadowOperationType;
+import 
org.apache.shardingsphere.shadow.api.shadow.column.ColumnShadowAlgorithm;
+import 
org.apache.shardingsphere.shadow.api.shadow.column.PreciseColumnShadowValue;
+
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Properties;
+
+/**
+ * Column value match shadow algorithm.
+ */
+@Getter
+@Setter
+public final class ColumnValueMatchShadowAlgorithm implements 
ColumnShadowAlgorithm<Comparable<?>> {
+    
+    private static final String COLUMN = "column";
+    
+    private static final String OPERATION = "operation";
+    
+    private static final String VALUE = "value";
+    
+    private Properties props = new Properties();
+    
+    private ShadowOperationType shadowOperationType;
+    
+    @Override
+    public void init() {
+        checkProps();
+    }
+    
+    private void checkProps() {
+        checkOperation();
+        checkColumn();
+        checkValue();
+    }
+    
+    private void checkValue() {
+        Object value = props.get(VALUE);
+        Preconditions.checkNotNull(value, "Column value match shadow algorithm 
value cannot be null.");
+    }
+    
+    private void checkColumn() {
+        String column = props.getProperty(COLUMN);
+        Preconditions.checkNotNull(column, "Column value match shadow 
algorithm column cannot be null.");
+    }
+    
+    private void checkOperation() {
+        String operationType = props.getProperty(OPERATION);
+        Preconditions.checkNotNull(operationType, "Column value match shadow 
algorithm operation cannot be null.");
+        Optional<ShadowOperationType> shadowOperationType = 
ShadowOperationType.contains(operationType);
+        Preconditions.checkState(shadowOperationType.isPresent(), "Column 
value match shadow algorithm operation must be one of select insert update 
delete.");
+        shadowOperationType.ifPresent(type -> this.shadowOperationType = type);
+    }
+    
+    @Override
+    public boolean isShadow(final Collection<String> shadowTableNames, final 
PreciseColumnShadowValue<Comparable<?>> shadowValue) {
+        boolean containTable = 
shadowTableNames.contains(shadowValue.getLogicTableName());
+        boolean isSameOperation = shadowOperationType == 
shadowValue.getShadowOperationType();
+        boolean isSameColumnName = Objects.equals(props.get(COLUMN), 
shadowValue.getColumnName());
+        boolean isSameColumnValue = 
props.get(VALUE).toString().equals(shadowValue.getValue());
+        return containTable && isSameOperation && isSameColumnName && 
isSameColumnValue;
+    }
+    
+    @Override
+    public String getType() {
+        return "COLUMN_VALUE_MATCH";
+    }
+}
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/resources/META-INF/services/org.apache.shardingsphere.shadow.spi.ShadowAlgorithm
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/resources/META-INF/services/org.apache.shardingsphere.shadow.spi.ShadowAlgorithm
index a428d4b..7d6f0d7 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/resources/META-INF/services/org.apache.shardingsphere.shadow.spi.ShadowAlgorithm
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/resources/META-INF/services/org.apache.shardingsphere.shadow.spi.ShadowAlgorithm
@@ -17,3 +17,4 @@
 
 
org.apache.shardingsphere.shadow.algorithm.shadow.note.SimpleSQLNoteShadowAlgorithm
 
org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnRegexMatchShadowAlgorithm
+org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnValueMatchShadowAlgorithm
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
new file mode 100644
index 0000000..6239cd7
--- /dev/null
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/algorithm/shadow/column/ColumnValueMatchShadowAlgorithmTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.shadow.algorithm.shadow.column;
+
+import org.apache.shardingsphere.shadow.api.shadow.ShadowOperationType;
+import 
org.apache.shardingsphere.shadow.api.shadow.column.PreciseColumnShadowValue;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class ColumnValueMatchShadowAlgorithmTest {
+    
+    private ColumnValueMatchShadowAlgorithm shadowAlgorithm;
+    
+    @Before
+    public void init() {
+        shadowAlgorithm = new ColumnValueMatchShadowAlgorithm();
+        shadowAlgorithm.setProps(createProperties());
+        shadowAlgorithm.init();
+    }
+    
+    private Properties createProperties() {
+        Properties properties = new Properties();
+        properties.setProperty("column", "shadow");
+        properties.setProperty("operation", "insert");
+        properties.setProperty("value", "1");
+        return properties;
+    }
+    
+    @Test
+    public void assertIsShadow() {
+        assertTrueCase();
+        assertFalseCase();
+    }
+    
+    private void assertTrueCase() {
+        assertThat(shadowAlgorithm.isShadow(createTableNames(), 
createPreciseColumnShadowValue("t_user", ShadowOperationType.INSERT, "shadow", 
"1")), is(true));
+        assertThat(shadowAlgorithm.isShadow(createTableNames(), 
createPreciseColumnShadowValue("t_order", ShadowOperationType.INSERT, "shadow", 
"1")), is(true));
+    }
+    
+    private void assertFalseCase() {
+        assertThat(shadowAlgorithm.isShadow(createTableNames(), 
createPreciseColumnShadowValue("auto", ShadowOperationType.INSERT, "shadow", 
"1")), is(false));
+        assertThat(shadowAlgorithm.isShadow(createTableNames(), 
createPreciseColumnShadowValue("t_user", ShadowOperationType.UPDATE, "shadow", 
"1")), is(false));
+        assertThat(shadowAlgorithm.isShadow(createTableNames(), 
createPreciseColumnShadowValue("t_user", ShadowOperationType.UPDATE, "auto", 
"1")), is(false));
+        assertThat(shadowAlgorithm.isShadow(createTableNames(), 
createPreciseColumnShadowValue("t_user", ShadowOperationType.UPDATE, "shadow", 
"2")), is(false));
+    }
+    
+    private PreciseColumnShadowValue<Comparable<?>> 
createPreciseColumnShadowValue(final String tableName, final 
ShadowOperationType operationType, final String columnName, final String value) 
{
+        return new PreciseColumnShadowValue<>(tableName, operationType, 
columnName, value);
+    }
+    
+    private Collection<String> createTableNames() {
+        Collection<String> shadowTableNames = new LinkedList<>();
+        shadowTableNames.add("t_user");
+        shadowTableNames.add("t_order");
+        return shadowTableNames;
+    }
+}
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
index 86e8cb1..39a513b 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.shadow.spring.boot;
 
 import 
org.apache.shardingsphere.shadow.algorithm.config.AlgorithmProvidedShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnRegexMatchShadowAlgorithm;
+import 
org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnValueMatchShadowAlgorithm;
 import 
org.apache.shardingsphere.shadow.algorithm.shadow.note.SimpleSQLNoteShadowAlgorithm;
 import 
org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
@@ -32,7 +33,6 @@ import 
org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import javax.annotation.Resource;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -56,12 +56,18 @@ public class YmlShadowSpringBootStarterTest {
     }
     
     private void assertShadowAlgorithms(final Map<String, ShadowAlgorithm> 
shadowAlgorithms) {
-        ShadowAlgorithm userIdMatchAlgorithm = 
shadowAlgorithms.get("user-id-match-algorithm");
-        assertThat(userIdMatchAlgorithm instanceof 
ColumnRegexMatchShadowAlgorithm, is(true));
-        assertThat(userIdMatchAlgorithm.getType(), is("COLUMN_REGEX_MATCH"));
-        assertThat(userIdMatchAlgorithm.getProps().get("operation"), 
is("insert"));
-        assertThat(userIdMatchAlgorithm.getProps().get("column"), 
is("user_id"));
-        assertThat(userIdMatchAlgorithm.getProps().get("regex"), is("[1]"));
+        ShadowAlgorithm userIdRegexMatchAlgorithm = 
shadowAlgorithms.get("user-id-regex-match-algorithm");
+        assertThat(userIdRegexMatchAlgorithm instanceof 
ColumnRegexMatchShadowAlgorithm, is(true));
+        assertThat(userIdRegexMatchAlgorithm.getType(), 
is("COLUMN_REGEX_MATCH"));
+        assertThat(userIdRegexMatchAlgorithm.getProps().get("operation"), 
is("insert"));
+        assertThat(userIdRegexMatchAlgorithm.getProps().get("column"), 
is("user_id"));
+        assertThat(userIdRegexMatchAlgorithm.getProps().get("regex"), 
is("[1]"));
+        ShadowAlgorithm userIdValueMatchAlgorithm = 
shadowAlgorithms.get("user-id-value-match-algorithm");
+        assertThat(userIdValueMatchAlgorithm instanceof 
ColumnValueMatchShadowAlgorithm, is(true));
+        assertThat(userIdValueMatchAlgorithm.getType(), 
is("COLUMN_VALUE_MATCH"));
+        assertThat(userIdValueMatchAlgorithm.getProps().get("operation"), 
is("insert"));
+        assertThat(userIdValueMatchAlgorithm.getProps().get("column"), 
is("user_id"));
+        assertThat(userIdValueMatchAlgorithm.getProps().get("value"), is(1));
         ShadowAlgorithm simpleNoteAlgorithm = 
shadowAlgorithms.get("simple-note-algorithm");
         assertThat(simpleNoteAlgorithm instanceof 
SimpleSQLNoteShadowAlgorithm, is(true));
         assertThat(simpleNoteAlgorithm.getType(), is("SIMPLE_NOTE"));
@@ -72,9 +78,9 @@ public class YmlShadowSpringBootStarterTest {
     private void assertShadowTables(final Map<String, 
ShadowTableConfiguration> shadowTables) {
         assertThat(shadowTables.size(), is(2));
         assertThat(shadowTables.get("t_order").getDataSourceNames().size(), 
is(2));
-        assertThat(shadowTables.get("t_order").getShadowAlgorithmNames(), 
is(Arrays.asList("user-id-match-algorithm", "simple-note-algorithm")));
+        assertThat(shadowTables.get("t_order").getShadowAlgorithmNames(), 
is(Arrays.asList("user-id-regex-match-algorithm", "simple-note-algorithm")));
         assertThat(shadowTables.get("t_user").getDataSourceNames().size(), 
is(1));
-        assertThat(shadowTables.get("t_user").getShadowAlgorithmNames(), 
is(Collections.singletonList("simple-note-algorithm")));
+        assertThat(shadowTables.get("t_user").getShadowAlgorithmNames(), 
is(Arrays.asList("user-id-value-match-algorithm", "simple-note-algorithm")));
     }
     
     private void assertShadowDataSources(final Map<String, 
ShadowDataSourceConfiguration> dataSources) {
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-yml.yml
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-yml.yml
index 527385a..6b55a24 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-yml.yml
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-yml.yml
@@ -31,19 +31,26 @@ spring:
           t_order:
             data-source-names: shadow-data-source-0,shadow-data-source-1
             shadow-algorithm-names:
-              - user-id-match-algorithm
+              - user-id-regex-match-algorithm
               - simple-note-algorithm
           t_user:
             data-source-names: shadow-data-source-1
             shadow-algorithm-names:
+              - user-id-value-match-algorithm
               - simple-note-algorithm
         shadow-algorithms:
-          user-id-match-algorithm:
+          user-id-regex-match-algorithm:
             type: COLUMN_REGEX_MATCH
             props:
               operation: insert
               column: user_id
               regex: "[1]"
+          user-id-value-match-algorithm:
+            type: COLUMN_VALUE_MATCH
+            props:
+              operation: insert
+              column: user_id
+              value: 1
           simple-note-algorithm:
             type: SIMPLE_NOTE
             props:
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/resources/META-INF/namespace/shadow.xsd
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/resources/META-INF/namespace/shadow.xsd
index ce633cd..c3a4e9f 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/resources/META-INF/namespace/shadow.xsd
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/resources/META-INF/namespace/shadow.xsd
@@ -79,6 +79,7 @@
     <xsd:simpleType name="algorithmType">
         <xsd:restriction base="xsd:string">
             <xsd:enumeration value="COLUMN_REGEX_MATCH" />
+            <xsd:enumeration value="COLUMN_VALUE_MATCH" />
             <xsd:enumeration value="SIMPLE_NOTE" />
         </xsd:restriction>
     </xsd:simpleType>
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
index 126513b..cf18830 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.shadow.spring.namespace;
 
 import 
org.apache.shardingsphere.shadow.algorithm.config.AlgorithmProvidedShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnRegexMatchShadowAlgorithm;
+import 
org.apache.shardingsphere.shadow.algorithm.shadow.column.ColumnValueMatchShadowAlgorithm;
 import 
org.apache.shardingsphere.shadow.algorithm.shadow.note.SimpleSQLNoteShadowAlgorithm;
 import 
org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.table.ShadowTableConfiguration;
@@ -29,7 +30,6 @@ import 
org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
 
 import javax.annotation.Resource;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -50,12 +50,18 @@ public final class ShadowAlgorithmSpringNamespaceTest 
extends AbstractJUnit4Spri
     }
     
     private void assertShadowAlgorithms(final Map<String, ShadowAlgorithm> 
shadowAlgorithms) {
-        ShadowAlgorithm userIdMatchAlgorithm = 
shadowAlgorithms.get("user-id-match-algorithm");
-        assertThat(userIdMatchAlgorithm instanceof 
ColumnRegexMatchShadowAlgorithm, is(true));
-        assertThat(userIdMatchAlgorithm.getType(), is("COLUMN_REGEX_MATCH"));
-        assertThat(userIdMatchAlgorithm.getProps().get("operation"), 
is("insert"));
-        assertThat(userIdMatchAlgorithm.getProps().get("column"), 
is("user_id"));
-        assertThat(userIdMatchAlgorithm.getProps().get("regex"), is("[1]"));
+        ShadowAlgorithm userIdRegexMatchAlgorithm = 
shadowAlgorithms.get("user-id-regex-match-algorithm");
+        assertThat(userIdRegexMatchAlgorithm instanceof 
ColumnRegexMatchShadowAlgorithm, is(true));
+        assertThat(userIdRegexMatchAlgorithm.getType(), 
is("COLUMN_REGEX_MATCH"));
+        assertThat(userIdRegexMatchAlgorithm.getProps().get("operation"), 
is("insert"));
+        assertThat(userIdRegexMatchAlgorithm.getProps().get("column"), 
is("user_id"));
+        assertThat(userIdRegexMatchAlgorithm.getProps().get("regex"), 
is("[1]"));
+        ShadowAlgorithm userIdValueMatchAlgorithm = 
shadowAlgorithms.get("user-id-value-match-algorithm");
+        assertThat(userIdValueMatchAlgorithm instanceof 
ColumnValueMatchShadowAlgorithm, is(true));
+        assertThat(userIdValueMatchAlgorithm.getType(), 
is("COLUMN_VALUE_MATCH"));
+        assertThat(userIdValueMatchAlgorithm.getProps().get("operation"), 
is("insert"));
+        assertThat(userIdValueMatchAlgorithm.getProps().get("column"), 
is("user_id"));
+        assertThat(userIdValueMatchAlgorithm.getProps().get("value"), is("1"));
         ShadowAlgorithm simpleNoteAlgorithm = 
shadowAlgorithms.get("simple-note-algorithm");
         assertThat(simpleNoteAlgorithm instanceof 
SimpleSQLNoteShadowAlgorithm, is(true));
         assertThat(simpleNoteAlgorithm.getType(), is("SIMPLE_NOTE"));
@@ -66,9 +72,9 @@ public final class ShadowAlgorithmSpringNamespaceTest extends 
AbstractJUnit4Spri
     private void assertShadowTables(final Map<String, 
ShadowTableConfiguration> shadowTables) {
         assertThat(shadowTables.size(), is(2));
         assertThat(shadowTables.get("t_order").getDataSourceNames().size(), 
is(2));
-        assertThat(shadowTables.get("t_order").getShadowAlgorithmNames(), 
is(Arrays.asList("user-id-match-algorithm", "simple-note-algorithm")));
+        assertThat(shadowTables.get("t_order").getShadowAlgorithmNames(), 
is(Arrays.asList("user-id-regex-match-algorithm", "simple-note-algorithm")));
         assertThat(shadowTables.get("t_user").getDataSourceNames().size(), 
is(1));
-        assertThat(shadowTables.get("t_user").getShadowAlgorithmNames(), 
is(Collections.singletonList("simple-note-algorithm")));
+        assertThat(shadowTables.get("t_user").getShadowAlgorithmNames(), 
is(Arrays.asList("user-id-value-match-algorithm", "simple-note-algorithm")));
     }
     
     private void assertShadowDataSources(final Map<String, 
ShadowDataSourceConfiguration> dataSources) {
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/resources/META-INF/spring/shadow-algorithm-application-context.xml
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/resources/META-INF/spring/shadow-algorithm-application-context.xml
index 6f8b5b0..21b1da5 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/resources/META-INF/spring/shadow-algorithm-application-context.xml
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/resources/META-INF/spring/shadow-algorithm-application-context.xml
@@ -24,13 +24,20 @@
                            
http://shardingsphere.apache.org/schema/shardingsphere/shadow
                            
http://shardingsphere.apache.org/schema/shardingsphere/shadow/shadow.xsd
                            ">
-    <shadow:shadow-algorithm id="user-id-match-algorithm" 
type="COLUMN_REGEX_MATCH">
+    <shadow:shadow-algorithm id="user-id-regex-match-algorithm" 
type="COLUMN_REGEX_MATCH">
         <props>
             <prop key="operation">insert</prop>
             <prop key="column">user_id</prop>
             <prop key="regex">[1]</prop>
         </props>
     </shadow:shadow-algorithm>
+    <shadow:shadow-algorithm id="user-id-value-match-algorithm" 
type="COLUMN_VALUE_MATCH">
+        <props>
+            <prop key="operation">insert</prop>
+            <prop key="column">user_id</prop>
+            <prop key="value">1</prop>
+        </props>
+    </shadow:shadow-algorithm>
     <shadow:shadow-algorithm id="simple-note-algorithm" type="SIMPLE_NOTE">
         <props>
             <prop key="shadow">true</prop>
@@ -42,10 +49,11 @@
         <shadow:data-source id="shadow-data-source-0" 
source-data-source-name="ds" shadow-data-source-name="ds-shadow"/>
         <shadow:data-source id="shadow-data-source-1" 
source-data-source-name="ds1" shadow-data-source-name="ds1-shadow"/>
         <shadow:shadow-table name="t_order" 
data-sources="shadow-data-source-0,shadow-data-source-1">
-            <shadow:algorithm shadow-algorithm-ref= "user-id-match-algorithm" 
/>
+            <shadow:algorithm shadow-algorithm-ref= 
"user-id-regex-match-algorithm" />
             <shadow:algorithm shadow-algorithm-ref= "simple-note-algorithm" />
         </shadow:shadow-table>
         <shadow:shadow-table name="t_user" data-sources="shadow-data-source-1">
+            <shadow:algorithm shadow-algorithm-ref= 
"user-id-value-match-algorithm" />
             <shadow:algorithm shadow-algorithm-ref= "simple-note-algorithm" />
         </shadow:shadow-table>
     </shadow:rule>

Reply via email to