|
2 | 2 |
|
3 | 3 | import com.arangodb.util.RawBytes; |
4 | 4 | import com.arangodb.util.RawJson; |
| 5 | +import com.fasterxml.jackson.databind.JsonNode; |
5 | 6 | import com.fasterxml.jackson.databind.node.JsonNodeFactory; |
6 | 7 | import com.fasterxml.jackson.databind.node.ObjectNode; |
7 | 8 | import org.junit.jupiter.params.ParameterizedTest; |
8 | 9 | import org.junit.jupiter.params.provider.EnumSource; |
9 | 10 |
|
10 | 11 |
|
| 12 | +import java.sql.Date; |
| 13 | + |
11 | 14 | import static org.assertj.core.api.Assertions.assertThat; |
12 | 15 |
|
13 | 16 |
|
@@ -35,4 +38,32 @@ void rawBytesSerde(DataType type) { |
35 | 38 | assertThat(deserialized).isEqualTo(raw); |
36 | 39 | } |
37 | 40 |
|
| 41 | + @ParameterizedTest |
| 42 | + @EnumSource(DataType.class) |
| 43 | + void utilDateSerde(DataType type) { |
| 44 | + InternalSerde s = InternalSerde.of(type, null); |
| 45 | + long ts = 1000000000000L; |
| 46 | + java.util.Date date = new java.util.Date(ts); |
| 47 | + byte[] ser = s.serialize(date); |
| 48 | + JsonNode node = s.parse(ser); |
| 49 | + assertThat(node.isLong()).isTrue(); |
| 50 | + assertThat(node.longValue()).isEqualTo(ts); |
| 51 | + java.util.Date deser = s.deserialize(ser, java.util.Date.class); |
| 52 | + assertThat(deser).isEqualTo(date); |
| 53 | + } |
| 54 | + |
| 55 | + @ParameterizedTest |
| 56 | + @EnumSource(DataType.class) |
| 57 | + void sqlDateSerde(DataType type) { |
| 58 | + InternalSerde s = InternalSerde.of(type, null); |
| 59 | + long ts = 1000000000000L; |
| 60 | + java.sql.Date date = new Date(ts); |
| 61 | + byte[] ser = s.serialize(date); |
| 62 | + JsonNode node = s.parse(ser); |
| 63 | + assertThat(node.isLong()).isTrue(); |
| 64 | + assertThat(node.longValue()).isEqualTo(ts); |
| 65 | + java.sql.Date deser = s.deserialize(ser, java.sql.Date.class); |
| 66 | + assertThat(deser).isEqualTo(date); |
| 67 | + } |
| 68 | + |
38 | 69 | } |
0 commit comments