< prev index next >

test/jdk/sun/tools/jps/JpsHelper.java

Print this page
rev 51638 : [mq]: 8210112
rev 51639 : [mq]: 8210112-1


 167             }
 168         }
 169 
 170         ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
 171         System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
 172         OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
 173         System.out.println(output.getOutput());
 174 
 175         return output;
 176     }
 177 
 178     /**
 179      * Verify jps stdout contains only pids and programs' name information.
 180      * jps stderr may contain VM warning messages which will be ignored.
 181      *
 182      * The output can look like:
 183      * 35536 Jps
 184      * 35417 Main
 185      * 31103 org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
 186      */
 187     public static void verifyJpsOutput(OutputAnalyzer output, String regex) throws Exception {
 188         output.shouldHaveExitValue(0);
 189         int matchedCount = output.stdoutShouldMatchByLine(regex);
 190         assertGreaterThan(matchedCount , 0, "Found no lines matching pattern: " + regex);
 191         output.stderrShouldNotMatch("[E|e]xception");
 192         output.stderrShouldNotMatch("[E|e]rror");
 193     }
 194 
 195     /**
 196      * Compare jps output with a content in a file line by line
 197      */
 198     public static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
 199         String testSrc = System.getProperty("test.src", "?");
 200         Path path = Paths.get(testSrc, "usage.out");
 201         List<String> fileOutput = Files.readAllLines(path);
 202         List<String> outputAsLines = output.asLines();
 203         assertTrue(outputAsLines.containsAll(fileOutput),
 204                 "The ouput should contain all content of " + path.toAbsolutePath());
 205     }
 206 
 207     public static void runJpsVariants(Long pid, String processName, String fullProcessName, String argument) throws Exception {
 208         System.out.printf("INFO: user.dir:  '%s''\n", System.getProperty("user.dir"));
 209         List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
 210         for (List<JpsHelper.JpsArg> combination : combinations) {




 167             }
 168         }
 169 
 170         ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
 171         System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
 172         OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
 173         System.out.println(output.getOutput());
 174 
 175         return output;
 176     }
 177 
 178     /**
 179      * Verify jps stdout contains only pids and programs' name information.
 180      * jps stderr may contain VM warning messages which will be ignored.
 181      *
 182      * The output can look like:
 183      * 35536 Jps
 184      * 35417 Main
 185      * 31103 org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
 186      */
 187     public static void verifyJpsOutput(OutputAnalyzer output, String regex) {
 188         output.shouldHaveExitValue(0);
 189         output.stdoutShouldMatchByLine(regex);

 190         output.stderrShouldNotMatch("[E|e]xception");
 191         output.stderrShouldNotMatch("[E|e]rror");
 192     }
 193 
 194     /**
 195      * Compare jps output with a content in a file line by line
 196      */
 197     public static void verifyOutputAgainstFile(OutputAnalyzer output) throws IOException {
 198         String testSrc = System.getProperty("test.src", "?");
 199         Path path = Paths.get(testSrc, "usage.out");
 200         List<String> fileOutput = Files.readAllLines(path);
 201         List<String> outputAsLines = output.asLines();
 202         assertTrue(outputAsLines.containsAll(fileOutput),
 203                 "The ouput should contain all content of " + path.toAbsolutePath());
 204     }
 205 
 206     public static void runJpsVariants(Long pid, String processName, String fullProcessName, String argument) throws Exception {
 207         System.out.printf("INFO: user.dir:  '%s''\n", System.getProperty("user.dir"));
 208         List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
 209         for (List<JpsHelper.JpsArg> combination : combinations) {


< prev index next >