//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToAttachToPidAndRunThreadDump() throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToAttachToPidAndRunThreadDump() { long pid = PID; assertThat(pid, @is(not(0))); // Write config file Files.createFile(TestDirectory.file("neo4j.conf").toPath()); // write neo4j.pid file File run = TestDirectory.directory("run"); Files.write(Paths.get(run.AbsolutePath, "neo4j.pid"), pid.ToString().GetBytes()); // Run command, should detect running instance try { using (RealOutsideWorld outsideWorld = new RealOutsideWorld()) { string[] args = new string[] { "threads", "--to=" + TestDirectory.absolutePath().AbsolutePath + "/reports" }; Path homeDir = TestDirectory.directory().toPath(); DiagnosticsReportCommand diagnosticsReportCommand = new DiagnosticsReportCommand(homeDir, homeDir, outsideWorld); diagnosticsReportCommand.Execute(args); } } catch (IncorrectUsage e) { if (e.Message.Equals("Unknown classifier: threads")) { return; // If we get attach API is not available for example in some IBM jdk installs, ignore this test } throw e; } // Verify that we took a thread dump File reports = TestDirectory.directory("reports"); File[] files = reports.listFiles(); assertThat(files, notNullValue()); assertThat(Files.Length, @is(1)); Path report = files[0].toPath(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.net.URI uri = java.net.URI.create("jar:file:" + report.toUri().getRawPath()); URI uri = URI.create("jar:file:" + report.toUri().RawPath); using (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { string threadDump = new string( Files.readAllBytes(fs.getPath("threaddump.txt"))); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: assertThat(threadDump, containsString(typeof(DiagnosticsReportCommandIT).FullName)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void listShouldDisplayAllClassifiers() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void ListShouldDisplayAllClassifiers() { using (MemoryStream baos = new MemoryStream()) { PrintStream ps = new PrintStream(baos); string[] args = new string[] { "--list" }; OutsideWorld outsideWorld = mock(typeof(OutsideWorld)); when(outsideWorld.FileSystem()).thenReturn(_fs); when(outsideWorld.OutStream()).thenReturn(ps); DiagnosticsReportCommand diagnosticsReportCommand = new DiagnosticsReportCommand(_homeDir, _configDir, outsideWorld); diagnosticsReportCommand.Execute(args); assertThat(baos.ToString(), @is(string.Format("Finding running instance of neo4j%n" + "No running instance of neo4j was found. Online reports will be omitted.%n" + "If neo4j is running but not detected, you can supply the process id of the running instance with --pid%n" + "All available classifiers:%n" + " config include configuration file%n" + " logs include log files%n" + " plugins include a view of the plugin directory%n" + " ps include a list of running processes%n" + " tree include a view of the tree structure of the data directory%n" + " tx include transaction logs%n"))); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void overrideDestination() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void OverrideDestination() { // because of https://bugs.openjdk.java.net/browse/JDK-8202127 and current surefire behaviour we need to have custom value for JRE >= 11 string toArgument = JRE.JAVA_11.CurrentVersion ? "--to=" + System.getProperty("user.dir") + "/other/" : "--to=other/"; string[] args = new string[] { toArgument, "all" }; using (RealOutsideWorld outsideWorld = new RealOutsideWorld()) { DiagnosticsReportCommand diagnosticsReportCommand = new DiagnosticsReportCommand(_homeDir, _configDir, outsideWorld); diagnosticsReportCommand.Execute(args); File other = _testDirectory.directory("other"); FileSystemAbstraction fs = outsideWorld.FileSystem(); assertThat(fs.FileExists(other), @is(true)); assertThat(fs.ListFiles(other).Length, @is(1)); // Default should be empty File reports = new File(_testDirectory.directory(), "reports"); assertThat(fs.FileExists(reports), @is(false)); } }