//https://github.com/Readify/Neo4jClient/issues/127
        public async Task ReturnsCorrectError_WhenTransactionIsAutomaticallyRolledBack_ViaNeo4j_2_2_6_Plus(RestTestHarness.Neo4jVersion version)
        {
            /* In 2.2.6 ClientErrors (Constraint Violations etc) were changed to Automatically rollback. This created a 404 error when *we* tried to rollback on an error, as the transaction no longer existed. */
            var initTransactionRequest     = MockRequest.PostJson("/transaction", @"{
                'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
            var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");

            using (var testHarness = new RestTestHarness
            {
                {
                    initTransactionRequest,
                    MockResponse.Json(201, TransactionRestResponseHelper.GenerateCypherErrorResponse(1, "{\"code\":\"Neo.ClientError.Schema.ConstraintViolation\",\"message\":\"Node 19572 already exists with label User and property.\"}"), "http://foo/db/data/transaction/1")
                },
                {
                    rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
                }
            })
            {
                var client = testHarness.CreateGraphClient(version);
                await client.ConnectAsync();

                using (var transaction = client.BeginTransaction())
                {
                    await Assert.ThrowsAsync <NeoException>(async() => await client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResultsAsync());
                }
            }
        }
        //https://github.com/Readify/Neo4jClient/issues/127
        public async Task ReturnsThe404_WhenVersionIsLessThan_2_2_6(RestTestHarness.Neo4jVersion version)
        {
            var initTransactionRequest     = MockRequest.PostJson("/transaction", @"{
                'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
            var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");

            using (var testHarness = new RestTestHarness
            {
                {
                    initTransactionRequest,
                    MockResponse.Json(201, TransactionRestResponseHelper.GenerateCypherErrorResponse(1, "{\"code\":\"Neo.ClientError.Schema.ConstraintViolation\",\"message\":\"Node 19572 already exists with label User and property.\"}"), "http://foo/db/data/transaction/1")
                },
                {
                    rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
                }
            })
            {
                var client = testHarness.CreateGraphClient(version);
                await client.ConnectAsync();

                try
                {
                    using (var transaction = client.BeginTransaction())
                    {
                        await client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResultsAsync();
                    }
                }
                catch (Exception ex)
                {
                    Assert.True(ex.Message.Contains("404"));
                }
            }
        }
 //https://github.com/Readify/Neo4jClient/issues/127
 public void ReturnsCorrectError_WhenTransactionIsAutomaticallyRolledBack_ViaNeo4j_2_2_6_Plus([Values(RestTestHarness.Neo4jVersion.Neo226/*, RestTestHarness.Neo4jVersion.Neo23*/)] RestTestHarness.Neo4jVersion version)
 {
     /* In 2.2.6 ClientErrors (Constraint Violations etc) were changed to Automatically rollback. This created a 404 error when *we* tried to rollback on an error, as the transaction no longer existed. */
     var initTransactionRequest = MockRequest.PostJson("/transaction", @"{
         'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
     var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");
     using (var testHarness = new RestTestHarness
     {
         {
             initTransactionRequest,
             MockResponse.Json(201, TransactionRestResponseHelper.GenerateCypherErrorResponse(1, "{\"code\":\"Neo.ClientError.Schema.ConstraintViolation\",\"message\":\"Node 19572 already exists with label User and property.\"}"), "http://foo/db/data/transaction/1")
         },
         {
             rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
         }
     })
     {
         var client = testHarness.CreateGraphClient(version);
         client.Connect();
         using (var transaction = client.BeginTransaction())
         {
             client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResults();
         }
     }
 }
        //https://github.com/Readify/Neo4jClient/issues/127
        public async Task ReturnsThe404_WhenVersionIs_2_2_6_Plus_WhenActuallyTimingOut(RestTestHarness.Neo4jVersion version)
        {
            var initTransactionRequest     = MockRequest.PostJson("/transaction", @"{
                'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
            var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");

            using (var testHarness = new RestTestHarness()
            {
                {
                    initTransactionRequest,
                    MockResponse.Json(201, TransactionRestResponseHelper.GenerateInitTransactionResponse(1), "http://foo/db/data/transaction/1")
                },
                {
                    rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
                }
            })
            {
                var client = testHarness.CreateGraphClient(version);
                await client.ConnectAsync();

                try
                {
                    using (var transaction = client.BeginTransaction())
                    {
                        await client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResultsAsync();
                    }
                    throw new Exception("Should not reach this code, as there is an expected exception.");
                }
                catch (Exception ex)
                {
                    Assert.True(ex.Message.Contains("404"));
                }
            }
        }
 //https://github.com/Readify/Neo4jClient/issues/127
 public void ReturnsThe404_WhenVersionIs_2_2_6_Plus_WhenActuallyTimingOut([Values(RestTestHarness.Neo4jVersion.Neo226, RestTestHarness.Neo4jVersion.Neo23)] RestTestHarness.Neo4jVersion version)
 {
     var initTransactionRequest = MockRequest.PostJson("/transaction", @"{
         'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
     var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");
     using (var testHarness = new RestTestHarness()
     {
         {
             initTransactionRequest,
             MockResponse.Json(201, TransactionRestResponseHelper.GenerateInitTransactionResponse(1), "http://foo/db/data/transaction/1")
         },
         {
             rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
         }
     })
     {
         var client = testHarness.CreateGraphClient(version);
         client.Connect();
         try
         {
             using (var transaction = client.BeginTransaction())
             {
                 client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResults();
             }
             Assert.Fail("Should not reach this code, as there is an expected exception.");
         }
         catch (ApplicationException ex)
         {
             Assert.That(ex.Message.Contains("404"));
         }
     }
 }
 public void BeginTransactionShouldFailWithLower20Versions()
 {
     using (var testHarness = new RestTestHarness())
     {
         var client = testHarness.CreateGraphClient(RestTestHarness.Neo4jVersion.Neo19);
         client.Connect();
         client.BeginTransaction();
     }
 }
 public void BeginTransactionShouldFailWithLower20Versions()
 {
     using (var testHarness = new RestTestHarness())
     {
         var client = testHarness.CreateGraphClient(false);
         client.Connect();
         client.BeginTransaction();
     }
 }
Beispiel #8
0
 public void BeginTransactionShouldFailWithLower20Versions()
 {
     using (var testHarness = new RestTestHarness())
     {
         var client = testHarness.CreateGraphClient(RestTestHarness.Neo4jVersion.Neo19);
         client.Connect();
         Assert.That(() => client.BeginTransaction(), Throws.TypeOf <NotSupportedException>());
     }
 }
 public void BeginTransactionShouldFailWithLower20Versions()
 {
     using (var testHarness = new RestTestHarness())
     {
         var client = testHarness.CreateGraphClient(RestTestHarness.Neo4jVersion.Neo19);
         client.Connect();
         Assert.That(() => client.BeginTransaction(), Throws.TypeOf<NotSupportedException>());
     }
 }
        public async Task BeginTransactionShouldFailWithLower20Versions()
        {
            using (var testHarness = new RestTestHarness())
            {
                var client = testHarness.CreateGraphClient(RestTestHarness.Neo4jVersion.Neo19);
                await client.ConnectAsync();

                Assert.Throws <NotSupportedException>(() => client.BeginTransaction());
            }
        }
 //https://github.com/Readify/Neo4jClient/issues/127
 public void ReturnsThe404_WhenVersionIsLessThan_2_2_6([Values(RestTestHarness.Neo4jVersion.Neo20, RestTestHarness.Neo4jVersion.Neo22, RestTestHarness.Neo4jVersion.Neo225)] RestTestHarness.Neo4jVersion version)
 {
     var initTransactionRequest = MockRequest.PostJson("/transaction", @"{
         'statements': [{'statement': 'MATCH n\r\nRETURN count(n)', 'resultDataContents':[], 'parameters': {}}]}");
     var rollbackTransactionRequest = MockRequest.Delete("/transaction/1");
     using (var testHarness = new RestTestHarness
     {
         {
             initTransactionRequest,
             MockResponse.Json(201, TransactionRestResponseHelper.GenerateCypherErrorResponse(1, "{\"code\":\"Neo.ClientError.Schema.ConstraintViolation\",\"message\":\"Node 19572 already exists with label User and property.\"}"), "http://foo/db/data/transaction/1")
         },
         {
             rollbackTransactionRequest, MockResponse.Json(404, "{\"results\":[],\"errors\":[{\"code\":\"Neo.ClientError.Transaction.UnknownId\",\"message\":\"Unrecognized transaction id. Transaction may have timed out and been rolled back.\"}]}")
         }
     })
     {
         var client = testHarness.CreateGraphClient(version);
         client.Connect();
         try
         {
             using (var transaction = client.BeginTransaction())
             {
                 client.Cypher.Match("n").Return(n => n.Count()).ExecuteWithoutResults();
             }
         }
         catch (ApplicationException ex)
         {
             Assert.That(ex.Message.Contains("404"));
         }
     }
 }