Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnEmptyMapForEmptyProperties()
        public virtual void ShouldReturnEmptyMapForEmptyProperties()
        {
            // Given
            string node = HTTP.POST(Server().baseUri().resolve("db/data/node").ToString()).location();
            string rel  = HTTP.POST(node + "/relationships", quotedJson("{'to':'" + node + "', " + "'type':'LOVES'}")).location();

            // When
            HTTP.Response res = HTTP.GET(rel + "/properties");

            // Then
            MatcherAssert.assertThat(res.RawContent(), equalTo("{ }"));
        }
Exemple #2
0
 private string ParseErrorMessage(HTTP.Response response)
 {
     try
     {
         JsonNode data = JsonHelper.jsonNode(response.RawContent());
         if (data.has("errors") && data.get("errors").has(0))
         {
             JsonNode firstError = data.get("errors").get(0);
             if (firstError.has("message"))
             {
                 return(firstError.get("message").asText());
             }
         }
     }
     catch (JsonParseException)
     {
         fail("Unexpected error parsing Json!");
     }
     return("");
 }
Exemple #3
0
        public override string ExecuteQuery(RESTSubject subject, string call, IDictionary <string, object> @params, System.Action <ResourceIterator <IDictionary <string, object> > > resultConsumer)
        {
            HTTP.RawPayload payload  = ConstructQuery(call);
            HTTP.Response   response = HTTP.withHeaders(HttpHeaders.AUTHORIZATION, subject.PrincipalCredentials).request(POST, CommitURL(), payload);

            try
            {
                string error = ParseErrorMessage(response);
                if (error.Length > 0)
                {
                    return(error);
                }
                Consume(resultConsumer, JsonHelper.jsonNode(response.RawContent()));
            }
            catch (JsonParseException)
            {
                fail("Unexpected error parsing Json!");
            }

            return("");
        }
Exemple #4
0
        public virtual void ResetTransactionTimeoutOfAnOpenTransaction()
        {
            // Given
            HTTP.Response initialResponse       = POST(DataUri + "transaction");
            string        location              = initialResponse.Location();
            long          initialExpirationTime = ExpirationTime(jsonToMap(initialResponse.RawContent()));

            // This generous wait time is necessary to compensate for limited resolution of RFC 1123 timestamps
            // and the fact that the system clock is allowed to run "backwards" between threads
            // (cf. http://stackoverflow.com/questions/2978598)
            //
            Thread.Sleep(3000);

            // Document
            ResponseEntity response = GenConflict.get().expectedStatus(200).payload(QuotedJson("{ 'statements': [ ] }")).post(location);

            // Then
            IDictionary <string, object> result = jsonToMap(response.Entity());

            AssertNoErrors(result);
            long newExpirationTime = ExpirationTime(result);

            assertTrue("Expiration time was not increased", newExpirationTime > initialExpirationTime);
        }
Exemple #5
0
 public override void AssertAuthenticated(RESTSubject subject)
 {
     HTTP.Response authenticate = authenticate(subject.PrincipalCredentials);
     assertThat(authenticate.RawContent(), authenticate.Status(), equalTo(200));
 }
Exemple #6
0
 private static void AssertTxWasTerminated(HTTP.Response txResponse)
 {
     assertEquals(200, txResponse.Status());
     assertThat(txResponse, hasErrors(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.ExecutionFailed));
     assertThat(txResponse.RawContent(), containsString(typeof(LockClientStoppedException).Name));
 }