private static BoltResponseMessageReader ResponseReader(Neo4jPack neo4jPack, sbyte[] bytes) { BufferedChannelInput input = new BufferedChannelInput(128); input.Reset(new ArrayByteChannel(bytes)); return(new BoltResponseMessageReader(neo4jPack.NewUnpacker(input))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static byte[] serialize(org.neo4j.bolt.messaging.Neo4jPack neo4jPack, org.neo4j.bolt.messaging.ResponseMessage... messages) throws java.io.IOException public static sbyte[] Serialize(Neo4jPack neo4jPack, params ResponseMessage[] messages) { RecordingByteChannel rawData = new RecordingByteChannel(); BufferedChannelOutput output = new BufferedChannelOutput(rawData); BoltResponseMessageWriterV1 writer = new BoltResponseMessageWriterV1(neo4jPack.newPacker, output, NullLogService.Instance); foreach (ResponseMessage message in messages) { writer.Write(message); } writer.Flush(); return(rawData.Bytes); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static org.neo4j.bolt.messaging.ResponseMessage responseMessage(org.neo4j.bolt.messaging.Neo4jPack neo4jPack, byte[] bytes) throws java.io.IOException public static ResponseMessage ResponseMessage(Neo4jPack neo4jPack, sbyte[] bytes) { BoltResponseMessageReader unpacker = ResponseReader(neo4jPack, bytes); BoltResponseMessageRecorder consumer = new BoltResponseMessageRecorder(); try { unpacker.Read(consumer); return(consumer.AsList()[0]); } catch (Exception e) { throw new IOException("Failed to deserialize response, '" + e.Message + "'.\n" + "Raw data: \n" + HexPrinter.hex(bytes), e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static byte[] serialize(org.neo4j.bolt.messaging.Neo4jPack neo4jPack, org.neo4j.bolt.messaging.RequestMessage... messages) throws java.io.IOException public static sbyte[] Serialize(Neo4jPack neo4jPack, params RequestMessage[] messages) { RecordingByteChannel rawData = new RecordingByteChannel(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = neo4jPack.NewPacker(new BufferedChannelOutput(rawData)); BoltRequestMessageWriter writer = new BoltRequestMessageWriter(packer); foreach (RequestMessage message in messages) { writer.Write(message); } writer.Flush(); return(rawData.Bytes); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void testMessageDecoding(org.neo4j.bolt.messaging.RequestMessage message) throws Exception private static void TestMessageDecoding(RequestMessage message) { Neo4jPack neo4jPack = newNeo4jPack(); BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); BoltRequestMessageReader reader = requestMessageReader(stateMachine); PackedInputArray input = new PackedInputArray(encode(neo4jPack, message)); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = neo4jPack.NewUnpacker(input); reader.Read(unpacker); verify(stateMachine).process(eq(message), any()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void testUnpackableStructParametersWithKnownType(org.neo4j.bolt.messaging.Neo4jPack packerForSerialization, org.neo4j.values.AnyValue parameterValue, String expectedMessage) throws Exception private void TestUnpackableStructParametersWithKnownType(Neo4jPack packerForSerialization, AnyValue parameterValue, string expectedMessage) { string statement = "RETURN $x"; MapValue parameters = VirtualValues.map(new string[] { "x" }, new AnyValue[] { parameterValue }); BoltStateMachine stateMachine = mock(typeof(BoltStateMachine)); SynchronousBoltConnection connection = new SynchronousBoltConnection(stateMachine); _channel = new EmbeddedChannel(NewDecoder(connection)); _channel.writeInbound(Unpooled.wrappedBuffer(serialize(packerForSerialization, new RunMessage(statement, parameters)))); _channel.finishAndReleaseAll(); verify(stateMachine).handleExternalFailure(eq(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.TypeError, expectedMessage)), any()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static void assertOriginalMessageEqualsToDecoded(org.neo4j.bolt.messaging.RequestMessage originalMessage, org.neo4j.bolt.messaging.RequestMessageDecoder decoder) throws Exception internal static void AssertOriginalMessageEqualsToDecoded(RequestMessage originalMessage, RequestMessageDecoder decoder) { Neo4jPack neo4jPack = newNeo4jPack(); PackedInputArray input = new PackedInputArray(encode(neo4jPack, originalMessage)); Org.Neo4j.Bolt.messaging.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); assertEquals(originalMessage, deserializedMessage); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailNicelyOnPointsWhenProtocolDoesNotSupportThem() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFailNicelyOnPointsWhenProtocolDoesNotSupportThem() { // only V1 protocol does not support points assumeThat(Neo4jPack.version(), equalTo(Neo4jPackV1.VERSION)); // When Connection.connect(_address).send(Util.defaultAcceptedVersions()).send(Util.chunk(new InitMessage("TestClient/1.1", emptyMap()), new RunMessage("RETURN point({x:13, y:37, crs:'cartesian'}) as p"), PullAllMessage.INSTANCE)); // Then assertThat(Connection, Util.eventuallyReceivesSelectedProtocolVersion()); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.hamcrest.Matcher<java.util.Map<? extends String,?>> fieldsMatcher = hasEntry(is("fields"), equalTo(singletonList("p"))); Matcher <IDictionary <string, ?> > fieldsMatcher = hasEntry(@is("fields"), equalTo(singletonList("p"))); assertThat(Connection, Util.eventuallyReceives(msgSuccess(), msgSuccess(CoreMatchers.allOf(fieldsMatcher, hasKey("result_available_after"))), msgFailure(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Point is not supported as a return type in Bolt"))); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void testShouldDecodeAuthToken(java.util.Map<String,Object> authToken, boolean checkDecodingResult) throws Exception protected internal override void TestShouldDecodeAuthToken(IDictionary <string, object> authToken, bool checkDecodingResult) { Neo4jPack neo4jPack = newNeo4jPack(); authToken["user_agent"] = "My Driver"; HelloMessage originalMessage = new HelloMessage(authToken); PackedInputArray input = new PackedInputArray(encode(neo4jPack, originalMessage)); Org.Neo4j.Bolt.messaging.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); if (checkDecodingResult) { AssertHelloMessageMatches(originalMessage, deserializedMessage); } }
public TransportTestUtil(Neo4jPack neo4jPack, MessageEncoder messageEncoder) { this.Neo4jPackConflict = neo4jPack; this._messageEncoder = messageEncoder; }
public TransportTestUtil(Neo4jPack neo4jPack) : this(neo4jPack, new MessageEncoderV1()) { }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public byte[] encode(org.neo4j.bolt.messaging.Neo4jPack neo4jPack, org.neo4j.bolt.messaging.ResponseMessage... messages) throws java.io.IOException public override sbyte[] Encode(Neo4jPack neo4jPack, params ResponseMessage[] messages) { return(serialize(neo4jPack, messages)); }
private static string NewName(Type connectionClass, Neo4jPack neo4jPack) { return(connectionClass.Name + " & " + neo4jPack); }