예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldShowServerMetrics() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldShowServerMetrics()
        {
            // Given
            File      metrics = Folder.file("metrics");
            NeoServer server  = EnterpriseServerBuilder.serverOnRandomPorts().usingDataDir(Folder.databaseDir().AbsolutePath).withProperty(MetricsSettings.metricsEnabled.name(), "true").withProperty(MetricsSettings.csvEnabled.name(), "true").withProperty(MetricsSettings.csvPath.name(), metrics.Path).withProperty(MetricsSettings.csvInterval.name(), "100ms").persistent().build();

            try
            {
                // when
                server.Start();

                string host = "http://localhost:" + server.BaseUri().Port + ServerSettings.rest_api_path.DefaultValue + "/transaction/commit";

                for (int i = 0; i < 5; i++)
                {
                    ClientResponse r = Client.create().resource(host).accept(APPLICATION_JSON).type(APPLICATION_JSON).post(typeof(ClientResponse), "{ 'statements': [ { 'statement': 'CREATE ()' } ] }");
                    assertEquals(200, r.Status);
                }

                // then
                AssertMetricsExists(metrics, ServerMetrics.THREAD_JETTY_ALL);
                AssertMetricsExists(metrics, ServerMetrics.THREAD_JETTY_IDLE);
            }
            finally
            {
                server.Stop();
            }
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRedirectToBrowserUsingXForwardedHeaders() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRedirectToBrowserUsingXForwardedHeaders()
        {
            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).header("X-Forwarded-Host", "foo.bar:8734").header("X-Forwarded-Proto", "https").get(server.baseUri().toString());
            JaxRsResponse response = (new RestRequest(_server.baseUri(), nonRedirectingClient)).accept(MediaType.TEXT_HTML_TYPE).header("X-Forwarded-Host", "foo.bar:8734").header("X-Forwarded-Proto", "https").get(_server.baseUri().ToString());

            assertEquals(303, response.Status);
            assertEquals(new URI("https://foo.bar:8734/browser/"), response.Location);
            response.Close();
        }
예제 #3
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)));
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRequireAuthorizationForHAStatusEndpoints() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldRequireAuthorizationForHAStatusEndpoints()
        {
            // Given
            int       clusterPort = PortAuthority.allocatePort();
            NeoServer server      = EnterpriseServerBuilder.serverOnRandomPorts().withProperty(GraphDatabaseSettings.auth_enabled.name(), "true").usingDataDir(Folder.Root.AbsolutePath).withProperty(mode.name(), "HA").withProperty(server_id.name(), "1").withProperty(cluster_server.name(), ":" + clusterPort).withProperty(initial_hosts.name(), ":" + clusterPort).persistent().build();

            try
            {
                server.Start();
                server.Database;

                assertThat(server.Database.Graph, @is(instanceOf(typeof(HighlyAvailableGraphDatabase))));

                Client         client = Client.create();
                ClientResponse r      = client.resource(GetHaEndpoint(server)).accept(APPLICATION_JSON).get(typeof(ClientResponse));
                assertEquals(401, r.Status);
            }
            finally
            {
                server.Stop();
            }
        }