|
23 | 23 | import nl.altindag.log.LogCaptor; |
24 | 24 | import org.apache.tinkerpop.gremlin.driver.Channelizer; |
25 | 25 | import org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer; |
| 26 | +import org.apache.tinkerpop.gremlin.structure.Graph; |
| 27 | +import org.apache.tinkerpop.gremlin.structure.io.Mapper; |
| 28 | +import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper; |
| 29 | +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2; |
| 30 | +import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3; |
26 | 31 | import org.apache.tinkerpop.gremlin.util.ExceptionHelper; |
27 | 32 | import org.apache.tinkerpop.gremlin.TestHelper; |
28 | 33 | import org.apache.tinkerpop.gremlin.driver.Client; |
|
39 | 44 | import org.apache.tinkerpop.gremlin.util.message.ResponseStatusCode; |
40 | 45 | import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection; |
41 | 46 | import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1; |
| 47 | +import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV2; |
| 48 | +import org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV3; |
42 | 49 | import org.apache.tinkerpop.gremlin.util.ser.Serializers; |
43 | 50 | import org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin; |
44 | 51 | import org.apache.tinkerpop.gremlin.process.traversal.Bytecode; |
@@ -209,6 +216,46 @@ public Settings overrideSettings(final Settings settings) { |
209 | 216 | return settings; |
210 | 217 | } |
211 | 218 |
|
| 219 | + @Test |
| 220 | + public void shouldSubgraphWithGraphSONV3Serialization() throws Exception { |
| 221 | + // validating subgraph() serialization here b/c we don't have feature tests for it yet in gherkin |
| 222 | + final GraphSONMapper.Builder builder = GraphSONMapper.build().addRegistry(TinkerIoRegistryV3.instance()); |
| 223 | + final GraphSONMessageSerializerV3 serializer = new GraphSONMessageSerializerV3(builder); |
| 224 | + final Cluster cluster = TestClientFactory.build().serializer(serializer).create(); |
| 225 | + final Client client = cluster.connect(); |
| 226 | + |
| 227 | + try { |
| 228 | + final List<Result> r = client.submit("TinkerFactory.createModern().traversal().E().hasLabel('knows').subgraph('x').cap('x')").all().join(); |
| 229 | + assertEquals(1, r.size()); |
| 230 | + |
| 231 | + final Graph graph = r.get(0).get(Graph.class); |
| 232 | + final GraphTraversalSource g = traversal().withEmbedded(graph); |
| 233 | + assertEquals(2, g.E().count().next().longValue()); |
| 234 | + assertEquals(3, g.V().count().next().longValue()); |
| 235 | + } finally { |
| 236 | + cluster.close(); |
| 237 | + } |
| 238 | + } |
| 239 | + |
| 240 | + @Test |
| 241 | + public void shouldSubgraphWithGraphBinaryV1Serialization() throws Exception { |
| 242 | + // validating subgraph() serialization here b/c we don't have feature tests for it yet in gherkin |
| 243 | + final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHBINARY_V1).create(); |
| 244 | + final Client client = cluster.connect(); |
| 245 | + |
| 246 | + try { |
| 247 | + final List<Result> r = client.submit("TinkerFactory.createModern().traversal().E().hasLabel('knows').subgraph('x').cap('x')").all().join(); |
| 248 | + assertEquals(1, r.size()); |
| 249 | + |
| 250 | + final Graph graph = r.get(0).get(Graph.class); |
| 251 | + final GraphTraversalSource g = traversal().withEmbedded(graph); |
| 252 | + assertEquals(2, g.E().count().next().longValue()); |
| 253 | + assertEquals(3, g.V().count().next().longValue()); |
| 254 | + } finally { |
| 255 | + cluster.close(); |
| 256 | + } |
| 257 | + } |
| 258 | + |
212 | 259 | @Test |
213 | 260 | public void shouldInterceptRequests() throws Exception { |
214 | 261 | final int requestsToMake = 32; |
|
0 commit comments