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 adfc4febb36 Add more test cases on bind.protocol.text package (#38215)
adfc4febb36 is described below

commit adfc4febb3695d78c9de1f766ec209ad67e73633
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Feb 26 17:40:23 2026 +0800

    Add more test cases on bind.protocol.text package (#38215)
---
 .../text/impl/PostgreSQLBitValueParserTest.java    | 26 ++++++++-
 .../text/impl/PostgreSQLDateValueParserTest.java   | 49 ++++++++++++++--
 .../text/impl/PostgreSQLJsonValueParserTest.java   | 26 ++++++++-
 .../text/impl/PostgreSQLTimeValueParserTest.java   | 60 +++++++++----------
 .../impl/PostgreSQLTimestampValueParserTest.java   | 67 +++++++++-------------
 5 files changed, 143 insertions(+), 85 deletions(-)

diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParserTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParserTest.java
index ce2361837ae..bfb656064b0 100644
--- 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParserTest.java
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLBitValueParserTest.java
@@ -17,18 +17,38 @@
 
 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.Matchers.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 PostgreSQLBitValueParserTest {
     
     @Test
-    void assertParse() {
+    void assertParse() throws SQLException {
+        PGobject expected = new PGobject();
+        expected.setType("bit");
+        expected.setValue("1");
         PGobject actual = new PostgreSQLBitValueParser().parse("1");
-        assertThat(actual.getType(), is("bit"));
-        assertThat(actual.getValue(), is("1"));
+        assertThat(actual, is(expected));
+    }
+    
+    @Test
+    void assertParseWithSQLException() {
+        try (MockedConstruction<PGobject> mocked = 
mockConstruction(PGobject.class, (mock, context) -> doThrow(new 
SQLException("failed")).when(mock).setValue(anyString()))) {
+            SQLWrapperException actual = 
assertThrows(SQLWrapperException.class, () -> new 
PostgreSQLBitValueParser().parse("1"));
+            assertThat(actual.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/PostgreSQLDateValueParserTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParserTest.java
index 91ed133b01c..3ecc7a17845 100644
--- 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParserTest.java
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLDateValueParserTest.java
@@ -17,22 +17,59 @@
 
 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.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.mockito.MockedConstruction;
+import org.postgresql.jdbc.TimestampUtils;
 
 import java.sql.Date;
+import java.sql.SQLException;
 import java.time.LocalDate;
-import java.time.ZoneOffset;
+import java.util.stream.Stream;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.isA;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.Mockito.mockConstruction;
+import static org.mockito.Mockito.when;
 
 class PostgreSQLDateValueParserTest {
     
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("parseSuccessArguments")
+    void assertParseWithDateTimeFormatter(final String name, final String 
input, final Date expected) {
+        assertThat(new PostgreSQLDateValueParser().parse(input), is(expected));
+    }
+    
     @Test
-    void assertParse() {
-        assertThat(new PostgreSQLDateValueParser().parse("2020-01-01"), 
is(Date.valueOf(LocalDate.of(2020, 1, 1))));
-        assertThat(new PostgreSQLDateValueParser().parse("2020-01-01 +08"), 
is(Date.valueOf(LocalDate.of(2020, 1, 
1).atStartOfDay(ZoneOffset.of("+8")).toLocalDate())));
-        assertThat(new PostgreSQLDateValueParser().parse("2020-01-01 +08:00"), 
is(Date.valueOf(LocalDate.of(2020, 1, 
1).atStartOfDay(ZoneOffset.of("+8")).toLocalDate())));
-        assertThat(new PostgreSQLDateValueParser().parse("2020-01-01 
+08:00:00"), is(Date.valueOf(LocalDate.of(2020, 1, 
1).atStartOfDay(ZoneOffset.of("+8")).toLocalDate())));
+    void assertParseWithTimestampUtilsFallback() throws SQLException {
+        assertThat(new PostgreSQLDateValueParser().parse("infinity"), is(new 
TimestampUtils(false, null).toDate(null, "infinity")));
+    }
+    
+    @Test
+    void assertParseWithTimestampUtilsException() {
+        try (MockedConstruction<TimestampUtils> ignored = 
mockConstruction(TimestampUtils.class, (mock, context) -> {
+            try {
+                when(mock.toDate(isNull(), anyString())).thenThrow(new 
SQLException("failed"));
+            } catch (final SQLException ex) {
+                throw new IllegalStateException(ex);
+            }
+        })) {
+            assertThat(assertThrows(SQLWrapperException.class, () -> new 
PostgreSQLDateValueParser().parse("bad")).getCause(), isA(SQLException.class));
+        }
+    }
+    
+    private static Stream<Arguments> parseSuccessArguments() {
+        return Stream.of(
+                Arguments.of("date only", "2020-01-01", 
Date.valueOf(LocalDate.of(2020, 1, 1))),
+                Arguments.of("date with short offset", "2020-01-01 +08", 
Date.valueOf(LocalDate.of(2020, 1, 1))),
+                Arguments.of("date with offset", "2020-01-01 +08:00", 
Date.valueOf(LocalDate.of(2020, 1, 1))),
+                Arguments.of("date with long offset", "2020-01-01 +08:00:00", 
Date.valueOf(LocalDate.of(2020, 1, 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/PostgreSQLJsonValueParserTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParserTest.java
index 1e11fec69e0..1805fae5521 100644
--- 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParserTest.java
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLJsonValueParserTest.java
@@ -17,18 +17,38 @@
 
 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.Matchers.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 PostgreSQLJsonValueParserTest {
     
     @Test
-    void assertParse() {
+    void assertParse() throws SQLException {
+        PGobject expected = new PGobject();
+        expected.setType("json");
+        expected.setValue("['input']");
         PGobject actual = new PostgreSQLJsonValueParser().parse("['input']");
-        assertThat(actual.getType(), is("json"));
-        assertThat(actual.getValue(), is("['input']"));
+        assertThat(actual, is(expected));
+    }
+    
+    @Test
+    void assertParseWithSQLException() {
+        try (MockedConstruction<PGobject> mocked = 
mockConstruction(PGobject.class, (mock, context) -> doThrow(new 
SQLException("failed")).when(mock).setValue(anyString()))) {
+            SQLWrapperException actual = 
assertThrows(SQLWrapperException.class, () -> new 
PostgreSQLJsonValueParser().parse("bad"));
+            assertThat(actual.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/PostgreSQLTimeValueParserTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParserTest.java
index 05feee45759..0a77e29122d 100644
--- 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParserTest.java
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimeValueParserTest.java
@@ -17,54 +17,46 @@
 
 package 
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
 
-import org.junit.jupiter.api.extension.ExtensionContext;
+import 
org.apache.shardingsphere.infra.exception.generic.UnsupportedSQLOperationException;
+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.time.LocalTime;
 import java.util.stream.Stream;
 
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 class PostgreSQLTimeValueParserTest {
     
     @ParameterizedTest(name = "{0}")
-    @ArgumentsSource(TestCaseArgumentsProvider.class)
-    void assertParse(final String input, final LocalTime expected) {
+    @MethodSource("parseSuccessArguments")
+    void assertParse(final String name, final String input, final LocalTime 
expected) {
         assertThat(new PostgreSQLTimeValueParser().parse(input), is(expected));
     }
     
-    private static final class TestCaseArgumentsProvider implements 
ArgumentsProvider {
-        
-        @Override
-        public Stream<? extends Arguments> provideArguments(final 
ParameterDeclarations parameters, final ExtensionContext context) {
-            return Stream.of(Arguments.of("2323", LocalTime.of(23, 23, 0)),
-                    Arguments.of("23:23", LocalTime.of(23, 23, 0)),
-                    Arguments.of("232323", LocalTime.of(23, 23, 23)),
-                    Arguments.of("23:23:23", LocalTime.of(23, 23, 23)),
-                    Arguments.of("23:23:23.1", LocalTime.of(23, 23, 23, 
100_000_000)),
-                    Arguments.of("23:23:23.12", LocalTime.of(23, 23, 23, 
120_000_000)),
-                    Arguments.of("23:23:23.123", LocalTime.of(23, 23, 23, 
123_000_000)),
-                    Arguments.of("23:23:23.123+08", LocalTime.of(23, 23, 23, 
123_000_000)),
-                    Arguments.of("23:23:23.123+08", LocalTime.of(23, 23, 23, 
123_000_000)),
-                    Arguments.of("23:23:23.12345", LocalTime.of(23, 23, 23, 
123_450_000)),
-                    Arguments.of("23:23:23.12345+0800", LocalTime.of(23, 23, 
23, 123_450_000)),
-                    Arguments.of("23:23:23.12345+0800", LocalTime.of(23, 23, 
23, 123_450_000)),
-                    Arguments.of("23:23:23.12345+08:00:00", LocalTime.of(23, 
23, 23, 123_450_000)),
-                    Arguments.of("23:23:23.12345+08:00:00", LocalTime.of(23, 
23, 23, 123_450_000)),
-                    Arguments.of("23:23:23.12345+08:00:00", LocalTime.of(23, 
23, 23, 123_450_000)),
-                    Arguments.of("23:23:23.123456", LocalTime.of(23, 23, 23, 
123_456_000)),
-                    Arguments.of("23:23:23.1234567", LocalTime.of(23, 23, 23, 
123_456_700)),
-                    Arguments.of("23:23:23.12345678", LocalTime.of(23, 23, 23, 
123_456_780)),
-                    Arguments.of("23:23:23.123456789", LocalTime.of(23, 23, 
23, 123_456_789)),
-                    Arguments.of("23:23:23.123456 +08:00", LocalTime.of(23, 
23, 23, 123_456_000)),
-                    Arguments.of("23:23:23.123456 -08:00", LocalTime.of(23, 
23, 23, 123_456_000)),
-                    Arguments.of("23:23:23.123456789 +08:00", LocalTime.of(23, 
23, 23, 123_456_789)),
-                    Arguments.of("23:23:23.123456", LocalTime.of(23, 23, 23, 
123_456_000)));
-        }
+    @Test
+    void assertParseWithUnsupportedTimeFormat() {
+        assertThat(assertThrows(UnsupportedSQLOperationException.class,
+                () -> new 
PostgreSQLTimeValueParser().parse("bad")).getMessage(), is("Unsupported SQL 
operation: Unsupported time format: [bad]."));
+    }
+    
+    private static Stream<Arguments> parseSuccessArguments() {
+        return Stream.of(
+                Arguments.of("compact hour minute", "2323", LocalTime.of(23, 
23, 0)),
+                Arguments.of("hour minute", "23:23", LocalTime.of(23, 23, 0)),
+                Arguments.of("compact with second", "232323", LocalTime.of(23, 
23, 23)),
+                Arguments.of("with second", "23:23:23", LocalTime.of(23, 23, 
23)),
+                Arguments.of("single fraction", "23:23:23.1", LocalTime.of(23, 
23, 23, 100_000_000)),
+                Arguments.of("three fractions", "23:23:23.123", 
LocalTime.of(23, 23, 23, 123_000_000)),
+                Arguments.of("with offset", "23:23:23.123+08", 
LocalTime.of(23, 23, 23, 123_000_000)),
+                Arguments.of("with long fraction and compact zone", 
"23:23:23.12345+0800", LocalTime.of(23, 23, 23, 123_450_000)),
+                Arguments.of("with long zone", "23:23:23.12345+08:00:00", 
LocalTime.of(23, 23, 23, 123_450_000)),
+                Arguments.of("with spacing and positive zone", 
"23:23:23.123456 +08:00", LocalTime.of(23, 23, 23, 123_456_000)),
+                Arguments.of("with spacing and negative zone", 
"23:23:23.123456 -08:00", LocalTime.of(23, 23, 23, 123_456_000)),
+                Arguments.of("with max nanos", "23:23:23.123456789", 
LocalTime.of(23, 23, 23, 123_456_789)));
     }
 }
diff --git 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParserTest.java
 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParserTest.java
index da071f06b6b..4a9f7922038 100644
--- 
a/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParserTest.java
+++ 
b/database/protocol/dialect/postgresql/src/test/java/org/apache/shardingsphere/database/protocol/postgresql/packet/command/query/extended/bind/protocol/text/impl/PostgreSQLTimestampValueParserTest.java
@@ -17,59 +17,48 @@
 
 package 
org.apache.shardingsphere.database.protocol.postgresql.packet.command.query.extended.bind.protocol.text.impl;
 
-import org.junit.jupiter.api.extension.ExtensionContext;
+import 
org.apache.shardingsphere.infra.exception.external.sql.type.wrapper.SQLWrapperException;
+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.sql.SQLException;
 import java.sql.Timestamp;
 import java.util.stream.Stream;
 
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 class PostgreSQLTimestampValueParserTest {
     
     @ParameterizedTest(name = "{0}")
-    @ArgumentsSource(TestCaseArgumentsProvider.class)
-    void assertGetLocalDateTimeNoExceptionOccurs(final String input, final 
Timestamp expected) {
+    @MethodSource("parseSuccessArguments")
+    void assertParse(final String name, final String input, final Timestamp 
expected) {
         assertThat(new PostgreSQLTimestampValueParser().parse(input), 
is(expected));
     }
     
-    private static final class TestCaseArgumentsProvider implements 
ArgumentsProvider {
-        
-        @Override
-        public Stream<? extends Arguments> provideArguments(final 
ParameterDeclarations parameters, final ExtensionContext context) {
-            return Stream.of(Arguments.of("20211012 2323", 
Timestamp.valueOf("2021-10-12 23:23:00")),
-                    Arguments.of("20211012 23:23", 
Timestamp.valueOf("2021-10-12 23:23:00")),
-                    Arguments.of("20211012 232323", 
Timestamp.valueOf("2021-10-12 23:23:23")),
-                    Arguments.of("2021-10-12 23:23:23", 
Timestamp.valueOf("2021-10-12 23:23:23")),
-                    Arguments.of("2021-10-12 23:23:23.1", 
Timestamp.valueOf("2021-10-12 23:23:23.1")),
-                    Arguments.of("2021-10-12 23:23:23.12", 
Timestamp.valueOf("2021-10-12 23:23:23.12")),
-                    Arguments.of("2021-10-12 23:23:23.123", 
Timestamp.valueOf("2021-10-12 23:23:23.123")),
-                    Arguments.of("2021-10-12 23:23:23.123+08", 
Timestamp.valueOf("2021-10-12 23:23:23.123")),
-                    Arguments.of("2021-10-12T23:23:23.123+08", 
Timestamp.valueOf("2021-10-12 23:23:23.123")),
-                    Arguments.of("2021-10-12 23:23:23.12345", 
Timestamp.valueOf("2021-10-12 23:23:23.12345")),
-                    Arguments.of("2021-10-12 23:23:23.12345+0800", 
Timestamp.valueOf("2021-10-12 23:23:23.12345")),
-                    Arguments.of("20211012 23:23:23.12345+0800", 
Timestamp.valueOf("2021-10-12 23:23:23.12345")),
-                    Arguments.of("2021-10-12 23:23:23.12345+08:00:00", 
Timestamp.valueOf("2021-10-12 23:23:23.12345")),
-                    Arguments.of("211012 23:23:23.12345+08:00:00", 
Timestamp.valueOf("2021-10-12 23:23:23.12345")),
-                    Arguments.of("10/12/21 23:23:23.12345+08:00:00", 
Timestamp.valueOf("2021-10-12 23:23:23.12345")),
-                    Arguments.of("2021-10-12 23:23:23.123456", 
Timestamp.valueOf("2021-10-12 23:23:23.123456")),
-                    Arguments.of("2021-10-12 23:23:23.1234567", 
Timestamp.valueOf("2021-10-12 23:23:23.1234567")),
-                    Arguments.of("2021-10-12 23:23:23.12345678", 
Timestamp.valueOf("2021-10-12 23:23:23.12345678")),
-                    Arguments.of("2021-10-12 23:23:23.123456789", 
Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
-                    Arguments.of("2021-10-12 23:23:23.123456 +08:00", 
Timestamp.valueOf("2021-10-12 23:23:23.123456")),
-                    Arguments.of("2021-10-12 23:23:23.1234567 +08:00", 
Timestamp.valueOf("2021-10-12 23:23:23.1234567")),
-                    Arguments.of("2021-10-12 23:23:23.12345678 +08:00", 
Timestamp.valueOf("2021-10-12 23:23:23.12345678")),
-                    Arguments.of("2021-10-12 23:23:23.123456789+08:00", 
Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
-                    Arguments.of("2021-10-12 23:23:23.123456789 +08:00", 
Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
-                    Arguments.of("2021-10-12 23:23:23.123456 -08:00", 
Timestamp.valueOf("2021-10-12 23:23:23.123456")),
-                    Arguments.of("2021-3-3 23:23:23.123456", 
Timestamp.valueOf("2021-03-03 23:23:23.123456")),
-                    Arguments.of("infinity", new 
Timestamp(9223372036825200000L)),
-                    Arguments.of("-infinity", new 
Timestamp(-9223372036832400000L)));
-        }
+    @Test
+    void assertParseWithTimestampUtilsException() {
+        assertThat(assertThrows(SQLWrapperException.class, () -> new 
PostgreSQLTimestampValueParser().parse("bad")).getCause(), 
isA(SQLException.class));
+    }
+    
+    private static Stream<Arguments> parseSuccessArguments() {
+        return Stream.of(
+                Arguments.of("date and short time", "20211012 2323", 
Timestamp.valueOf("2021-10-12 23:23:00")),
+                Arguments.of("date and time", "2021-10-12 23:23:23", 
Timestamp.valueOf("2021-10-12 23:23:23")),
+                Arguments.of("date and nanos", "2021-10-12 
23:23:23.123456789", Timestamp.valueOf("2021-10-12 23:23:23.123456789")),
+                Arguments.of("timestamp with T and offset", 
"2021-10-12T23:23:23.123+08", Timestamp.valueOf("2021-10-12 23:23:23.123")),
+                Arguments.of("timestamp with extended offset", "2021-10-12 
23:23:23.12345+08:00:00", Timestamp.valueOf("2021-10-12 23:23:23.12345")),
+                Arguments.of("timestamp with compact date", "20211012 
23:23:23.12345+0800", Timestamp.valueOf("2021-10-12 23:23:23.12345")),
+                Arguments.of("timestamp with short date", "211012 
23:23:23.12345+08:00:00", Timestamp.valueOf("2021-10-12 23:23:23.12345")),
+                Arguments.of("timestamp with slash date", "10/12/21 
23:23:23.12345+08:00:00", Timestamp.valueOf("2021-10-12 23:23:23.12345")),
+                Arguments.of("timestamp with positive zone spacing", 
"2021-10-12 23:23:23.123456 +08:00", Timestamp.valueOf("2021-10-12 
23:23:23.123456")),
+                Arguments.of("timestamp with negative zone spacing", 
"2021-10-12 23:23:23.123456 -08:00", Timestamp.valueOf("2021-10-12 
23:23:23.123456")),
+                Arguments.of("single-digit month and day", "2021-3-3 
23:23:23.123456", Timestamp.valueOf("2021-03-03 23:23:23.123456")),
+                Arguments.of("positive infinity fallback", "infinity", new 
Timestamp(9223372036825200000L)),
+                Arguments.of("negative infinity fallback", "-infinity", new 
Timestamp(-9223372036832400000L)));
     }
 }

Reply via email to