Search in sources :

Example 6 with OutputAnalyzer

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");
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer) Registry(java.rmi.registry.Registry) LocateRegistry(java.rmi.registry.LocateRegistry) ProcessThread(jdk.testlibrary.ProcessThread)

Example 7 with OutputAnalyzer

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;
}
Also used : JDKToolLauncher(jdk.testlibrary.JDKToolLauncher) OutputAnalyzer(jdk.testlibrary.OutputAnalyzer)

Example 8 with OutputAnalyzer

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);
}
Also used : ArrayList(java.util.ArrayList) OutputAnalyzer(jdk.testlibrary.OutputAnalyzer)

Example 9 with OutputAnalyzer

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>'.");
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer)

Example 10 with OutputAnalyzer

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);
}
Also used : OutputAnalyzer(jdk.testlibrary.OutputAnalyzer)

Aggregations

OutputAnalyzer (jdk.testlibrary.OutputAnalyzer)54 File (java.io.File)5 JDKToolLauncher (jdk.testlibrary.JDKToolLauncher)5 ArrayList (java.util.ArrayList)4 PortUnreachableException (java.net.PortUnreachableException)1 LocateRegistry (java.rmi.registry.LocateRegistry)1 Registry (java.rmi.registry.Registry)1 KeyStore (java.security.KeyStore)1 X509Certificate (java.security.cert.X509Certificate)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 MissingResourceException (java.util.MissingResourceException)1 ProcessThread (jdk.testlibrary.ProcessThread)1