//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPropagateFatalError() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPropagateFatalError()
        {
            Neo4jPack_Unpacker unpacker = mock(typeof(Neo4jPack_Unpacker));
            Exception          error    = new Exception();

            when(unpacker.UnpackStructHeader()).thenThrow(error);

            BoltRequestMessageReader reader = new TestBoltRequestMessageReader(ConnectionMock(), ResponseHandlerMock(), emptyList());

            Exception e = assertThrows(typeof(Exception), () => reader.read(unpacker));

            assertEquals(error, e);
        }
Пример #2
0
//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();
            InitMessage originalMessage = new InitMessage("My Driver", map("user", "neo4j", "password", "secret"));

            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 TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandleErrorThatCausesFailureMessage() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHandleErrorThatCausesFailureMessage()
        {
            Neo4jPack_Unpacker unpacker = mock(typeof(Neo4jPack_Unpacker));
            BoltIOException    error    = new BoltIOException(Org.Neo4j.Kernel.Api.Exceptions.Status_General.UnknownError, "Hello");

            when(unpacker.UnpackStructHeader()).thenThrow(error);

            BoltStateMachine stateMachine = mock(typeof(BoltStateMachine));
            BoltConnection   connection   = new SynchronousBoltConnection(stateMachine);

            BoltResponseHandler      externalErrorResponseHandler = ResponseHandlerMock();
            BoltRequestMessageReader reader = new TestBoltRequestMessageReader(connection, externalErrorResponseHandler, emptyList());

            reader.Read(unpacker);

            verify(stateMachine).handleExternalFailure(Neo4jError.from(error), externalErrorResponseHandler);
        }
Пример #4
0
//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)
        {
            Neo4jPackV1 neo4jPack       = new Neo4jPackV1();
            InitMessage originalMessage = new InitMessage("My Driver", authToken);

            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);

            if (checkDecodingResult)
            {
                AssertInitMessageMatches(originalMessage, deserializedMessage);
            }
        }
Пример #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void doRead(Neo4jPack_Unpacker unpacker) throws java.io.IOException
        private void DoRead(Neo4jPack_Unpacker unpacker)
        {
            try
            {
                unpacker.UnpackStructHeader();
                int signature = unpacker.UnpackStructSignature();

                RequestMessageDecoder decoder = _decoders[signature];
                if (decoder == null)
                {
                    throw new BoltIOException(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, string.Format("Message 0x{0} is not a valid message signature.", signature.ToString("x")));
                }

                RequestMessage      message         = decoder.Decode(unpacker);
                BoltResponseHandler responseHandler = decoder.ResponseHandler();

                _connection.enqueue(stateMachine => stateMachine.process(message, responseHandler));
            }
            catch (PackStream.PackStreamException e)
            {
                throw new BoltIOException(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.InvalidFormat, string.Format("Unable to read message type. Error was: {0}.", e.Message), e);
            }
        }