//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void testLoggingOfOriginalErrorWhenOutputIsClosed(org.neo4j.bolt.runtime.Neo4jError original) throws Exception
        private static void TestLoggingOfOriginalErrorWhenOutputIsClosed(Neo4jError original)
        {
            PackOutputClosedException outputClosed = new PackOutputClosedException("Output closed", "<client>");
            AssertableLogProvider     logProvider  = EmulateFailureWritingError(original, outputClosed);

            logProvider.AssertExactly(inLog("Test").warn(startsWith("Unable to send error back to the client"), equalTo(original.Cause())));
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void handleFailure(Throwable cause, boolean fatal) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        public override void HandleFailure(Exception cause, bool fatal)
        {
            if (ExceptionUtils.indexOfType(cause, typeof(BoltConnectionFatality)) != -1)
            {
                fatal = true;
            }

            Neo4jError error = fatal ? Neo4jError.fatalFrom(cause) : Neo4jError.from(cause);

            Fail(error);

            if (error.Fatal)
            {
                if (ExceptionUtils.indexOfType(cause, typeof(AuthorizationExpiredException)) != -1)
                {
                    throw new BoltConnectionAuthFatality("Failed to process a bolt message", cause);
                }
                if (cause is AuthenticationException)
                {
                    throw new BoltConnectionAuthFatality(( AuthenticationException )cause);
                }

                throw new BoltConnectionFatality("Failed to process a bolt message", cause);
            }
        }
Ejemplo n.º 3
0
//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));
            }
        }
Ejemplo n.º 4
0
//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));
            }
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCallExternalErrorOnInitWithDuplicateKeys() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCallExternalErrorOnInitWithDuplicateKeys()
        {
            BoltStateMachine          stateMachine = mock(typeof(BoltStateMachine));
            SynchronousBoltConnection connection   = new SynchronousBoltConnection(stateMachine);

            _channel = new EmbeddedChannel(NewDecoder(connection));

            // Generate INIT message with duplicate keys
            PackedOutputArray @out = new PackedOutputArray();

            Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = PackerUnderTest.newPacker(@out);
            packer.PackStructHeader(2, InitMessage.SIGNATURE);
            packer.Pack("Test/User Agent 1.0");
            packer.PackMapHeader(3);
            packer.Pack("scheme");
            packer.Pack("basic");
            packer.Pack("principal");
            packer.Pack("user");
            packer.Pack("scheme");
            packer.Pack("password");

            _channel.writeInbound(Unpooled.wrappedBuffer(@out.Bytes()));
            _channel.finishAndReleaseAll();

            verify(stateMachine).handleExternalFailure(eq(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, "Duplicate map key `scheme`.")), any());
        }
Ejemplo n.º 6
0
        private void AssertYieldsErrors(string json, params Neo4jError[] expectedErrors)
        {
            StatementDeserializer de = new StatementDeserializer(new ByteArrayInputStreamAnonymousInnerClass(this, UTF8.encode(json)));

            while (de.MoveNext())
            {
                de.Current;
            }

            IEnumerator <Neo4jError> actual   = de.Errors();
            IEnumerator <Neo4jError> expected = asList(expectedErrors).GetEnumerator();

            while (actual.MoveNext())
            {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                assertTrue(expected.hasNext());
                Neo4jError error = actual.Current;
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                Neo4jError expectedError = expected.next();

                assertThat(error.Message, equalTo(expectedError.Message));
                assertThat(error.Status(), equalTo(expectedError.Status()));
            }

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(expected.hasNext());
        }
Ejemplo n.º 7
0
        protected internal virtual void After()
        {
            if (ConnectionStateConflict.ResponseHandler != null)
            {
                try
                {
                    Neo4jError pendingError = ConnectionStateConflict.PendingError;
                    if (pendingError != null)
                    {
                        ConnectionStateConflict.markFailed(pendingError);
                    }

                    if (ConnectionStateConflict.hasPendingIgnore())
                    {
                        ConnectionStateConflict.markIgnored();
                    }

                    ConnectionStateConflict.resetPendingFailedAndIgnored();
                    ConnectionStateConflict.ResponseHandler.onFinish();
                }
                finally
                {
                    ConnectionStateConflict.ResponseHandler = null;
                }
            }
        }
Ejemplo n.º 8
0
 private void AddError(Neo4jError error)
 {
     if (_errors == null)
     {
         _errors = new LinkedList <Neo4jError>();
     }
     _errors.Add(error);
 }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void nextState(org.neo4j.bolt.messaging.RequestMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        private void NextState(RequestMessage message, StateMachineContext context)
        {
            BoltStateMachineState preState = _state;

            _state = _state.process(message, context);
            if (_state == null)
            {
                string msg = "Message '" + message + "' cannot be handled by a session in the " + preState.Name() + " state.";
                Fail(Neo4jError.fatalFrom(Org.Neo4j.Kernel.Api.Exceptions.Status_Request.Invalid, msg));
                throw new BoltProtocolBreachFatality(msg);
            }
        }
Ejemplo n.º 10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.logging.AssertableLogProvider emulateFailureWritingError(org.neo4j.bolt.runtime.Neo4jError error, Throwable errorDuringWrite) throws Exception
        private static AssertableLogProvider EmulateFailureWritingError(Neo4jError error, Exception errorDuringWrite)
        {
            AssertableLogProvider     logProvider     = new AssertableLogProvider();
            BoltResponseMessageWriter responseHandler = NewResponseHandlerMock(error.Fatal, errorDuringWrite);

            MessageProcessingHandler handler = new MessageProcessingHandler(responseHandler, mock(typeof(BoltConnection)), logProvider.GetLog("Test"));

            handler.MarkFailed(error);
            handler.OnFinish();

            return(logProvider);
        }
Ejemplo n.º 11
0
 private void Fail(Neo4jError neo4jError)
 {
     _spi.reportError(neo4jError);
     if (_state == _failedState)
     {
         ConnectionStateConflict.markIgnored();
     }
     else
     {
         ConnectionStateConflict.markFailed(neo4jError);
     }
 }
Ejemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldProcessAckFailureMessageWithPendingError() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldProcessAckFailureMessageWithPendingError()
        {
            Neo4jError error = Neo4jError.from(new Exception());

            _connectionState.markFailed(error);
            assertEquals(error, _connectionState.PendingError);

            BoltStateMachineState newState = _state.process(AckFailureMessage.INSTANCE, _context);

            assertEquals(_readyState, newState);
            assertNull(_connectionState.PendingError);
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBeAbleToUnpackRelationship() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBeAbleToUnpackRelationship()
        {
            try
            {
                // When
                Unpacked(Packed(ALICE_KNOWS_BOB));
                fail("exception expected.");
            }
            catch (BoltIOException ex)
            {
                assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.TypeError, "Relationship values cannot be unpacked with this version of bolt."), Neo4jError.from(ex));
            }
        }
Ejemplo n.º 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldProcessResetMessageWithPerndingError() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldProcessResetMessageWithPerndingError()
        {
            when(_context.resetMachine()).thenReturn(true);                 // reset successful
            Neo4jError error = Neo4jError.from(new Exception());

            _connectionState.markFailed(error);
            assertEquals(error, _connectionState.PendingError);

            BoltStateMachineState newState = _state.process(ResetMessage.INSTANCE, _context);

            assertEquals(_readyState, newState);
            assertNull(_connectionState.PendingError);
        }
Ejemplo n.º 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCallExternalErrorOnInitWithNullKeys() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCallExternalErrorOnInitWithNullKeys()
        {
            BoltStateMachine          stateMachine = mock(typeof(BoltStateMachine));
            SynchronousBoltConnection connection   = new SynchronousBoltConnection(stateMachine);

            _channel = new EmbeddedChannel(NewDecoder(connection));

            string userAgent = "Test/User Agent 1.0";
            IDictionary <string, object> authToken = MapUtil.map("scheme", "basic", null, "user", "credentials", "password");

            _channel.writeInbound(Unpooled.wrappedBuffer(serialize(PackerUnderTest, new InitMessage(userAgent, authToken))));
            _channel.finishAndReleaseAll();

            verify(stateMachine).handleExternalFailure(eq(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.")), any());
        }
Ejemplo n.º 16
0
//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());
        }
Ejemplo n.º 17
0
        private void Execute(StatementDeserializer statements, ExecutionResultSerializer output, IList <Neo4jError> errors, HttpServletRequest request)
        {
            ExecuteStatements(statements, output, errors, request);

            if (Neo4jError.shouldRollBackOn(errors))
            {
                Rollback(errors);
            }
            else
            {
                _context.suspendSinceTransactionsAreStillThreadBound();
                long lastActiveTimestamp = _registry.release(_id, this);
                output.TransactionStatus(lastActiveTimestamp);
            }
        }
Ejemplo n.º 18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void handleExternalFailure(org.neo4j.bolt.runtime.Neo4jError error, org.neo4j.bolt.runtime.BoltResponseHandler handler) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        public override void HandleExternalFailure(Neo4jError error, BoltResponseHandler handler)
        {
            Before(handler);
            try
            {
                if (ConnectionStateConflict.canProcessMessage())
                {
                    Fail(error);
                    _state = _failedState;
                }
            }
            finally
            {
                After();
            }
        }
Ejemplo n.º 19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogShortWarningOnClientDisconnectMidwayThroughQuery() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLogShortWarningOnClientDisconnectMidwayThroughQuery()
        {
            // Connections dying is not exceptional per-se, so we don't need to fill the log with
            // eye-catching stack traces; but it could be indicative of some issue, so log a brief
            // warning in the debug log at least.

            // Given
            PackOutputClosedException outputClosed = new PackOutputClosedException("Output closed", "<client>");
            Neo4jError txTerminated = Neo4jError.from(new TransactionTerminatedException(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Terminated));

            // When
            AssertableLogProvider logProvider = EmulateFailureWritingError(txTerminated, outputClosed);

            // Then
            logProvider.AssertExactly(inLog("Test").warn(equalTo("Client %s disconnected while query was running. Session has been cleaned up. " + "This can be caused by temporary network problems, but if you see this often, ensure your " + "applications are properly waiting for operations to complete before exiting."), equalTo("<client>")));
        }
Ejemplo n.º 20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBeAbleToUnpackPaths() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBeAbleToUnpackPaths()
        {
            foreach (PathValue path in ALL_PATHS)
            {
                try
                {
                    // When
                    Unpacked(Packed(path));
                    fail("exception expected.");
                }
                catch (BoltIOException ex)
                {
                    assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.TypeError, "Path values cannot be unpacked with this version of bolt."), Neo4jError.from(ex));
                }
            }
        }
Ejemplo n.º 21
0
//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);
        }
Ejemplo n.º 22
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void read(Neo4jPack_Unpacker unpacker) throws java.io.IOException
        public virtual void Read(Neo4jPack_Unpacker unpacker)
        {
            try
            {
                DoRead(unpacker);
            }
            catch (BoltIOException e)
            {
                if (e.CausesFailureMessage())
                {
                    Neo4jError error = Neo4jError.from(e);
                    _connection.enqueue(stateMachine => stateMachine.handleExternalFailure(error, _externalErrorResponseHandler));
                }
                else
                {
                    throw e;
                }
            }
        }
Ejemplo n.º 23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void onlyDatabaseErrorsAreLogged()
        public virtual void OnlyDatabaseErrorsAreLogged()
        {
            AssertableLogProvider userLog     = new AssertableLogProvider();
            AssertableLogProvider internalLog = new AssertableLogProvider();
            ErrorReporter         reporter    = NewErrorReporter(userLog, internalLog);

            foreach (Org.Neo4j.Kernel.Api.Exceptions.Status_Classification classification in Enum.GetValues(typeof(Org.Neo4j.Kernel.Api.Exceptions.Status_Classification)))
            {
                if (classification != Org.Neo4j.Kernel.Api.Exceptions.Status_Classification.DatabaseError)
                {
                    Org.Neo4j.Kernel.Api.Exceptions.Status_Code code = NewStatusCode(classification);
                    Neo4jError error = Neo4jError.from(() => code, "Database error");
                    reporter.Report(error);

                    userLog.AssertNoLoggingOccurred();
                    internalLog.AssertNoLoggingOccurred();
                }
            }
        }
Ejemplo n.º 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void databaseErrorShouldLogFullMessageInDebugLogAndHelpfulPointerInUserLog()
        public virtual void DatabaseErrorShouldLogFullMessageInDebugLogAndHelpfulPointerInUserLog()
        {
            // given
            AssertableLogProvider userLog     = new AssertableLogProvider();
            AssertableLogProvider internalLog = new AssertableLogProvider();
            ErrorReporter         reporter    = NewErrorReporter(userLog, internalLog);

            Neo4jError error = Neo4jError.fatalFrom(new TestDatabaseError());

            System.Guid reference = error.Reference();

            // when
            reporter.Report(error);

            // then
            userLog.RawMessageMatcher().assertContains("Client triggered an unexpected error");
            userLog.RawMessageMatcher().assertContains(reference.ToString());
            userLog.RawMessageMatcher().assertContains("Database error");

            internalLog.RawMessageMatcher().assertContains(reference.ToString());
            internalLog.RawMessageMatcher().assertContains("Database error");
        }
Ejemplo n.º 25
0
        private void PublishError(BoltResponseMessageWriter messageWriter, Neo4jError error)
        {
            try
            {
                if (error.Fatal)
                {
                    messageWriter.Write(new FatalFailureMessage(error.Status(), error.Message()));
                }
                else
                {
                    messageWriter.Write(new FailureMessage(error.Status(), error.Message()));
                }
            }
            catch (PackOutputClosedException e)
            {
                // Can't write error to the client, because the connection is closed.
                // Very likely our error is related to the connection being closed.

                // If the error is that the transaction was terminated, then the error is a side-effect of
                // us cleaning up stuff that was running when the client disconnected. Log a warning without
                // stack trace to highlight clients are disconnecting while stuff is running:
                if (_clientMidOpDisconnectErrors.Contains(error.Status()))
                {
                    Log.warn("Client %s disconnected while query was running. Session has been cleaned up. " + "This can be caused by temporary network problems, but if you see this often, " + "ensure your applications are properly waiting for operations to complete before exiting.", e.ClientAddress());
                    return;
                }

                // If the error isn't that the tx was terminated, log it to the console for debugging. It's likely
                // there are other "ok" errors that we can whitelist into the conditional above over time.
                Log.warn("Unable to send error back to the client. " + e.Message, error.Cause());
            }
            catch (Exception t)
            {
                // some unexpected error happened while writing exception back to the client
                // log it together with the original error being suppressed
                t.addSuppressed(error.Cause());
                Log.error("Unable to send error back to the client", t);
            }
        }
Ejemplo n.º 26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotBeAbleToUnpackUnboundRelationship() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotBeAbleToUnpackUnboundRelationship()
        {
            // Given
            PackedOutputArray @out = new PackedOutputArray();

            Neo4jPackV1.Packer packer = _neo4jPack.newPacker(@out);

            packer.packStructHeader(3, UNBOUND_RELATIONSHIP);
            packer.pack(ValueUtils.of(1L));
            packer.pack(ValueUtils.of("RELATES_TO"));
            packer.pack(ValueUtils.asMapValue(MapUtil.map("a", 1L, "b", "x")));

            try
            {
                // When
                Unpacked(@out.Bytes());
                fail("exception expected.");
            }
            catch (BoltIOException ex)
            {
                assertEquals(Neo4jError.from(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.TypeError, "Relationship values cannot be unpacked with this version of bolt."), Neo4jError.from(ex));
            }
        }
Ejemplo n.º 27
0
//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));
            }
        }
Ejemplo n.º 28
0
 public override void ReportError(Neo4jError err)
 {
     _errorReporter.report(err);
 }
Ejemplo n.º 29
0
 public override void MarkFailed(Neo4jError error)
 {
     this._error = error;
 }
Ejemplo n.º 30
0
 private void ClearState()
 {
     _error   = null;
     _ignored = false;
     _metadata.clear();
 }