use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class JstatdTest method doTest.
public void doTest() throws Throwable {
ProcessThread jstatdThread = null;
try {
while (jstatdThread == null) {
if (!useDefaultPort || withExternalRegistry) {
port = Integer.toString(Utils.getFreePort());
}
if (withExternalRegistry) {
Registry registry = startRegistry();
if (registry == null) {
// The port is already in use. Cancel and try with new one.
continue;
}
}
jstatdThread = tryToSetupJstatdProcess();
}
runToolsAndVerify();
} finally {
cleanUpThread(jstatdThread);
}
// Verify output from jstatd
OutputAnalyzer output = jstatdThread.getOutput();
assertTrue(output.getOutput().isEmpty(), "jstatd should get an empty output, got: " + Utils.NEW_LINE + output.getOutput());
assertNotEquals(output.getExitValue(), 0, "jstatd process exited with unexpected exit code");
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class JstatdTest method runJstat.
/**
* Depending on test settings command line can look like:
*
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname:port 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname/serverName 250 5
* jstat -J-XX:+UsePerfData -J-Duser.language=en -gcutil pid@hostname:port/serverName 250 5
*/
private OutputAnalyzer runJstat() throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstat");
launcher.addVMArg("-XX:+UsePerfData");
launcher.addVMArg("-Duser.language=en");
launcher.addToolArg("-gcutil");
launcher.addToolArg(jstatdPid + "@" + getDestination());
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_INTERVAL_MS));
launcher.addToolArg(Integer.toString(JSTAT_GCUTIL_SAMPLES));
String[] cmd = launcher.getCommand();
log("Start jstat", cmd);
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
System.out.println(output.getOutput());
return output;
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class TestJpsClass method main.
public static void main(String[] args) throws Throwable {
String testJdk = System.getProperty("test.jdk", "?");
String testSrc = System.getProperty("test.src", "?");
String testClassPath = System.getProperty("test.class.path", "?");
List<String> cmd = new ArrayList<>();
cmd.addAll(JpsHelper.getVmArgs());
cmd.add("-Dtest.jdk=" + testJdk);
cmd.add("-Dtest.src=" + testSrc);
cmd.add("-cp");
cmd.add(testClassPath);
cmd.add("JpsBase");
cmd.add("monkey");
ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(cmd.toArray(new String[cmd.size()]));
OutputAnalyzer output = new OutputAnalyzer(processBuilder.start());
System.out.println(output.getOutput());
output.shouldHaveExitValue(0);
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class TestJcmdSanity method testJcmdPidHelp.
/**
* jcmd -J-XX:+UsePerfData pid help
*/
private static void testJcmdPidHelp() throws Exception {
OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS, new String[] { "help" });
output.shouldHaveExitValue(0);
output.shouldNotContain("Exception");
output.shouldContain(Integer.toString(ProcessTools.getProcessId()) + ":");
matchJcmdCommands(output);
output.shouldContain("For more information about a specific command use 'help <command>'.");
}
use of jdk.testlibrary.OutputAnalyzer in project jdk8u_jdk by JetBrains.
the class TestJpsSanity method testJpsUnknownHost.
private static void testJpsUnknownHost() throws Exception {
String invalidHostName = "Oja781nh2ev7vcvbajdg-Sda1-C";
OutputAnalyzer output = JpsHelper.jps(invalidHostName);
Asserts.assertNotEquals(output.getExitValue(), 0, "Exit code shouldn't be 0");
Asserts.assertFalse(output.getStderr().isEmpty(), "Error output should not be empty");
output.shouldContain("Unknown host: " + invalidHostName);
}
Aggregations