|
75 | 75 | import org.apache.tinkerpop.gremlin.util.ser.GraphBinaryMessageSerializerV1; |
76 | 76 | import org.apache.tinkerpop.gremlin.util.ser.MessageTextSerializer; |
77 | 77 | import org.junit.Test; |
| 78 | + |
| 79 | +import groovy.lang.GString; |
| 80 | +import groovy.lang.GroovyShell; |
78 | 81 | import org.mockito.Mockito; |
79 | 82 | import org.yaml.snakeyaml.Yaml; |
80 | 83 | import org.yaml.snakeyaml.error.YAMLException; |
@@ -540,6 +543,44 @@ public void testDefaultGraphSONSerializerIncludesHugeGraphElementProperties() |
540 | 543 | Assert.assertContains("0.75", pathJson); |
541 | 544 | } |
542 | 545 |
|
| 546 | + @Test |
| 547 | + public void testDriverConfigsReturnEvaluatedGroovyStrings() throws Exception { |
| 548 | + Object value = new GroovyShell().evaluate("def value = 42; \"r3-value:${value}\""); |
| 549 | + Assert.assertInstanceOf(GString.class, value); |
| 550 | + Settings.SerializerSettings serverSettings = readGremlinServerSettings().serializers.get(0); |
| 551 | + MessageSerializer<?> server = newMessageSerializer(serverSettings.className); |
| 552 | + server.configure(config(serverSettings.config), Collections.emptyMap()); |
| 553 | + List<Object> response = List.of(value, List.of(value), Map.of("value", value)); |
| 554 | + List<Object> expected = List.of("r3-value:42", List.of("r3-value:42"), |
| 555 | + Map.of("value", "r3-value:42")); |
| 556 | + for (String config : DRIVER_CONFIGS) { |
| 557 | + RemoteSerializerSettings settings = readRemoteSerializerSettings(config); |
| 558 | + MessageSerializer<?> client = newMessageSerializer(settings.className); |
| 559 | + client.configure(config(settings.config), Collections.emptyMap()); |
| 560 | + Assert.assertEquals(config, expected, |
| 561 | + roundTripBinaryResponse(server, client, response).getResult().getData()); |
| 562 | + } |
| 563 | + Assert.assertEquals(expected, |
| 564 | + roundTripBinaryResponse(server, new GraphBinaryMessageSerializerV1(), response) |
| 565 | + .getResult().getData()); |
| 566 | + } |
| 567 | + |
| 568 | + @Test |
| 569 | + public void testUntypedGraphsonKeepsEvaluatedGroovyStringBean() throws Exception { |
| 570 | + Object value = new GroovyShell().evaluate("def value = 42; \"r3-value:${value}\""); |
| 571 | + Settings.SerializerSettings settings = readGremlinServerSettings().serializers.stream() |
| 572 | + .filter(s -> s.className.endsWith( |
| 573 | + "GraphSONUntypedMessageSerializerV1")) |
| 574 | + .findFirst().orElseThrow(); |
| 575 | + MessageTextSerializer<?> serializer = (MessageTextSerializer<?>) newMessageSerializer(settings.className); |
| 576 | + serializer.configure(config(settings.config), Collections.emptyMap()); |
| 577 | + Object result = roundTripResponse(serializer, value).getResult().getData(); |
| 578 | + Assert.assertInstanceOf(Map.class, result); |
| 579 | + Map<?, ?> bean = (Map<?, ?>) result; |
| 580 | + Assert.assertEquals(List.of(42), bean.get("values")); |
| 581 | + Assert.assertEquals(List.of("r3-value:", ""), bean.get("strings")); |
| 582 | + } |
| 583 | + |
543 | 584 | @Test |
544 | 585 | public void testDriverConfigsReturnOptionalAndFile() throws Exception { |
545 | 586 | Settings.SerializerSettings serverSettings = readGremlinServerSettings() |
|
0 commit comments