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 41dbfd6abcc Add more test cases on PostgreSQLCommandCompletePacketTest 
(#38207)
41dbfd6abcc is described below

commit 41dbfd6abccb3e54a922d6390bfcd07e56ab785c
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Feb 26 14:00:04 2026 +0800

    Add more test cases on PostgreSQLCommandCompletePacketTest (#38207)
---
 .../PostgreSQLCommandCompletePacketTest.java       | 39 ++++++++++------------
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/generic/PostgreSQLCommandCompletePacketTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/generic/PostgreSQLCommandCompletePacketTest.java
index 2dfffd520d3..070fd7a6f54 100644
--- 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/generic/PostgreSQLCommandCompletePacketTest.java
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/generic/PostgreSQLCommandCompletePacketTest.java
@@ -18,14 +18,13 @@
 package org.apache.shardingsphere.database.protocol.postgresql.packet.generic;
 
 import 
org.apache.shardingsphere.database.protocol.postgresql.packet.ByteBufTestUtils;
+import org.apache.shardingsphere.database.protocol.payload.PacketPayload;
 import 
org.apache.shardingsphere.database.protocol.postgresql.packet.identifier.PostgreSQLMessagePacketType;
 import 
org.apache.shardingsphere.database.protocol.postgresql.payload.PostgreSQLPacketPayload;
-import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.ArgumentsProvider;
-import org.junit.jupiter.params.provider.ArgumentsSource;
-import org.junit.jupiter.params.support.ParameterDeclarations;
+import org.junit.jupiter.params.provider.MethodSource;
 
 import java.nio.charset.StandardCharsets;
 import java.util.stream.Stream;
@@ -36,26 +35,22 @@ import static org.hamcrest.MatcherAssert.assertThat;
 class PostgreSQLCommandCompletePacketTest {
     
     @ParameterizedTest(name = "{0}")
-    @ArgumentsSource(TestCaseArgumentsProvider.class)
-    void assertReadWrite(final String sqlCommand, final String 
expectedDelimiter) {
-        long rowCount = 1L;
-        String expectedString = sqlCommand + expectedDelimiter + rowCount;
-        int expectedStringLength = expectedString.length();
-        PostgreSQLPacketPayload payload = new 
PostgreSQLPacketPayload(ByteBufTestUtils.createByteBuf(expectedStringLength + 
1), StandardCharsets.ISO_8859_1);
-        PostgreSQLCommandCompletePacket packet = new 
PostgreSQLCommandCompletePacket(sqlCommand, rowCount);
-        assertThat(packet.getIdentifier(), 
is(PostgreSQLMessagePacketType.COMMAND_COMPLETE));
-        packet.write(payload);
+    @MethodSource("writeCases")
+    void assertWrite(final String name, final String sqlCommand, final long 
rowCount, final String expectedString) {
+        PostgreSQLPacketPayload payload = new 
PostgreSQLPacketPayload(ByteBufTestUtils.createByteBuf(expectedString.length() 
+ 1), StandardCharsets.ISO_8859_1);
+        new PostgreSQLCommandCompletePacket(sqlCommand, 
rowCount).write((PacketPayload) payload);
         assertThat(payload.readStringNul(), is(expectedString));
     }
     
-    private static final class TestCaseArgumentsProvider implements 
ArgumentsProvider {
-        
-        @Override
-        public Stream<? extends Arguments> provideArguments(final 
ParameterDeclarations parameters, final ExtensionContext context) {
-            return Stream.of(
-                    Arguments.of("SELECT", " "),
-                    Arguments.of("INSERT", " 0 "),
-                    Arguments.of("MOVE", " "));
-        }
+    @Test
+    void assertGetIdentifier() {
+        assertThat(new PostgreSQLCommandCompletePacket("SELECT", 
1L).getIdentifier(), is(PostgreSQLMessagePacketType.COMMAND_COMPLETE));
+    }
+    
+    private static Stream<Arguments> writeCases() {
+        return Stream.of(
+                Arguments.of("insert command with oid and row count", 
"INSERT", 1L, "INSERT 0 1"),
+                Arguments.of("select command with row count", "SELECT", 2L, 
"SELECT 2"),
+                Arguments.of("create command without row count", "CREATE", 3L, 
"CREATE"));
     }
 }

Reply via email to