Java Code Examples for jdk.testlibrary.OutputAnalyzer#stdoutShouldContain()

The following examples show how to use jdk.testlibrary.OutputAnalyzer#stdoutShouldContain() . 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: PremainClassTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 2
Source File: PremainClassTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 3
Source File: PremainClassTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 4
Source File: PremainClassTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 5
Source File: PremainClassTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 6
Source File: PremainClassTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = ProcessTools.executeProcess(pb);
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 7
Source File: PremainClassTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 8
Source File: PremainClassTest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 9
Source File: PremainClassTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 10
Source File: PremainClassTest.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 11
Source File: PremainClassTest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 12
Source File: PremainClassTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 13
Source File: PremainClassTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] a) throws Exception {
    String testArgs = String.format(
            "-javaagent:%s/Agent.jar -classpath %s DummyMain",
            System.getProperty("test.src"),
            System.getProperty("test.classes", "."));

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
            Utils.addTestJavaOpts(testArgs.split("\\s+")));
    System.out.println("testjvm.cmd:" + Utils.getCommandLine(pb));

    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    System.out.println("testjvm.stdout:" + output.getStdout());
    System.out.println("testjvm.stderr:" + output.getStderr());

    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("premain running");
    output.stdoutShouldContain("Hello from DummyMain!");
}
 
Example 14
Source File: TestModularizedEvent.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String... args) throws Exception {
    compileModule(ANNO_MODULE);
    compileModule(SETTING_MODULE);
    compileModule(EVENT_MODULE, "--module-path", MODS_DIR.toString());
    compileModule(TEST_MODULE, "--module-path", MODS_DIR.toString());

    OutputAnalyzer oa = ProcessTools.executeTestJava("--module-path", "mods", "-m", "test.jfr.main/test.jfr.main.MainTest");
    oa.stdoutShouldContain("Test passed.");
}
 
Example 15
Source File: ProgramTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String... args) throws Exception {
    String lib = System.getProperty("test.nativepath");
    ProcessBuilder pb = new ProcessBuilder(lib + "/sanity_SimpleNativeLauncher");
    OutputAnalyzer output = ProcessTools.executeProcess(pb);
    output.shouldHaveExitValue(0);
    output.stdoutShouldContain("Hello");
}