use of org.neo4j.bolt.v41.messaging.RoutingContext in project neo4j by neo4j.
the class HelloMessageDecoderTest method testShouldDecodeRoutingContext.
@Test
void testShouldDecodeRoutingContext() throws Exception {
Map<String, Object> meta = new HashMap<>();
Map<String, Object> authToken;
Map<String, String> parameterMap = new HashMap<>();
RoutingContext routingContext = new RoutingContext(true, parameterMap);
parameterMap.put("policy", "fast");
parameterMap.put("region", "eu-west");
Neo4jPack neo4jPack = newNeo4jPack();
meta.put("user_agent", "My Driver");
meta.put("routing", parameterMap);
authToken = new HashMap<>(Map.copyOf(meta));
authToken.remove("routing");
HelloMessage originalMessage = new HelloMessage(meta, routingContext, authToken);
PackedInputArray input = new PackedInputArray(encode(neo4jPack, originalMessage));
Neo4jPack.Unpacker unpacker = neo4jPack.newUnpacker(input);
// these two steps are executed before decoding in order to select a correct decoder
unpacker.unpackStructHeader();
unpacker.unpackStructSignature();
RequestMessage deserializedMessage = decoder.decode(unpacker);
assertHelloMessageMatches(originalMessage, deserializedMessage);
assertRoutingContextMatches(originalMessage, deserializedMessage);
}
use of org.neo4j.bolt.v41.messaging.RoutingContext in project neo4j by neo4j.
the class HelloMessageDecoderTest method shouldDecodeHelloMessage.
@Test
void shouldDecodeHelloMessage() throws Exception {
HelloMessage originalMessage = new HelloMessage(map("user_agent", "My Driver", "user", "neo4j", "password", "secret", "routing", Collections.emptyMap()), new RoutingContext(true, Collections.emptyMap()), map("user_agent", "My Driver", "user", "neo4j", "password", "secret"));
assertOriginalMessageEqualsToDecoded(originalMessage, decoder);
}
use of org.neo4j.bolt.v41.messaging.RoutingContext in project neo4j by neo4j.
the class HelloMessageDecoderTest method shouldDecodeHelloMessageWithRouting.
@Test
void shouldDecodeHelloMessageWithRouting() throws Exception {
HelloMessage originalMessage = new HelloMessage(map("user_agent", "My Driver", "user", "neo4j", "password", "secret", "routing", map("policy", "europe")), new RoutingContext(true, stringMap("policy", "europe")), map("user_agent", "My Driver", "user", "neo4j", "password", "secret"));
assertOriginalMessageEqualsToDecoded(originalMessage, decoder);
}
Aggregations