From bdc59e118572a4b1810b57f1555c246429991359 Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Fri, 10 Dec 2021 03:54:59 +0800 Subject: [PATCH] fix test Change-Id: Ib8179d878b4311f72268f80e39f4aea48bba68b7 --- .../baidu/hugegraph/core/VertexCoreTest.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/hugegraph-test/src/main/java/com/baidu/hugegraph/core/VertexCoreTest.java b/hugegraph-test/src/main/java/com/baidu/hugegraph/core/VertexCoreTest.java index 696df46fe1..674f0e1ec5 100644 --- a/hugegraph-test/src/main/java/com/baidu/hugegraph/core/VertexCoreTest.java +++ b/hugegraph-test/src/main/java/com/baidu/hugegraph/core/VertexCoreTest.java @@ -8729,9 +8729,6 @@ public void testQueryByHasIdEmptyListInPage() { public void testAddVertexWithSpecialSymbolInPrimaryValues() { HugeGraph graph = graph(); - Vertex vertex0 = graph.addVertex(T.label, "person", "name", - "xyz\u0000abc", "city", "Hongkong", - "age", 10); Vertex vertex1 = graph.addVertex(T.label, "person", "name", "xyz\u0001abc", "city", "Hongkong", "age", 11); @@ -8744,8 +8741,7 @@ public void testAddVertexWithSpecialSymbolInPrimaryValues() { graph.tx().commit(); GraphTraversalSource g = graph.traversal(); - Assert.assertEquals(vertex0, g.V().hasLabel("person") - .has("name", "xyz\u0000abc").next()); + Assert.assertEquals(vertex1, g.V().hasLabel("person") .has("name", "xyz\u0001abc").next()); Assert.assertEquals(vertex2, g.V().hasLabel("person") @@ -8753,6 +8749,14 @@ public void testAddVertexWithSpecialSymbolInPrimaryValues() { Assert.assertEquals(vertex3, g.V().hasLabel("person") .has("name", "xyz\u0003abc").next()); + if (!graph.backend().equals("postgresql")) { + Vertex vertex0 = graph.addVertex(T.label, "person", "name", + "xyz\u0000abc", "city", "Hongkong", + "age", 10); + Assert.assertEquals(vertex0, g.V().hasLabel("person") + .has("name", "xyz\u0000abc").next()); + } + Assert.assertThrows(IllegalArgumentException.class, () -> { graph.addVertex(T.label, "person", "name", "\u0000", "city", "Hongkong", @@ -8867,10 +8871,20 @@ public void testQueryBySearchIndexWithSpecialSymbol() { vertices = g.V().has("city", Text.contains("\u0001")).toList(); Assert.assertEquals(0, vertices.size()); - if (graph.backend().equals("postgresql")) { + String backend = graph.backend(); + if (ImmutableSet.of("rocksdb", "hbase").contains(backend)) { + Assert.assertThrows(Exception.class, () -> { + graph.addVertex(T.label, "person", "name", "0", + "city", "xyz\u0000efg", "age", 0); + graph.tx().commit(); + }, e -> { + Assert.assertContains("can't contains byte '0x00'", + e.getMessage()); + }); + } else if (backend.equals("postgresql")) { Assert.assertThrows(BackendException.class, () -> { graph.addVertex(T.label, "person", "name", "7", - "city", "\u0000", + "city", "xyz\u0000efg", "age", 15); graph.tx().commit(); }, e -> {