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 88bf89d6ad1 Add more test cases for Firebird blob packets (#38161)
88bf89d6ad1 is described below

commit 88bf89d6ad15e0f1eff49a6740f13b7204e1c4f1
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Feb 23 19:25:44 2026 +0800

    Add more test cases for Firebird blob packets (#38161)
---
 .../blob/FirebirdCreateBlobCommandPacket.java      |  5 +-
 .../query/blob/FirebirdOpenBlobCommandPacket.java  |  8 +--
 .../blob/FirebirdCancelBlobCommandPacketTest.java  | 14 +++---
 .../blob/FirebirdCloseBlobCommandPacketTest.java   | 14 +++---
 .../blob/FirebirdCreateBlobCommandPacketTest.java  | 19 ++++++++
 .../FirebirdGetBlobSegmentCommandPacketTest.java   |  9 +++-
 .../FirebirdGetBlobSegmentResponsePacketTest.java  | 57 ++++++++++++++++++++++
 .../blob/FirebirdOpenBlobCommandPacketTest.java    | 26 ++++++++++
 .../FirebirdPutBlobSegmentCommandPacketTest.java   | 32 +++++++++---
 .../blob/FirebirdSeekBlobCommandPacketTest.java    | 16 +++---
 10 files changed, 157 insertions(+), 43 deletions(-)

diff --git 
a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacket.java
 
b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacket.java
index 7e9907a04d5..9b0ffb5e3cc 100644
--- 
a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacket.java
+++ 
b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacket.java
@@ -63,10 +63,7 @@ public final class FirebirdCreateBlobCommandPacket extends 
FirebirdCommandPacket
      * @return length of packet
      */
     public static int getLength(final FirebirdCommandPacketType commandType, 
final FirebirdPacketPayload payload) {
-        Preconditions.checkArgument(
-                FirebirdCommandPacketType.CREATE_BLOB == commandType
-                        || FirebirdCommandPacketType.CREATE_BLOB2 == 
commandType,
-                "Unsupported blob command type: %s", commandType);
+        Preconditions.checkArgument(FirebirdCommandPacketType.CREATE_BLOB == 
commandType || FirebirdCommandPacketType.CREATE_BLOB2 == commandType, 
"Unsupported blob command type: %s", commandType);
         // reserved (4)
         int length = 4;
         if (FirebirdCommandPacketType.CREATE_BLOB2 == commandType) {
diff --git 
a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacket.java
 
b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacket.java
index 4443edb5146..3c145a53545 100644
--- 
a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacket.java
+++ 
b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacket.java
@@ -37,8 +37,7 @@ public final class FirebirdOpenBlobCommandPacket extends 
FirebirdCommandPacket {
     private final long blobId;
     
     public FirebirdOpenBlobCommandPacket(final FirebirdCommandPacketType 
commandType, final FirebirdPacketPayload payload) {
-        Preconditions.checkArgument(FirebirdCommandPacketType.OPEN_BLOB == 
commandType
-                || FirebirdCommandPacketType.OPEN_BLOB2 == commandType, 
"Unsupported blob command type: %s", commandType);
+        Preconditions.checkArgument(FirebirdCommandPacketType.OPEN_BLOB == 
commandType || FirebirdCommandPacketType.OPEN_BLOB2 == commandType, 
"Unsupported blob command type: %s", commandType);
         payload.skipReserved(4);
         if (FirebirdCommandPacketType.OPEN_BLOB2 == commandType) {
             ByteBuf buffer = payload.readBuffer();
@@ -63,10 +62,7 @@ public final class FirebirdOpenBlobCommandPacket extends 
FirebirdCommandPacket {
      * @return length of packet
      */
     public static int getLength(final FirebirdCommandPacketType commandType, 
final FirebirdPacketPayload payload) {
-        Preconditions.checkArgument(
-                FirebirdCommandPacketType.OPEN_BLOB == commandType
-                        || FirebirdCommandPacketType.OPEN_BLOB2 == commandType,
-                "Unsupported blob command type: %s", commandType);
+        Preconditions.checkArgument(FirebirdCommandPacketType.OPEN_BLOB == 
commandType || FirebirdCommandPacketType.OPEN_BLOB2 == commandType, 
"Unsupported blob command type: %s", commandType);
         // reserved (4)
         int length = 4;
         if (FirebirdCommandPacketType.OPEN_BLOB2 == commandType) {
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacketTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacketTest.java
index 0f7e32e3c38..19be7b9541b 100644
--- 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacketTest.java
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCancelBlobCommandPacketTest.java
@@ -19,28 +19,26 @@ package 
org.apache.shardingsphere.database.protocol.firebird.packet.command.quer
 
 import 
org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
 
-import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-@ExtendWith(MockitoExtension.class)
 class FirebirdCancelBlobCommandPacketTest {
     
-    @Mock
-    private FirebirdPacketPayload payload;
-    
     @Test
     void assertCancelBlobPacket() {
+        FirebirdPacketPayload payload = mock(FirebirdPacketPayload.class);
         when(payload.readInt4()).thenReturn(42);
         FirebirdCancelBlobCommandPacket packet = new 
FirebirdCancelBlobCommandPacket(payload);
         verify(payload).skipReserved(4);
         verify(payload).readInt4();
         assertThat(packet.getBlobHandle(), is(42));
+        packet.write(payload);
+        verifyNoMoreInteractions(payload);
     }
     
     @Test
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacketTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacketTest.java
index 42dd3bde5ac..7692c69cd9a 100644
--- 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacketTest.java
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCloseBlobCommandPacketTest.java
@@ -19,28 +19,26 @@ package 
org.apache.shardingsphere.database.protocol.firebird.packet.command.quer
 
 import 
org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
 
-import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-@ExtendWith(MockitoExtension.class)
 class FirebirdCloseBlobCommandPacketTest {
     
-    @Mock
-    private FirebirdPacketPayload payload;
-    
     @Test
     void assertCloseBlobPacket() {
+        FirebirdPacketPayload payload = mock(FirebirdPacketPayload.class);
         when(payload.readInt4()).thenReturn(99);
         FirebirdCloseBlobCommandPacket packet = new 
FirebirdCloseBlobCommandPacket(payload);
         verify(payload).skipReserved(4);
         verify(payload).readInt4();
         assertThat(packet.getBlobHandle(), is(99));
+        packet.write(payload);
+        verifyNoMoreInteractions(payload);
     }
     
     @Test
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacketTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacketTest.java
index 87f44396b67..ddf127b0e14 100644
--- 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacketTest.java
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdCreateBlobCommandPacketTest.java
@@ -27,8 +27,11 @@ import org.mockito.junit.jupiter.MockitoExtension;
 
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 @ExtendWith(MockitoExtension.class)
@@ -47,6 +50,10 @@ class FirebirdCreateBlobCommandPacketTest {
         assertThat(packet.getTransactionId(), is(42));
         assertThat(packet.getRequestedBlobId(), is(0x0102030405060708L));
         assertThat(packet.getBlobParameterBuffer().length, is(0));
+        packet.write(payload);
+        verify(payload).readInt4();
+        verify(payload).readInt8();
+        verifyNoMoreInteractions(payload);
     }
     
     @Test
@@ -62,6 +69,12 @@ class FirebirdCreateBlobCommandPacketTest {
         assertThat(packet.getBlobParameterBuffer(), is(new byte[]{1, 2, 3, 
4}));
     }
     
+    @Test
+    void assertCreateBlobPacketWithUnsupportedCommandType() {
+        assertThrows(IllegalArgumentException.class, () -> new 
FirebirdCreateBlobCommandPacket(FirebirdCommandPacketType.OPEN_BLOB, payload));
+        verifyNoInteractions(payload);
+    }
+    
     @Test
     void assertGetLengthWithoutBpb() {
         
assertThat(FirebirdCreateBlobCommandPacket.getLength(FirebirdCommandPacketType.CREATE_BLOB,
 payload), is(16));
@@ -73,4 +86,10 @@ class FirebirdCreateBlobCommandPacketTest {
         
assertThat(FirebirdCreateBlobCommandPacket.getLength(FirebirdCommandPacketType.CREATE_BLOB2,
 payload), is(28));
         verify(payload).getBufferLength(4);
     }
+    
+    @Test
+    void assertGetLengthWithUnsupportedCommandType() {
+        assertThrows(IllegalArgumentException.class, () -> 
FirebirdCreateBlobCommandPacket.getLength(FirebirdCommandPacketType.OPEN_BLOB, 
payload));
+        verifyNoInteractions(payload);
+    }
 }
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacketTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacketTest.java
index b38b3a6287c..fbcc677fe74 100644
--- 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacketTest.java
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentCommandPacketTest.java
@@ -26,7 +26,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
 
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 @ExtendWith(MockitoExtension.class)
@@ -40,11 +42,14 @@ class FirebirdGetBlobSegmentCommandPacketTest {
         when(payload.readInt4()).thenReturn(11, 3);
         when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(new 
byte[]{1, 2, 3}));
         FirebirdGetBlobSegmentCommandPacket packet = new 
FirebirdGetBlobSegmentCommandPacket(payload);
-        verify(payload).skipReserved(4);
-        verify(payload).readBuffer();
         assertThat(packet.getBlobHandle(), is(11));
         assertThat(packet.getSegmentLength(), is(3));
         assertThat(packet.getSegment(), is(new byte[]{1, 2, 3}));
+        verify(payload).skipReserved(4);
+        verify(payload, times(2)).readInt4();
+        verify(payload).readBuffer();
+        packet.write(payload);
+        verifyNoMoreInteractions(payload);
     }
     
     @Test
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentResponsePacketTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentResponsePacketTest.java
new file mode 100644
index 00000000000..89c4b3fa81f
--- /dev/null
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdGetBlobSegmentResponsePacketTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.database.protocol.firebird.packet.command.query.blob;
+
+import io.netty.buffer.ByteBuf;
+import 
org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.stream.Stream;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class FirebirdGetBlobSegmentResponsePacketTest {
+    
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("assertWriteArguments")
+    void assertWrite(final String name,
+                     final byte[] segment, final int expectedLength, final int 
expectedWriteBytesCount, final int expectedGetByteBufCount, final int 
expectedPad, final int expectedPadCallCount) {
+        FirebirdPacketPayload payload = mock(FirebirdPacketPayload.class);
+        ByteBuf byteBuf = mock(ByteBuf.class);
+        if (expectedGetByteBufCount > 0) {
+            when(payload.getByteBuf()).thenReturn(byteBuf);
+        }
+        new FirebirdGetBlobSegmentResponsePacket(segment).write(payload);
+        verify(payload).writeInt2LE(expectedLength);
+        verify(payload, times(expectedWriteBytesCount)).writeBytes(segment);
+        verify(payload, times(expectedGetByteBufCount)).getByteBuf();
+        verify(byteBuf, times(expectedPadCallCount)).writeZero(expectedPad);
+    }
+    
+    private static Stream<Arguments> assertWriteArguments() {
+        return Stream.of(
+                Arguments.of("empty_segment", new byte[0], 0, 0, 0, 0, 0),
+                Arguments.of("aligned_segment", new byte[]{1, 2, 3, 4}, 4, 1, 
0, 0, 0),
+                Arguments.of("unaligned_segment", new byte[]{1, 2, 3}, 3, 1, 
1, 1, 1));
+    }
+}
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacketTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacketTest.java
index a3a73956920..fde8dd32529 100644
--- 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacketTest.java
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdOpenBlobCommandPacketTest.java
@@ -27,8 +27,11 @@ import org.mockito.junit.jupiter.MockitoExtension;
 
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 @ExtendWith(MockitoExtension.class)
@@ -47,6 +50,10 @@ class FirebirdOpenBlobCommandPacketTest {
         assertThat(packet.getBlobParameterBuffer().length, is(0));
         assertThat(packet.getTransactionId(), is(5));
         assertThat(packet.getBlobId(), is(7L));
+        packet.write(payload);
+        verify(payload).readInt4();
+        verify(payload).readInt8();
+        verifyNoMoreInteractions(payload);
     }
     
     @Test
@@ -62,8 +69,27 @@ class FirebirdOpenBlobCommandPacketTest {
         assertThat(packet.getBlobId(), is(12L));
     }
     
+    @Test
+    void assertOpenBlobPacketWithUnsupportedCommandType() {
+        assertThrows(IllegalArgumentException.class, () -> new 
FirebirdOpenBlobCommandPacket(FirebirdCommandPacketType.CREATE_BLOB, payload));
+        verifyNoInteractions(payload);
+    }
+    
     @Test
     void assertGetLengthWithoutBpb() {
         
assertThat(FirebirdOpenBlobCommandPacket.getLength(FirebirdCommandPacketType.OPEN_BLOB,
 payload), is(16));
     }
+    
+    @Test
+    void assertGetLengthWithBpb() {
+        when(payload.getBufferLength(4)).thenReturn(10);
+        
assertThat(FirebirdOpenBlobCommandPacket.getLength(FirebirdCommandPacketType.OPEN_BLOB2,
 payload), is(26));
+        verify(payload).getBufferLength(4);
+    }
+    
+    @Test
+    void assertGetLengthWithUnsupportedCommandType() {
+        assertThrows(IllegalArgumentException.class, () -> 
FirebirdOpenBlobCommandPacket.getLength(FirebirdCommandPacketType.CREATE_BLOB, 
payload));
+        verifyNoInteractions(payload);
+    }
 }
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacketTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacketTest.java
index 23f94dc703b..6a9cef535f9 100644
--- 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacketTest.java
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdPutBlobSegmentCommandPacketTest.java
@@ -19,6 +19,7 @@ package 
org.apache.shardingsphere.database.protocol.firebird.packet.command.quer
 
 import io.netty.buffer.Unpooled;
 import 
org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
@@ -26,8 +27,11 @@ import org.mockito.junit.jupiter.MockitoExtension;
 
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
 @ExtendWith(MockitoExtension.class)
@@ -36,20 +40,34 @@ class FirebirdPutBlobSegmentCommandPacketTest {
     @Mock
     private FirebirdPacketPayload payload;
     
+    @AfterEach
+    void clearBlobSegment() {
+        FirebirdBlobRegistry.clearSegment();
+    }
+    
     @Test
     void assertPutBlobSegmentPacket() {
         when(payload.readInt4()).thenReturn(15, 3);
         when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(new 
byte[]{5, 6, 7}));
-        final FirebirdPutBlobSegmentCommandPacket packet = new 
FirebirdPutBlobSegmentCommandPacket(payload);
-        
-        verify(payload).skipReserved(4);
-        verify(payload, times(2)).readInt4();
-        verify(payload).readBuffer();
-        
+        FirebirdPutBlobSegmentCommandPacket packet = new 
FirebirdPutBlobSegmentCommandPacket(payload);
         assertThat(packet.getBlobHandle(), is(15));
         assertThat(packet.getSegmentLength(), is(3));
         assertThat(packet.getSegment(), is(new byte[]{5, 6, 7}));
-        
+        assertThat(FirebirdBlobRegistry.getSegment(), is(new byte[]{5, 6, 7}));
+        verify(payload).skipReserved(4);
+        verify(payload, times(2)).readInt4();
+        verify(payload).readBuffer();
+        packet.write(payload);
+        verifyNoMoreInteractions(payload);
+    }
+    
+    @Test
+    void assertPutBlobSegmentPacketWithMismatchLength() {
+        FirebirdBlobRegistry.setSegment(new byte[]{9, 9});
+        when(payload.readInt4()).thenReturn(15, 2);
+        when(payload.readBuffer()).thenReturn(Unpooled.wrappedBuffer(new 
byte[]{5, 6, 7}));
+        assertThrows(IllegalArgumentException.class, () -> new 
FirebirdPutBlobSegmentCommandPacket(payload));
+        assertNull(FirebirdBlobRegistry.getSegment());
     }
     
     @Test
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacketTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacketTest.java
index 1b8e14c02f2..416f739321f 100644
--- 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacketTest.java
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdSeekBlobCommandPacketTest.java
@@ -19,29 +19,29 @@ package 
org.apache.shardingsphere.database.protocol.firebird.packet.command.quer
 
 import 
org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
 
-import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
 
-@ExtendWith(MockitoExtension.class)
 class FirebirdSeekBlobCommandPacketTest {
     
-    @Mock
-    private FirebirdPacketPayload payload;
-    
     @Test
     void assertSeekBlobPacket() {
+        FirebirdPacketPayload payload = mock(FirebirdPacketPayload.class);
         when(payload.readInt4()).thenReturn(21, 2, 128);
         FirebirdSeekBlobCommandPacket packet = new 
FirebirdSeekBlobCommandPacket(payload);
         verify(payload).skipReserved(4);
+        verify(payload, times(3)).readInt4();
         assertThat(packet.getBlobHandle(), is(21));
         assertThat(packet.getSeekMode(), is(2));
         assertThat(packet.getOffset(), is(128));
+        packet.write(payload);
+        verifyNoMoreInteractions(payload);
     }
     
     @Test

Reply via email to