public async void ShouldKillLongRunningStatement()
            {
                using (var session = _driver.Session())
                {
                    var cancelTokenSource = new CancellationTokenSource();
                    var resetSession      = ResetSessionAfterTimeout(session, 5, cancelTokenSource.Token);

                    var result = session.Run("CALL test.driver.longRunningStatement({seconds})",
                                             new Dictionary <string, object> {
                        { "seconds", 20 }
                    });
                    var exception = Record.Exception(() => result.Consume());

                    // if we finished procedure then we cancel the reset timeout
                    cancelTokenSource.Cancel();
                    await resetSession;

                    var serverInfo = result.Summary.Server;

                    if (ServerVersion.Version(serverInfo.Version) >= ServerVersion.V3_1_0)
                    {
                        exception.Should().BeOfType <TransientException>();
                    }
                    else
                    {
                        exception.Should().BeOfType <ClientException>();
                    }
                    exception.Message.StartsWith("Failed to invoke procedure `test.driver.longRunningStatement`: " +
                                                 "Caused by: org.neo4j.graphdb.TransactionTerminatedException");
                }
            }
            public void GetsSummary()
            {
                using (var session = _driver.Session())
                {
                    var result = session.Run("PROFILE CREATE (p:Person { Name: 'Test'})");
                    var stats  = result.Consume().Counters;
                    stats.ToString().Should()
                    .Be("Counters{NodesCreated=1, NodesDeleted=0, RelationshipsCreated=0, " +
                        "RelationshipsDeleted=0, PropertiesSet=1, LabelsAdded=1, LabelsRemoved=0, " +
                        "IndexesAdded=0, IndexesRemoved=0, ConstraintsAdded=0, ConstraintsRemoved=0}");
                    var serverInfo = result.Summary.Server;

                    serverInfo.Address.Should().Be("localhost:7687");
                    if (ServerVersion.Version(serverInfo.Version) >= ServerVersion.V3_1_0)
                    {
                        result.Summary.ResultAvailableAfter.Should().BeGreaterOrEqualTo(TimeSpan.Zero);
                        result.Summary.ResultConsumedAfter.Should().BeGreaterOrEqualTo(TimeSpan.Zero);
                    }
                    else
                    {
                        result.Summary.ResultAvailableAfter.Should().BeLessThan(TimeSpan.Zero);
                        result.Summary.ResultConsumedAfter.Should().BeLessThan(TimeSpan.Zero);
                    }
                }
            }
Пример #3
0
        public void ShouldDefaultToUnknownVersion(string version)
        {
            var serverVersion = ServerVersion.Version(version);

            serverVersion.Major.Should().Be(0);
            serverVersion.Minor.Should().Be(0);
            serverVersion.Patch.Should().Be(0);
        }
Пример #4
0
        public void ShouldHandleMajorMinorPatchVersion(string version)
        {
            var serverVersion = ServerVersion.Version(version);

            serverVersion.Major.Should().Be(3);
            serverVersion.Minor.Should().Be(2);
            serverVersion.Patch.Should().Be(1);
        }
Пример #5
0
        public void ShouldHandleDevVersion()
        {
            var version       = "Neo4j/dev";
            var serverVersion = ServerVersion.Version(version);

            serverVersion.Major.Should().Be(Int32.MaxValue);
            serverVersion.Minor.Should().Be(Int32.MaxValue);
            serverVersion.Patch.Should().Be(Int32.MaxValue);
        }
Пример #6
0
        public void UpdatePackStream(string serverVersion)
        {
            var version = ServerVersion.Version(serverVersion);

            if (version >= ServerVersion.V3_2_0)
            {
                return;
            }
            SetupPackStreamFormatWriterAndReader(false);
        }
        public bool ReconfigIfNecessary(string serverVersion)
        {
            var version = ServerVersion.Version(serverVersion);

            if (version >= ServerVersion.V3_2_0)
            {
                return(false);
            }

            // downgrade PackStream to not support byte array.
            CreateReaderAndWriter(BoltProtocolPackStream.V1NoByteArray);
            return(true);
        }
Пример #8
0
        public void Authenticate(IConnection connection, string userAgent, IAuthToken authToken)
        {
            var initCollector = new InitCollector();

            connection.Enqueue(new InitMessage(userAgent, authToken.AsDictionary()), initCollector);
            connection.Sync();
            ((ServerInfo)connection.Server).Version = initCollector.Server;

            if (!(ServerVersion.Version(initCollector.Server) >= ServerVersion.V3_2_0))
            {
                connection.ResetMessageReaderAndWriterForServerV3_1();
            }
        }
            private void CheckBookmarkSupport()
            {
                string version = null;

                using (var session = _driver.Session())
                {
                    version = session.Run("RETURN 1").Consume().Server.Version;
                }
                if (ServerVersion.Version(version) >= ServerVersion.V3_1_0)
                {
                    Skip = false;
                }
                else
                {
                    Skip = true;
                }
            }