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 7534d144dda Add more test cases on 
PostgreSQLDateBinaryProtocolValueTest (#38212)
7534d144dda is described below

commit 7534d144dda0c7cb80ac275d9e9e49106329e51b
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Feb 26 16:26:31 2026 +0800

    Add more test cases on PostgreSQLDateBinaryProtocolValueTest (#38212)
---
 .../PostgreSQLDateBinaryProtocolValueTest.java      | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
index 35c61c4cfbf..12922ea30c6 100644
--- 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLDateBinaryProtocolValueTest.java
@@ -21,15 +21,22 @@ import io.netty.buffer.Unpooled;
 import 
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.MockedConstruction;
 import org.mockito.junit.jupiter.MockitoExtension;
 import org.postgresql.jdbc.TimestampUtils;
 import org.postgresql.util.PSQLException;
+import org.postgresql.util.PSQLState;
 
 import java.nio.charset.StandardCharsets;
 import java.sql.Date;
 
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.Mockito.mockConstruction;
+import static org.mockito.Mockito.when;
 
 @ExtendWith(MockitoExtension.class)
 class PostgreSQLDateBinaryProtocolValueTest {
@@ -48,6 +55,20 @@ class PostgreSQLDateBinaryProtocolValueTest {
         assertThat(new PostgreSQLDateBinaryProtocolValue().read(payload, 4), 
is(expected));
     }
     
+    @Test
+    void assertReadWithException() {
+        PostgreSQLPacketPayload payload = new 
PostgreSQLPacketPayload(Unpooled.wrappedBuffer(new byte[4]), 
StandardCharsets.UTF_8);
+        try (MockedConstruction<TimestampUtils> ignored = 
mockConstruction(TimestampUtils.class, (mock, context) -> {
+            try {
+                when(mock.toDateBin(isNull(), 
any(byte[].class))).thenThrow(new PSQLException("failed", 
PSQLState.DATA_ERROR));
+            } catch (final PSQLException ex) {
+                throw new IllegalStateException(ex);
+            }
+        })) {
+            assertThrows(PSQLException.class, () -> new 
PostgreSQLDateBinaryProtocolValue().read(payload, 4));
+        }
+    }
+    
     @Test
     void assertWrite() throws PSQLException {
         byte[] actual = new byte[4];

Reply via email to