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 7862869e959 Add coverage for pg/mysql/firebird packet utilities 
(#37596)
7862869e959 is described below

commit 7862869e959a647454c2e8fc7ed21bc90eddc0c0
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Dec 31 23:29:41 2025 +0800

    Add coverage for pg/mysql/firebird packet utilities (#37596)
---
 AGENTS.md                                          |  3 +-
 .../firebird/err/FirebirdStatusVector.java         |  4 +-
 .../firebird/err/FirebirdStatusVectorTest.java     | 70 ++++++++++++++++++++++
 .../query/blob/FirebirdBlobRegistryTest.java       | 64 ++++++++++++++++++++
 .../value/time/MySQLFractionalSecondsTest.java     | 67 +++++++++++++++++++++
 .../constant/PostgreSQLValueFormatTest.java        | 44 ++++++++++++++
 .../PostgreSQLParameterDescriptionPacketTest.java  | 57 ++++++++++++++++++
 .../impl/PostgreSQLTextArrayValueParserTest.java   | 52 ++++++++++++++++
 .../PostgreSQLVarcharArrayValueParserTest.java     | 52 ++++++++++++++++
 .../PostgreSQLPortalSuspendedPacketTest.java       | 47 +++++++++++++++
 .../flush/PostgreSQLComFlushPacketTest.java        | 46 ++++++++++++++
 ...PostgreSQLPasswordAuthenticationPacketTest.java | 47 +++++++++++++++
 12 files changed, 549 insertions(+), 4 deletions(-)

diff --git a/AGENTS.md b/AGENTS.md
index 0a458a62e51..d17a87bbc14 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -34,7 +34,8 @@ This guide is written **for AI coding agents only**. Follow 
it literally; improv
 - **Continuous Verification**: rely on automated tests and integration 
validation.
 - **Test Naming Simplicity**: keep test names concise and scenario-focused 
(avoid “ReturnsXXX”/overly wordy or AI-like phrasing); describe the scenario 
directly.
 - **Coverage Discipline**: follow the dedicated coverage & branch checklist 
before coding when coverage targets are stated.
-- **One public method, one test**: each public production method must be 
covered by exactly one dedicated test method.
+- **Dedicated and scoped tests**: each public production method must be 
covered by dedicated test methods; each test method covers only one scenario 
and invokes the target public method at most once (repeat only when the same 
scenario needs extra assertions), and different branches/inputs belong in 
separate test methods.
+- **Parameterized tests naming**: all parameterized tests must set an explicit 
`name` including the index (e.g., `"[{index}] foo={0}"`) so scenarios are 
distinguishable in reports.
 - **Mocking Rule**: default to mocks; see Mocking & SPI Guidance for 
static/constructor mocking and spy avoidance details.
 ## Tool Usage Guide
 
diff --git 
a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/err/FirebirdStatusVector.java
 
b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/err/FirebirdStatusVector.java
index 84c8b9bbe20..2ef6c55093a 100644
--- 
a/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/err/FirebirdStatusVector.java
+++ 
b/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/err/FirebirdStatusVector.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.database.protocol.firebird.err;
 
 import lombok.Getter;
-import lombok.Setter;
 import 
org.apache.shardingsphere.database.protocol.firebird.packet.FirebirdPacket;
 import 
org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
 import org.firebirdsql.gds.ISCConstants;
@@ -29,12 +28,11 @@ import java.sql.SQLException;
  * Firebird status vector for errors handling.
  */
 @Getter
-@Setter
 public final class FirebirdStatusVector extends FirebirdPacket {
     
     private final int gdsCode;
     
-    private String errorMessage;
+    private final String errorMessage;
     
     public FirebirdStatusVector(final SQLException ex) {
         gdsCode = ex.getErrorCode() >= ISCConstants.isc_arith_except ? 
ex.getErrorCode() : ISCConstants.isc_random;
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/err/FirebirdStatusVectorTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/err/FirebirdStatusVectorTest.java
new file mode 100644
index 00000000000..418152a5eb8
--- /dev/null
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/err/FirebirdStatusVectorTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.err;
+
+import 
org.apache.shardingsphere.database.protocol.firebird.payload.FirebirdPacketPayload;
+import org.firebirdsql.gds.ISCConstants;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InOrder;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+@ExtendWith(MockitoExtension.class)
+class FirebirdStatusVectorTest {
+    
+    @Mock
+    private FirebirdPacketPayload payload;
+    
+    @Test
+    void assertWriteWithArithmeticCodeAndTrimmedMessage() {
+        SQLException richMessage = new SQLException("prefix; detail 
[SQLState:42000]", "42000", ISCConstants.isc_arith_except);
+        FirebirdStatusVector vector = new FirebirdStatusVector(richMessage);
+        assertThat(vector.getGdsCode(), is(richMessage.getErrorCode()));
+        assertThat(vector.getErrorMessage(), is("detail"));
+        vector.write(payload);
+        InOrder inOrder = inOrder(payload);
+        inOrder.verify(payload).writeInt4(ISCConstants.isc_arg_gds);
+        inOrder.verify(payload).writeInt4(ISCConstants.isc_arith_except);
+        inOrder.verify(payload).writeInt4(ISCConstants.isc_arg_string);
+        inOrder.verify(payload).writeString("detail");
+        inOrder.verify(payload).writeInt4(ISCConstants.isc_arg_end);
+        verifyNoMoreInteractions(payload);
+    }
+    
+    @Test
+    void assertWriteUsesRandomCodeWhenErrorCodeIsLowerThanArithExcept() {
+        SQLException plainMessage = new SQLException("plain", "00000", 
ISCConstants.isc_arith_except - 1);
+        FirebirdStatusVector vector = new FirebirdStatusVector(plainMessage);
+        vector.write(payload);
+        InOrder inOrder = inOrder(payload);
+        inOrder.verify(payload).writeInt4(ISCConstants.isc_arg_gds);
+        inOrder.verify(payload).writeInt4(ISCConstants.isc_random);
+        inOrder.verify(payload).writeInt4(ISCConstants.isc_arg_string);
+        inOrder.verify(payload).writeString("plain");
+        inOrder.verify(payload).writeInt4(ISCConstants.isc_arg_end);
+        verifyNoMoreInteractions(payload);
+    }
+}
diff --git 
a/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdBlobRegistryTest.java
 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdBlobRegistryTest.java
new file mode 100644
index 00000000000..d024dab4214
--- /dev/null
+++ 
b/database/protocol/dialect/firebird/src/test/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/blob/FirebirdBlobRegistryTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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 io.netty.buffer.UnpooledByteBufAllocator;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.StandardCharsets;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class FirebirdBlobRegistryTest {
+    
+    @Test
+    void assertBuildSegmentPayloadWhenSegmentMissing() {
+        FirebirdBlobRegistry.clearSegment();
+        
assertNull(FirebirdBlobRegistry.buildSegmentPayload(UnpooledByteBufAllocator.DEFAULT,
 StandardCharsets.UTF_8));
+    }
+    
+    @Test
+    void assertBuildSegmentPayloadWithoutPadding() {
+        byte[] segment = {1, 2, 3, 4};
+        FirebirdBlobRegistry.setSegment(segment);
+        ByteBuf buffer = 
FirebirdBlobRegistry.buildSegmentPayload(UnpooledByteBufAllocator.DEFAULT, 
StandardCharsets.UTF_8).getByteBuf();
+        assertThat(buffer.readInt(), is(segment.length));
+        byte[] actual = new byte[segment.length];
+        buffer.readBytes(actual);
+        assertThat(actual, is(segment));
+        assertThat(buffer.readableBytes(), is(0));
+        buffer.release();
+    }
+    
+    @Test
+    void assertBuildSegmentPayloadWithPadding() {
+        byte[] segment = {5, 6, 7};
+        FirebirdBlobRegistry.setSegment(segment);
+        ByteBuf buffer = 
FirebirdBlobRegistry.buildSegmentPayload(UnpooledByteBufAllocator.DEFAULT, 
StandardCharsets.UTF_8).getByteBuf();
+        assertThat(buffer.readInt(), is(segment.length));
+        byte[] actual = new byte[segment.length];
+        buffer.readBytes(actual);
+        assertThat(actual, is(segment));
+        assertThat(buffer.readableBytes(), is(1));
+        assertThat(buffer.readByte(), is((byte) 0));
+        buffer.release();
+    }
+}
diff --git 
a/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/time/MySQLFractionalSecondsTest.java
 
b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/time/MySQLFractionalSecondsTest.java
new file mode 100644
index 00000000000..ff234a7ee27
--- /dev/null
+++ 
b/database/protocol/dialect/mysql/src/test/java/org/apache/shardingsphere/database/protocol/mysql/packet/binlog/row/column/value/time/MySQLFractionalSecondsTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.mysql.packet.binlog.row.column.value.time;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import 
org.apache.shardingsphere.database.protocol.mysql.payload.MySQLPacketPayload;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.nio.charset.StandardCharsets;
+import java.util.stream.Stream;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class MySQLFractionalSecondsTest {
+    
+    @ParameterizedTest(name = "[{index}] precision={0}, expectedNanos={2}")
+    @MethodSource("fractionalSecondsArguments")
+    void assertNanosWithVariousPrecision(final int precision, final ByteBuf 
buf, final int expectedNanos, final int expectedRemaining) {
+        assertThat(new MySQLFractionalSeconds(precision, new 
MySQLPacketPayload(buf, StandardCharsets.UTF_8)).getNanos(), is(expectedNanos));
+        assertThat(buf.readableBytes(), is(expectedRemaining));
+    }
+    
+    private static Stream<Arguments> fractionalSecondsArguments() {
+        return Stream.of(
+                Arguments.of(1, writeByte(10), 100000000, 0),
+                Arguments.of(3, writeShort(2), 200000, 0),
+                Arguments.of(5, writeMedium(3), 3000, 0),
+                Arguments.of(0, writeByte(1), 0, 1));
+    }
+    
+    private static ByteBuf writeByte(final int value) {
+        ByteBuf result = Unpooled.buffer();
+        result.writeByte(value);
+        return result;
+    }
+    
+    private static ByteBuf writeShort(final int value) {
+        ByteBuf result = Unpooled.buffer();
+        result.writeShort(value);
+        return result;
+    }
+    
+    private static ByteBuf writeMedium(final int value) {
+        ByteBuf result = Unpooled.buffer();
+        result.writeMedium(value);
+        return result;
+    }
+}
diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/constant/PostgreSQLValueFormatTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/constant/PostgreSQLValueFormatTest.java
new file mode 100644
index 00000000000..ad198909a3a
--- /dev/null
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/constant/PostgreSQLValueFormatTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.postgresql.constant;
+
+import 
org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class PostgreSQLValueFormatTest {
+    
+    @Test
+    void assertValueOfText() {
+        assertThat(PostgreSQLValueFormat.valueOf(0), 
is(PostgreSQLValueFormat.TEXT));
+    }
+    
+    @Test
+    void assertValueOfBinary() {
+        assertThat(PostgreSQLValueFormat.valueOf(1), 
is(PostgreSQLValueFormat.BINARY));
+    }
+    
+    @Test
+    void assertValueOfThrowsOnUnknown() {
+        UnsupportedSQLOperationException ex = 
assertThrows(UnsupportedSQLOperationException.class, () -> 
PostgreSQLValueFormat.valueOf(2));
+        assertThat(ex.getMessage(), is("Unsupported SQL operation: Unsupported 
PostgreSQL format code `2`."));
+    }
+}
diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacketTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacketTest.java
new file mode 100644
index 00000000000..47f970b7bd8
--- /dev/null
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/PostgreSQLParameterDescriptionPacketTest.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.postgresql.packet.command.query;
+
+import 
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.PostgreSQLColumnType;
+import 
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLMessagePacketType;
+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.InOrder;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.Arrays;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+@ExtendWith(MockitoExtension.class)
+class PostgreSQLParameterDescriptionPacketTest {
+    
+    @Mock
+    private PostgreSQLPacketPayload payload;
+    
+    @Test
+    void assertWrite() {
+        new 
PostgreSQLParameterDescriptionPacket(Arrays.asList(PostgreSQLColumnType.INT4, 
PostgreSQLColumnType.TEXT)).write(payload);
+        InOrder inOrder = inOrder(payload);
+        inOrder.verify(payload).writeInt2(2);
+        
inOrder.verify(payload).writeInt4(PostgreSQLColumnType.INT4.getValue());
+        
inOrder.verify(payload).writeInt4(PostgreSQLColumnType.TEXT.getValue());
+        verifyNoMoreInteractions(payload);
+    }
+    
+    @Test
+    void assertGetIdentifier() {
+        assertThat(new 
PostgreSQLParameterDescriptionPacket(Arrays.asList(PostgreSQLColumnType.INT4, 
PostgreSQLColumnType.TEXT)).getIdentifier(),
+                is(PostgreSQLMessagePacketType.PARAMETER_DESCRIPTION));
+    }
+}
diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTextArrayValueParserTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTextArrayValueParserTest.java
new file mode 100644
index 00000000000..d31bd995701
--- /dev/null
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTextArrayValueParserTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.postgresql.packet.command.query.extended.bind.protocol.text.impl;
+
+import 
org.apache.shardingsphere.infra.exception.external.sql.type.wrapper.SQLWrapperException;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedConstruction;
+import org.postgresql.util.PGobject;
+
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mockConstruction;
+
+class PostgreSQLTextArrayValueParserTest {
+    
+    @Test
+    void assertParse() {
+        PGobject actual = new PostgreSQLTextArrayValueParser().parse("{c,d}");
+        assertThat(actual.getType(), is("text[]"));
+        assertThat(actual.getValue(), is("{c,d}"));
+    }
+    
+    @Test
+    void assertParseWithThrowsSQLException() {
+        try (MockedConstruction<PGobject> mocked = 
mockConstruction(PGobject.class, (mock, context) -> doThrow(new 
SQLException("failed")).when(mock).setValue(anyString()))) {
+            SQLWrapperException ex = assertThrows(SQLWrapperException.class, 
() -> new PostgreSQLTextArrayValueParser().parse("bad"));
+            assertThat(ex.getCause(), isA(SQLException.class));
+            assertThat(mocked.constructed().size(), is(1));
+        }
+    }
+}
diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharArrayValueParserTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharArrayValueParserTest.java
new file mode 100644
index 00000000000..459c866796a
--- /dev/null
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLVarcharArrayValueParserTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.postgresql.packet.command.query.extended.bind.protocol.text.impl;
+
+import 
org.apache.shardingsphere.infra.exception.external.sql.type.wrapper.SQLWrapperException;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedConstruction;
+import org.postgresql.util.PGobject;
+
+import java.sql.SQLException;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mockConstruction;
+
+class PostgreSQLVarcharArrayValueParserTest {
+    
+    @Test
+    void assertParse() {
+        PGobject actual = new 
PostgreSQLVarcharArrayValueParser().parse("{a,b}");
+        assertThat(actual.getType(), is("varchar[]"));
+        assertThat(actual.getValue(), is("{a,b}"));
+    }
+    
+    @Test
+    void assertParseThrowsOnSQLException() {
+        try (MockedConstruction<PGobject> mocked = 
mockConstruction(PGobject.class, (mock, context) -> doThrow(new 
SQLException("failed")).when(mock).setValue(anyString()))) {
+            SQLWrapperException ex = assertThrows(SQLWrapperException.class, 
() -> new PostgreSQLVarcharArrayValueParser().parse("bad"));
+            assertThat(ex.getCause(), instanceOf(SQLException.class));
+            assertThat(mocked.constructed().size(), is(1));
+        }
+    }
+}
diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/execute/PostgreSQLPortalSuspendedPacketTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/execute/PostgreSQLPortalSuspendedPacketTest.java
new file mode 100644
index 00000000000..762b6f5826e
--- /dev/null
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/execute/PostgreSQLPortalSuspendedPacketTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.postgresql.packet.command.query.extended.execute;
+
+import 
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLMessagePacketType;
+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.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.verifyNoInteractions;
+
+@ExtendWith(MockitoExtension.class)
+class PostgreSQLPortalSuspendedPacketTest {
+    
+    @Mock
+    private PostgreSQLPacketPayload payload;
+    
+    @Test
+    void assertWrite() {
+        new PostgreSQLPortalSuspendedPacket().write(payload);
+        verifyNoInteractions(payload);
+    }
+    
+    @Test
+    void assertGetIdentifier() {
+        assertThat(new PostgreSQLPortalSuspendedPacket().getIdentifier(), 
is(PostgreSQLMessagePacketType.PORTAL_SUSPENDED));
+    }
+}
diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/flush/PostgreSQLComFlushPacketTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/flush/PostgreSQLComFlushPacketTest.java
new file mode 100644
index 00000000000..df7f9d9b846
--- /dev/null
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/flush/PostgreSQLComFlushPacketTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.postgresql.packet.command.query.extended.flush;
+
+import 
org.apache.shardingsphere.database.protocol.postgresql.packet.command.PostgreSQLCommandPacketType;
+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.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+
+@ExtendWith(MockitoExtension.class)
+class PostgreSQLComFlushPacketTest {
+    
+    @Mock
+    private PostgreSQLPacketPayload payload;
+    
+    @Test
+    void assertWrite() {
+        assertDoesNotThrow(() -> new 
PostgreSQLComFlushPacket(payload).write(payload));
+    }
+    
+    @Test
+    void assertGetIdentifier() {
+        assertThat(new PostgreSQLComFlushPacket(payload).getIdentifier(), 
is(PostgreSQLCommandPacketType.FLUSH_COMMAND));
+    }
+}
diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/handshake/authentication/PostgreSQLPasswordAuthenticationPacketTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/handshake/authentication/PostgreSQLPasswordAuthenticationPacketTest.java
new file mode 100644
index 00000000000..58d261509f8
--- /dev/null
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/handshake/authentication/PostgreSQLPasswordAuthenticationPacketTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.postgresql.packet.handshake.authentication;
+
+import 
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLMessagePacketType;
+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.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.Mockito.verify;
+
+@ExtendWith(MockitoExtension.class)
+class PostgreSQLPasswordAuthenticationPacketTest {
+    
+    @Mock
+    private PostgreSQLPacketPayload payload;
+    
+    @Test
+    void assertWrite() {
+        new PostgreSQLPasswordAuthenticationPacket().write(payload);
+        verify(payload).writeInt4(3);
+    }
+    
+    @Test
+    void assertGetIdentifier() {
+        assertThat(new 
PostgreSQLPasswordAuthenticationPacket().getIdentifier(), 
is(PostgreSQLMessagePacketType.AUTHENTICATION_REQUEST));
+    }
+}

Reply via email to