Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("ResultOfMethodCallIgnored") @Test public void begin_and_execute_periodic_commit_that_fails() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void BeginAndExecutePeriodicCommitThatFails()
        {
            File file = File.createTempFile("begin_and_execute_periodic_commit_that_fails", ".csv").AbsoluteFile;

            try
            {
                PrintStream @out = new PrintStream(new FileStream(file, FileMode.Create, FileAccess.Write));
                @out.println("1");
                @out.println("2");
                @out.println("0");
                @out.println("3");
                @out.close();

                string url   = file.toURI().toURL().ToString().Replace("\\", "\\\\");
                string query = "USING PERIODIC COMMIT 1 LOAD CSV FROM \\\"" + url + "\\\" AS line CREATE ({name: 1/toInt(line[0])});";

                // begin and execute and commit
                HTTP.RawPayload payload  = quotedJson("{ 'statements': [ { 'statement': '" + query + "' } ] }");
                HTTP.Response   response = POST(TxCommitUri(), payload);

                assertThat(response.Status(), equalTo(200));
                assertThat(response, hasErrors(Org.Neo4j.Kernel.Api.Exceptions.Status_Statement.ArithmeticError));

                JsonNode message = response.Get("errors").get(0).get("message");
                assertTrue("Expected LOAD CSV line number information", message.ToString().Contains("on line 3. Possibly the last row committed during import is line 2. " + "Note that this information might not be accurate."));
            }
            finally
            {
                file.delete();
            }
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHavePredefinedRoles() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldHavePredefinedRoles()
        {
            // Given
            StartServerWithConfiguredUser();

            // When
            string method = "POST";
            string path   = "db/data/transaction/commit";

            HTTP.RawPayload payload  = HTTP.RawPayload.quotedJson("{'statements':[{'statement':'CALL dbms.security.listRoles()'}]}");
            HTTP.Response   response = HTTP.withBasicAuth("neo4j", "secret").request(method, Server.baseUri().resolve(path).ToString(), payload);

            // Then
            assertThat(response.Status(), equalTo(200));
            ArrayNode errors = ( ArrayNode )response.Get("errors");

            assertThat("Should have no errors", errors.size(), equalTo(0));
            ArrayNode results = ( ArrayNode )response.Get("results");
            ArrayNode data    = ( ArrayNode )results.get(0).get("data");

            assertThat("Should have 5 predefined roles", data.size(), equalTo(5));
            Stream <string> values = data.findValues("row").Select(row => row.get(0).asText());

            assertThat("Expected specific roles", values.collect(Collectors.toList()), hasItems("admin", "architect", "publisher", "editor", "reader"));
        }
Esempio n. 3
0
        private static HTTP.Response ExecuteUpdateStatement(HTTP.Response tx, long value, HTTP.Builder http)
        {
            string updateQuery = "MATCH (n:" + _label + ") SET n." + PROPERTY + "=" + value;

            HTTP.RawPayload json = quotedJson("{'statements': [{'statement':'" + updateQuery + "'}]}");
            return(http.Post(tx.Location(), json));
        }
Esempio n. 4
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("");
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowExecutingEnterpriseBuiltInProceduresWithAuthDisabled() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldAllowExecutingEnterpriseBuiltInProceduresWithAuthDisabled()
        {
            // Given
            StartServerWithAuthDisabled();

            // When
            string method = "POST";
            string path   = "db/data/transaction/commit";

            HTTP.RawPayload payload  = HTTP.RawPayload.quotedJson("{'statements':[{'statement':'CALL dbms.listQueries()'}]}");
            HTTP.Response   response = HTTP.request(method, Server.baseUri().resolve(path).ToString(), payload);

            // Then
            assertThat(response.Status(), equalTo(200));
            ArrayNode errors = ( ArrayNode )response.Get("errors");

            assertThat("Should have no errors", errors.size(), equalTo(0));
            ArrayNode results = ( ArrayNode )response.Get("results");
            ArrayNode data    = ( ArrayNode )results.get(0).get("data");

            assertThat("Should see our own query", data.size(), equalTo(1));
        }