2626import java .io .File ;
2727import java .nio .file .Path ;
2828import java .nio .file .Paths ;
29- import java .util .Iterator ;
3029
3130import jdk .jfr .Configuration ;
3231import jdk .jfr .Recording ;
@@ -60,26 +59,26 @@ public static void main(String[] args) throws Exception {
6059
6160 private static void testDumpFilename () throws Exception {
6261 OutputAnalyzer output = JcmdHelper .jcmd ("JFR.dump" );
63- verifyFile (readFilename (output ), null );
62+ verifyFile (JcmdHelper . readFilename (output ), null );
6463 }
6564
6665 private static void testDumpFilename (Recording r ) throws Exception {
6766 OutputAnalyzer output = JcmdHelper .jcmd ("JFR.dump" , "name=" + r .getId ());
68- verifyFile (readFilename (output ), r .getId ());
67+ verifyFile (JcmdHelper . readFilename (output ), r .getId ());
6968 }
7069
7170 private static void testDumpDiectory () throws Exception {
7271 Path directory = Paths .get ("." ).toAbsolutePath ().normalize ();
7372 OutputAnalyzer output = JcmdHelper .jcmd ("JFR.dump" , "filename=" + directory );
74- String filename = readFilename (output );
73+ String filename = JcmdHelper . readFilename (output );
7574 verifyFile (filename , null );
7675 verifyDirectory (filename , directory );
7776 }
7877
7978 private static void testDumpDiectory (Recording r ) throws Exception {
8079 Path directory = Paths .get ("." ).toAbsolutePath ().normalize ();
8180 OutputAnalyzer output = JcmdHelper .jcmd ("JFR.dump" , "name=" + r .getId (), "filename=" + directory );
82- String filename = readFilename (output );
81+ String filename = JcmdHelper . readFilename (output );
8382 verifyFile (filename , r .getId ());
8483 verifyDirectory (filename , directory );
8584 }
@@ -98,16 +97,4 @@ private static void verifyFile(String filename, Long id) throws Exception {
9897 }
9998 FileHelper .verifyRecording (new File (filename ));
10099 }
101-
102- private static String readFilename (OutputAnalyzer output ) throws Exception {
103- Iterator <String > it = output .asLines ().iterator ();
104- while (it .hasNext ()) {
105- String line = it .next ();
106- if (line .contains ("written to" )) {
107- line = it .next (); // blank line
108- return it .next ();
109- }
110- }
111- throw new Exception ("Could not find filename of dumped recording." );
112- }
113100}
0 commit comments