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 b660cdf1cc0 Add test cases on MySQLBinlogBinaryStringHandler (#33418)
b660cdf1cc0 is described below

commit b660cdf1cc0d4739e5916ec66bcbc3e12ffc6fe9
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Oct 27 13:38:31 2024 +0800

    Add test cases on MySQLBinlogBinaryStringHandler (#33418)
    
    * Add test cases on MySQLBinlogBinaryStringHandler
    
    * Add test cases on MySQLBinlogBinaryStringHandler
---
 .../binary/MySQLBinlogBinaryStringHandlerTest.java | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git 
a/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/binary/MySQLBinlogBinaryStringHandlerTest.java
 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/binary/MySQLBinlogBinaryStringHandlerTest.java
new file mode 100644
index 00000000000..7df2213ff38
--- /dev/null
+++ 
b/kernel/data-pipeline/dialect/mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/incremental/binlog/data/binary/MySQLBinlogBinaryStringHandlerTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.data.pipeline.mysql.ingest.incremental.binlog.data.binary;
+
+import 
org.apache.shardingsphere.data.pipeline.core.metadata.model.PipelineColumnMetaData;
+import 
org.apache.shardingsphere.db.protocol.mysql.packet.binlog.row.column.value.string.MySQLBinaryString;
+import org.junit.jupiter.api.Test;
+
+import java.sql.Types;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class MySQLBinlogBinaryStringHandlerTest {
+    
+    @Test
+    void assertHandleWithBinaryColumn() {
+        PipelineColumnMetaData metaData = mock(PipelineColumnMetaData.class);
+        when(metaData.getDataType()).thenReturn(Types.BINARY);
+        MySQLBinaryString value = new MySQLBinaryString(new byte[]{49});
+        assertThat(MySQLBinlogBinaryStringHandler.handle(metaData, value), 
is(new byte[]{49}));
+    }
+    
+    @Test
+    void assertHandleWithNotBinaryColumn() {
+        PipelineColumnMetaData metaData = mock(PipelineColumnMetaData.class);
+        when(metaData.getDataType()).thenReturn(Types.VARCHAR);
+        MySQLBinaryString value = new MySQLBinaryString(new byte[]{49});
+        assertThat(MySQLBinlogBinaryStringHandler.handle(metaData, value), 
is("1"));
+    }
+}

Reply via email to