You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ke...@apache.org on 2024/08/15 20:56:37 UTC
(tinkerpop) 05/05: test updates
This is an automated email from the ASF dual-hosted git repository.
kenhuuu pushed a commit to branch v4-io-test
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 17525d668506202eb3fa6901e6d4d2a7fcf62ec2
Author: Ken Hu <10...@users.noreply.github.com>
AuthorDate: Wed Aug 14 09:58:57 2024 -0700
test updates
---
.../io/AbstractTypedCompatibilityTest.java | 59 ++++++++++++++++++++++
.../tinkerpop/gremlin/structure/io/Model.java | 12 +++--
2 files changed, 66 insertions(+), 5 deletions(-)
diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java
index b4822cac8e..08653dab84 100644
--- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java
+++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java
@@ -878,4 +878,63 @@ public abstract class AbstractTypedCompatibilityTest extends AbstractCompatibili
assertEquals(resource, recycled);
}
+ @Test
+ public void shouldReadWriteZeroDate() throws Exception {
+ final String resourceName = "zero-date";
+
+ final Date resource = findModelEntryObject(resourceName);
+ final Date fromStatic = read(readFromResource(resourceName), Date.class);
+ final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
+ assertEquals(fromStatic, recycled);
+ assertEquals(resource, fromStatic);
+ assertEquals(resource, recycled);
+ }
+
+ @Test
+ public void shouldReadWriteMaxDate() throws Exception {
+ final String resourceName = "max-date";
+
+ final Date resource = findModelEntryObject(resourceName);
+ final Date fromStatic = read(readFromResource(resourceName), Date.class);
+ final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
+ assertEquals(fromStatic, recycled);
+ assertEquals(resource, fromStatic);
+ assertEquals(resource, recycled);
+ }
+
+ @Test
+ public void shouldReadWriteMinDate() throws Exception {
+ final String resourceName = "min-date";
+
+ final Date resource = findModelEntryObject(resourceName);
+ final Date fromStatic = read(readFromResource(resourceName), Date.class);
+ final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
+ assertEquals(fromStatic, recycled);
+ assertEquals(resource, fromStatic);
+ assertEquals(resource, recycled);
+ }
+
+ @Test
+ public void shouldReadWriteVarBulkSet() throws Exception {
+ final String resourceName = "var-bulkset";
+
+ final Date resource = findModelEntryObject(resourceName);
+ final Date fromStatic = read(readFromResource(resourceName), Date.class);
+ final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
+ assertEquals(fromStatic, recycled);
+ assertEquals(resource, fromStatic);
+ assertEquals(resource, recycled);
+ }
+
+ @Test
+ public void shouldReadWriteEmptyBulkSet() throws Exception {
+ final String resourceName = "empty-bulkset";
+
+ final Date resource = findModelEntryObject(resourceName);
+ final Date fromStatic = read(readFromResource(resourceName), Date.class);
+ final Date recycled = read(write(fromStatic, Date.class, resourceName), Date.class);
+ assertEquals(fromStatic, recycled);
+ assertEquals(resource, fromStatic);
+ assertEquals(resource, recycled);
+ }
}
diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java
index 9c9d198ae1..10b8269b5a 100644
--- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java
+++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java
@@ -55,6 +55,7 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
@@ -109,6 +110,7 @@ public class Model {
// IMPORTANT - the "title" or name of the Entry needs to be unique
addCoreEntry(new Date(0L), "zero-date");
+ addCoreEntry(new Date(11111111L), "precision-date");
addCoreEntry(new Date(Long.MAX_VALUE), "max-date");
addCoreEntry(new Date(Long.MIN_VALUE), "min-date");
@@ -141,13 +143,13 @@ public class Model {
final Map<Object,Object> map = new HashMap<>();
map.put("test", 123);
- map.put(new Date(1481750076295L), "red");
- map.put(Arrays.asList(1,2,3), new Date(1481750076295L));
+ map.put(new Date(1481295L), "red");
+ map.put(Arrays.asList(1,2,3), new Date(1481295L));
map.put(null, null);
addCoreEntry(map, "var-type-map", "Map is redefined so that to provide the ability to allow for non-String keys, which is not possible in JSON.");
addCoreEntry(Collections.EMPTY_MAP, "empty-map");
- addCoreEntry(new HashSet<>(Arrays.asList(1,"person", true, null)), "var-type-set", "Allows a JSON collection to behave as a Set.");
+ addCoreEntry(new HashSet<>(Arrays.asList(2, "person", true, null)), "var-type-set", "Allows a JSON collection to behave as a Set.");
addCoreEntry(Collections.EMPTY_SET, "empty-set");
addCoreEntry(UUID.fromString("41d2e28a-20a4-4ab0-b379-d810dede3786"), "specified-uuid");
@@ -156,7 +158,7 @@ public class Model {
addGraphStructureEntry(graph.edges().next(), "traversal-edge", "");
addGraphStructureEntry(DetachedFactory.detach(graph.edges().next(), false), "no-prop-edge", "");
- addGraphStructureEntry(g.V().out().out().path().next(), "traversal-path", "");
+ addGraphStructureEntry(detach(g.V().out().out().path().next(), false), "traversal-path", "");
addGraphStructureEntry(EmptyPath.instance(), "empty-path", "");
addGraphStructureEntry(detach(g.V().out().out().path().next(), true), "prop-path", "");
@@ -197,7 +199,7 @@ public class Model {
addExtendedEntry(Byte.MIN_VALUE, "min-byte", "");
addExtendedEntry(ByteBuffer.wrap(new byte[0]), "empty-binary", "");
- addEntry("Extended", () -> java.nio.ByteBuffer.wrap("some bytes for you".getBytes()), "str-binary", "");
+ addEntry("Extended", () -> java.nio.ByteBuffer.wrap("some bytes for you".getBytes(StandardCharsets.UTF_8)), "str-binary", "");
addExtendedEntry(Duration.ZERO, "zero-duration","The following example is a zero `Duration`");
addExtendedEntry(ChronoUnit.FOREVER.getDuration(), "forever-duration","");