Java Code Examples for jdk.testlibrary.OutputAnalyzer#getStdout()
The following examples show how to use
jdk.testlibrary.OutputAnalyzer#getStdout() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestJcmdStartStopDefault.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static String parseRecordingName(OutputAnalyzer output) { // Expected output: // Started recording recording-1. No limit (duration/maxsize/maxage) in use. // Use JFR.dump name=recording-1 filename=FILEPATH to copy recording data to file. String stdout = output.getStdout(); Pattern p = Pattern.compile(".*Use JFR.dump name=(\\S+).*", Pattern.DOTALL); Matcher m = p.matcher(stdout); Asserts.assertTrue(m.matches(), "Could not parse recording name"); String name = m.group(1); System.out.println("Recording name=" + name); return name; }
Example 2
Source File: TestPrintXML.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String... args) throws Exception { Path recordingFile = ExecuteHelper.createProfilingRecording().toAbsolutePath(); OutputAnalyzer output = ExecuteHelper.run("print", "--xml", recordingFile.toString()); String xml = output.getStdout(); System.out.println(xml); // Parse XML string SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser sp = factory.newSAXParser(); XMLReader xr = sp.getXMLReader(); RecordingHandler handler = new RecordingHandler(); xr.setContentHandler(handler); xr.parse(new InputSource(new StringReader(xml))); // Verify that all data was written correctly Iterator<RecordedEvent> it = RecordingFile.readAllEvents(recordingFile).iterator(); for (XMLEvent xmlEvent : handler.events) { RecordedEvent re = it.next(); if (!compare(re, xmlEvent.values)) { System.out.println(re); System.out.println(xmlEvent.values.toString()); throw new Exception("Event doesn't match"); } } }
Example 3
Source File: TestPrintJSON.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String... args) throws Exception { Path recordingFile = ExecuteHelper.createProfilingRecording().toAbsolutePath(); OutputAnalyzer output = ExecuteHelper.run("print", "--json", recordingFile.toString()); String json = output.getStdout(); // Parse JSON using Nashorn String statement = "var jsonObject = " + json; ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("nashorn"); engine.eval(statement); JSObject o = (JSObject) engine.get("jsonObject"); JSObject recording = (JSObject) o.getMember("recording"); JSObject events = (JSObject) recording.getMember("events"); // Verify events are equal try (RecordingFile rf = new RecordingFile(recordingFile)) { for (Object jsonEvent : events.values()) { RecordedEvent recordedEvent = rf.readEvent(); double typeId = recordedEvent.getEventType().getId(); String startTime = recordedEvent.getStartTime().toString(); String duration = recordedEvent.getDuration().toString(); Asserts.assertEquals(typeId, ((Number) ((JSObject) jsonEvent).getMember("typeId")).doubleValue()); Asserts.assertEquals(startTime, ((JSObject) jsonEvent).getMember("startTime")); Asserts.assertEquals(duration, ((JSObject) jsonEvent).getMember("duration")); assertEquals(jsonEvent, recordedEvent); } Asserts.assertFalse(rf.hasMoreEvents(), "Incorrect number of events"); } }
Example 4
Source File: NativeErrors.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 5
Source File: NativeErrors.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 6
Source File: NativeErrors.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 7
Source File: NativeErrors.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 8
Source File: NativeErrors.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 9
Source File: NativeErrors.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 10
Source File: NativeErrors.java From hottub with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 11
Source File: NativeErrors.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 12
Source File: NativeErrors.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }
Example 13
Source File: NativeErrors.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static String executeCmd(String... toolArgs) throws Throwable { JDKToolLauncher cmd = JDKToolLauncher.createUsingTestJDK("native2ascii"); for (String s : toolArgs) { cmd.addToolArg(s); } OutputAnalyzer output = ProcessTools.executeProcess(cmd.getCommand()); if (output == null || output.getStdout() == null) { throw new Exception("Output was null. Process did not finish correctly."); } if (output.getExitValue() == 0) { throw new Exception("Process exit code was 0, but error was expected."); } return output.getStdout(); }