//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowOnUnpackingMapWithDuplicateKeys() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowOnUnpackingMapWithDuplicateKeys() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.PackMapHeader(2); packer.Pack("key"); packer.pack(intValue(1)); packer.Pack("key"); packer.pack(intValue(2)); // When try { PackedInputArray input = new PackedInputArray(output.Bytes()); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input); unpacker.Unpack(); fail("exception expected"); } catch (BoltIOException ex) { assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Duplicate map key `key`."), Neo4jError.from(ex)); } }
public MessageDecoder(UnpackerProvider unpackProvider, BoltRequestMessageReader reader, LogService logService) { this._input = new ByteBufInput(); this._unpacker = unpackProvider.NewUnpacker(_input); this._reader = reader; this._log = logService.GetInternalLog(this.GetType()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldFailWhenTryingToPackAndUnpackMapContainingNullKeys() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldFailWhenTryingToPackAndUnpackMapContainingNullKeys() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); IDictionary <string, AnyValue> map = new Dictionary <string, AnyValue>(); map[null] = longValue(42L); map["foo"] = longValue(1337L); packer.PackMapHeader(map.Count); foreach (KeyValuePair <string, AnyValue> entry in map.SetOfKeyValuePairs()) { packer.pack(entry.Key); packer.pack(entry.Value); } // When try { PackedInputArray input = new PackedInputArray(output.Bytes()); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input); unpacker.Unpack(); fail("exception expected"); } catch (BoltIOException ex) { assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Value `null` is not supported as key in maps, must be a non-nullable string."), Neo4jError.from(ex)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { string statement = unpacker.UnpackString(); MapValue @params = unpacker.UnpackMap(); return(new RunMessage(statement, @params)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.values.AnyValue unpacked(byte[] bytes) throws java.io.IOException private AnyValue Unpacked(sbyte[] bytes) { PackedInputArray input = new PackedInputArray(bytes); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input); return(unpacker.Unpack()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { string userAgent = unpacker.UnpackString(); IDictionary <string, object> authToken = ReadMetaDataMap(unpacker); return(new InitMessage(userAgent, authToken)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static java.util.Map<String,Object> readMetaDataMap(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public static IDictionary <string, object> ReadMetaDataMap(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { MapValue metaDataMapValue = unpacker.UnpackMap(); PrimitiveOnlyValueWriter writer = new PrimitiveOnlyValueWriter(); IDictionary <string, object> metaDataMap = new Dictionary <string, object>(metaDataMapValue.Size()); metaDataMapValue.Foreach((key, value) => { object convertedValue = AuthToken.containsSensitiveInformation(key) ? writer.SensitiveValueAsObject(value) : writer.ValueAsObject(value); metaDataMap[key] = convertedValue; }); return(metaDataMap); }
//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 TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldDecodeAckFailure() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ShouldDecodeAckFailure() { Neo4jPackV1 neo4jPack = new Neo4jPackV1(); RunMessage originalMessage = new RunMessage("UNWIND range(1, 10) AS x RETURN x, $y", map(new string[] { "y" }, new AnyValue[] { longValue(42) })); PackedInputArray innput = new PackedInputArray(serialize(neo4jPack, originalMessage)); Neo4jPack_Unpacker unpacker = neo4jPack.NewUnpacker(innput); // 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 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 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); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowOnUnpackingMapWithUnsupportedKeyType() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowOnUnpackingMapWithUnsupportedKeyType() { // Given PackedOutputArray output = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = _neo4jPack.newPacker(output); packer.PackMapHeader(2); packer.Pack(ValueUtils.of(1L)); packer.pack(intValue(1)); // When try { PackedInputArray input = new PackedInputArray(output.Bytes()); Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker = _neo4jPack.newUnpacker(input); unpacker.Unpack(); fail("exception expected"); } catch (BoltIOException ex) { assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, "Bad key type: INTEGER"), Neo4jError.from(ex)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { _connection.interrupt(); return(ResetMessage.INSTANCE); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { MapValue meta = unpacker.UnpackMap(); return(new BeginMessage(meta)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { return(DiscardAllMessage.INSTANCE); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { return(AckFailureMessage.INSTANCE); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { _connection.stop(); return(GOODBYE_MESSAGE); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { return(COMMIT_MESSAGE); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.messaging.RequestMessage decode(org.neo4j.bolt.messaging.Neo4jPack_Unpacker unpacker) throws java.io.IOException public override RequestMessage Decode(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { IDictionary <string, object> meta = InitMessageDecoder.readMetaDataMap(unpacker); return(new HelloMessage(meta)); }
public BoltResponseMessageReader(Org.Neo4j.Bolt.messaging.Neo4jPack_Unpacker unpacker) { this._unpacker = unpacker; }