示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRedirectToBrowser() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRedirectToBrowser()
        {
            Client nonRedirectingClient = Client.create();

            nonRedirectingClient.FollowRedirects = false;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.server.rest.JaxRsResponse response = new org.neo4j.server.rest.RestRequest(server.baseUri(), nonRedirectingClient).accept(javax.ws.rs.core.MediaType.TEXT_HTML_TYPE).get(server.baseUri().toString());
            JaxRsResponse response = (new RestRequest(_server.baseUri(), nonRedirectingClient)).accept(MediaType.TEXT_HTML_TYPE).get(_server.baseUri().ToString());

            assertEquals(303, response.Status);
            assertEquals(new URI(_server.baseUri() + "browser/"), response.Location);
            response.Close();
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldPassHeaders() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldPassHeaders()
        {
            int httpPort = LocalHttpPort;

            string jsonData = (new PrettyJSON()).array().@object().key("method").value("GET").key("to").value("../.." + DUMMY_WEB_SERVICE_MOUNT_POINT + "/needs-auth-header").key("body").@object().endObject().endObject().endArray().ToString();

            JaxRsResponse response = (new RestRequest(null, "user", "pass")).post(_server.baseUri() + "db/data/batch", jsonData);

            assertEquals(200, response.Status);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<java.util.Map<String, Object>> responseData = jsonToList(response.getEntity());
            IList <IDictionary <string, object> > responseData = jsonToList(response.Entity);

            IDictionary <string, object> res = (IDictionary <string, object>)responseData[0]["body"];

            /*
             * {
             *   Accept=[application/json],
             *   Content-Type=[application/json],
             *   Authorization=[Basic dXNlcjpwYXNz],
             *   User-Agent=[Java/1.6.0_27] <-- ignore that, it changes often
             *   Host=[localhost:7474],
             *   Connection=[keep-alive],
             *   Content-Length=[86]
             * }
             */
            assertEquals("Basic dXNlcjpwYXNz", res["Authorization"]);
            assertEquals("application/json", res["Accept"]);
            assertEquals("application/json", res["Content-Type"]);
            assertEquals("localhost:" + httpPort, res["Host"]);
            assertEquals("keep-alive", res["Connection"]);
        }
示例#3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLoadThirdPartyJaxRsClasses() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLoadThirdPartyJaxRsClasses()
        {
            _server = CommunityServerBuilder.serverOnRandomPorts().withThirdPartyJaxRsPackage("org.dummy.web.service", DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT).usingDataDir(Folder.directory(Name.MethodName).AbsolutePath).build();
            _server.start();

            URI    thirdPartyServiceUri = (new URI(_server.baseUri().ToString() + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT)).normalize();
            string response             = CLIENT.resource(thirdPartyServiceUri.ToString()).get(typeof(string));

            assertEquals("hello", response);

            // Assert that extensions gets initialized
            int nodesCreated = CreateSimpleDatabase(_server.Database.Graph);

            thirdPartyServiceUri = (new URI(_server.baseUri().ToString() + DummyThirdPartyWebService.DUMMY_WEB_SERVICE_MOUNT_POINT + "/inject-test")).normalize();
            response             = CLIENT.resource(thirdPartyServiceUri.ToString()).get(typeof(string));
            assertEquals(nodesCreated.ToString(), response);
        }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldLogStartup()
        public virtual void ShouldLogStartup()
        {
            // Check the logs
            string logContent = @out.ToString();

            assertThat(logContent.Length, @is(greaterThan(0)));
            assertThat(logContent, containsString(NEO4J_IS_STARTING_MESSAGE));
            // Check the server is alive
            Client nonRedirectingClient = Client.create();

            nonRedirectingClient.FollowRedirects = false;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.server.rest.JaxRsResponse response = new org.neo4j.server.rest.RestRequest(server.baseUri(), nonRedirectingClient).get();
            JaxRsResponse response = (new RestRequest(_server.baseUri(), nonRedirectingClient)).get();

            assertThat(response.Status, @is(greaterThan(199)));
        }
示例#5
0
 public string DataUri()
 {
     return(_server.baseUri().ToString() + "db/data/");
 }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Setup()
        {
            ServerHelper.cleanTheDatabase(_readOnlyServer);
            _readOnlyServer = ServerHelper.createReadOnlyServer(Dir.storeDir());
            _http           = HTTP.withBaseUri(_readOnlyServer.baseUri());
        }
示例#7
0
 internal virtual JaxRsResponse Exec(string command, string engine)
 {
     return(RestRequest.Req().post(Server.baseUri() + "db/manage/server/console", "{" + "\"engine\":\"" + engine + "\"," + "\"command\":\"" + command + "\\n\"}"));
 }