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 b4822cac8e1..08653dab847 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 void shouldReadWriteOutDirection() throws Exception { 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 9c9d198ae1b..10b8269b5a9 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.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 @@ private 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 @@ private Model() { final Map 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 @@ private 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 @@ private 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","");