/// <summary> /// This test makes sure that the database is able to start after having been stopped during initialization. /// /// In order to make sure that the server is stopped during startup we create a separate thread that calls stop. /// In order to make sure that this thread does not call stop before the startup procedure has started we use a /// custom implementation of a PageSwapperFactory, which communicates with the thread that calls stop. We do this /// via a static semaphore. </summary> /// <exception cref="IOException"> </exception> /// <exception cref="InterruptedException"> </exception> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToRestartWhenStoppedDuringStartup() throws java.io.IOException, InterruptedException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToRestartWhenStoppedDuringStartup() { // Make sure that the semaphore is in a clean state. _semaphore.drainPermits(); // Get a server that uses our custom swapper. NeoServer server = GetNeoServer(CUSTOM_SWAPPER); try { AtomicBoolean failure = new AtomicBoolean(); Thread serverStoppingThread = ThreadTestUtils.fork(StopServerAfterStartingHasStarted(server, failure)); server.Start(); // Wait for the server to stop. serverStoppingThread.Join(); // Check if the server stopped successfully. if (failure.get()) { fail("Server failed to stop."); } // Verify that we can start the server again. server = GetNeoServer(CUSTOM_SWAPPER); server.Start(); } finally { server.Stop(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToStartInHAMode() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToStartInHAMode() { // Given int clusterPort = PortAuthority.allocatePort(); NeoServer server = EnterpriseServerBuilder.serverOnRandomPorts().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)))); HTTP.Response haEndpoint = HTTP.GET(GetHaEndpoint(server)); assertEquals(200, haEndpoint.Status()); assertThat(haEndpoint.RawContent(), containsString("master")); HTTP.Response discovery = HTTP.GET(server.BaseUri().toASCIIString()); assertEquals(200, discovery.Status()); } finally { server.Stop(); } }
//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(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToRestartServer() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToRestartServer() { // Given string dataDirectory1 = _baseDir.directory("data1").AbsolutePath; string dataDirectory2 = _baseDir.directory("data2").AbsolutePath; Config config = Config.fromFile(EnterpriseServerBuilder.serverOnRandomPorts().withDefaultDatabaseTuning().usingDataDir(dataDirectory1).createConfigFiles()).withHome(_baseDir.directory()).withSetting(GraphDatabaseSettings.logs_directory, _baseDir.directory("logs").Path).build(); // When NeoServer server = _cleanup.add(new OpenEnterpriseNeoServer(config, GraphDbDependencies())); server.Start(); assertNotNull(server.Database.Graph); assertEquals(config.Get(GraphDatabaseSettings.database_path).AbsolutePath, server.Database.Location.AbsolutePath); // Change the database location config.Augment(GraphDatabaseSettings.data_directory, dataDirectory2); ServerManagement bean = new ServerManagement(server); bean.RestartServer(); // Then assertNotNull(server.Database.Graph); assertEquals(config.Get(GraphDatabaseSettings.database_path).AbsolutePath, server.Database.Location.AbsolutePath); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void givenExplicitlyDisabledServerLoggingConfigurationShouldNotLogAccesses() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void GivenExplicitlyDisabledServerLoggingConfigurationShouldNotLogAccesses() { // given string directoryPrefix = _testName.MethodName; File logDirectory = _testDirectory.directory(directoryPrefix + "-logdir"); NeoServer server = serverOnRandomPorts().withDefaultDatabaseTuning().persistent().withProperty(ServerSettings.http_logging_enabled.name(), Settings.FALSE).withProperty(GraphDatabaseSettings.logs_directory.name(), logDirectory.ToString()).withProperty((new BoltConnector("bolt")).listen_address.name(), ":0").usingDataDir(_testDirectory.directory(directoryPrefix + "-dbdir").AbsolutePath).build(); try { server.Start(); FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server); // when string query = "?implicitlyDisabled" + RandomString(); JaxRsResponse response = (new RestRequest()).get(functionalTestHelper.ManagementUri() + query); assertThat(response.Status, @is(HttpStatus.SC_OK)); response.Close(); // then File httpLog = new File(logDirectory, "http.log"); assertThat(httpLog.exists(), @is(false)); } finally { server.Stop(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void givenExplicitlyEnabledServerLoggingConfigurationShouldLogAccess() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void GivenExplicitlyEnabledServerLoggingConfigurationShouldLogAccess() { // given string directoryPrefix = _testName.MethodName; File logDirectory = _testDirectory.directory(directoryPrefix + "-logdir"); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String query = "?explicitlyEnabled=" + randomString(); string query = "?explicitlyEnabled=" + RandomString(); NeoServer server = serverOnRandomPorts().withDefaultDatabaseTuning().persistent().withProperty(ServerSettings.http_logging_enabled.name(), Settings.TRUE).withProperty(GraphDatabaseSettings.logs_directory.name(), logDirectory.AbsolutePath).withProperty((new BoltConnector("bolt")).listen_address.name(), ":0").usingDataDir(_testDirectory.directory(directoryPrefix + "-dbdir").AbsolutePath).build(); try { server.Start(); FunctionalTestHelper functionalTestHelper = new FunctionalTestHelper(server); // when JaxRsResponse response = (new RestRequest()).get(functionalTestHelper.ManagementUri() + query); assertThat(response.Status, @is(HttpStatus.SC_OK)); response.Close(); // then File httpLog = new File(logDirectory, "http.log"); assertEventually("request appears in log", FileContentSupplier(httpLog), containsString(query), 5, TimeUnit.SECONDS); } finally { server.Stop(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static org.neo4j.server.NeoServer createServer(CommunityServerBuilder builder, boolean persistent, java.io.File path) throws java.io.IOException private static NeoServer CreateServer(CommunityServerBuilder builder, bool persistent, File path) { if (persistent) { builder = builder.Persistent(); } builder.OnRandomPorts(); NeoServer server = builder.UsingDataDir(path != null ? path.AbsolutePath : null).build(); server.Start(); return(server); }
//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(); } }