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

The following examples show how to use jdk.testlibrary.OutputAnalyzer#shouldNotContain() . 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: DynamicLauncher.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected void run() throws Exception {
    OutputAnalyzer out;
    int retries = 1;
    boolean tryAgain;

    do {
        tryAgain = false;
        jmxPort = Utils.getFreePort();
        out = runVM();
        try {
            out.shouldNotContain("Port already in use");
        } catch (RuntimeException e) {
            if (retries < 3) {
                retries++;
                tryAgain = true;
            }
        }
    } while (tryAgain);
}
 
Example 2
Source File: WeakAlg.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
static void checkGenCRL(String alias, String options, String bad) {

        OutputAnalyzer oa = kt("-gencrl -alias " + alias
                + " -id 1 -file " + alias + ".crl " + options);
        if (bad == null) {
            oa.shouldNotContain("Warning");
        } else {
            oa.shouldContain("Warning")
                    .shouldMatch("The generated CRL.*" + bad + ".*risk");
        }

        oa = kt("-printcrl -file " + alias + ".crl");
        if (bad == null) {
            oa.shouldNotContain("Warning")
                    .shouldContain("Verified by " + alias + " in keystore")
                    .shouldNotContain("(weak");
        } else {
            oa.shouldContain("Warning:")
                    .shouldMatch("The CRL.*" + bad + ".*risk")
                    .shouldContain("Verified by " + alias + " in keystore")
                    .shouldContain(bad + " (weak)");
        }
    }
 
Example 3
Source File: DynamicLauncher.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
protected void run() throws Exception {
    OutputAnalyzer out;
    int retries = 1;
    boolean tryAgain;

    do {
        tryAgain = false;
        jmxPort = Utils.getFreePort();
        out = runVM();
        try {
            out.shouldNotContain("Port already in use");
        } catch (RuntimeException e) {
            if (retries < 3) {
                retries++;
                tryAgain = true;
            }
        }
    } while (tryAgain);
}
 
Example 4
Source File: Test.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void checkVerifying(OutputAnalyzer analyzer, int expectedExitCode,
        String... warnings) {
    analyzer.shouldHaveExitValue(expectedExitCode);
    int count = 0;
    for (String warning : warnings) {
        if (warning.startsWith("!")) {
            analyzer.shouldNotContain(warning.substring(1));
        } else {
            count++;
            analyzer.shouldContain(warning);
        }
    }
    if (count > 0) {
        analyzer.shouldMatch(WARNING_OR_ERROR);
    }
    if (expectedExitCode == 0) {
        analyzer.shouldContain(JAR_VERIFIED);
    } else {
        analyzer.shouldContain(JAR_VERIFIED_WITH_SIGNER_ERRORS);
    }
}
 
Example 5
Source File: WeakAlg.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void checkGenCRL(String alias, String options, String bad) {

        OutputAnalyzer oa = kt("-gencrl -alias " + alias
                + " -id 1 -file " + alias + ".crl " + options);
        if (bad == null) {
            oa.shouldNotContain("Warning");
        } else {
            oa.shouldContain("Warning")
                    .shouldMatch("The generated CRL.*" + bad + ".*risk");
        }

        oa = kt("-printcrl -file " + alias + ".crl");
        if (bad == null) {
            oa.shouldNotContain("Warning")
                    .shouldContain("Verified by " + alias + " in keystore")
                    .shouldNotContain("(weak");
        } else {
            oa.shouldContain("Warning:")
                    .shouldMatch("The CRL.*" + bad + ".*risk")
                    .shouldContain("Verified by " + alias + " in keystore")
                    .shouldContain(bad + " (weak)");
        }
    }
 
Example 6
Source File: WeakAlg.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void checkCertReq(
        String alias, String options, String bad) {

    OutputAnalyzer oa = certreq(alias, options);
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning")
                .shouldMatch("The generated certificate request.*" + bad + ".*risk");
    }

    oa = kt("-printcertreq -file " + alias + ".req");
    if (bad == null) {
        oa.shouldNotContain("Warning")
                .shouldNotContain("(weak)");
    } else {
        oa.shouldContain("Warning")
                .shouldMatch("The certificate request.*" + bad + ".*risk")
                .shouldContain(bad + " (weak)");
    }
}
 
Example 7
Source File: TestDaemonThreadLauncher.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 {
    for(int i=0; i<50; i++) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
        OutputAnalyzer analyzer = ProcessTools.executeProcess(pb);
        analyzer.shouldNotContain("ASSERTION FAILED");
        analyzer.shouldHaveExitValue(0);
    }
}
 
Example 8
Source File: TestJcmdSanity.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests that it possible send a file over 1024 bytes large via jcmd -f.
 *
 * jcmd -J-XX:+UsePerfData pid -f dcmd-big-script.txt
 */
private static void testJcmdPidBigScript() throws Exception {
    File scrpitFile = new File(TEST_SRC, "dcmd-big-script.txt");
    OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS,
            new String[] {"-f", scrpitFile.getAbsolutePath()});

    output.shouldHaveExitValue(0);
    output.shouldNotContain("Exception");
    output.shouldContain(System.getProperty("java.vm.name").trim());
}
 
Example 9
Source File: TestDaemonThreadLauncher.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    for(int i=0; i<50; i++) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
        OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
        analyzer.shouldNotContain("ASSERTION FAILED");
    }
}
 
Example 10
Source File: TestJcmdSanity.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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>'.");
}
 
Example 11
Source File: TestJcmdSanity.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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(Long.toString(ProcessTools.getProcessId()) + ":");
    matchJcmdCommands(output);
    output.shouldContain("For more information about a specific command use 'help <command>'.");
}
 
Example 12
Source File: TestJcmdSanity.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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>'.");
}
 
Example 13
Source File: TestJcmdSanity.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests that it possible send a file over 1024 bytes large via jcmd -f.
 *
 * jcmd -J-XX:+UsePerfData pid -f dcmd-big-script.txt
 */
private static void testJcmdPidBigScript() throws Exception {
    File scrpitFile = new File(TEST_SRC, "dcmd-big-script.txt");
    OutputAnalyzer output = JcmdBase.jcmd(VM_ARGS,
            new String[] {"-f", scrpitFile.getAbsolutePath()});

    output.shouldHaveExitValue(0);
    output.shouldNotContain("Exception");
    output.shouldContain(System.getProperty("java.vm.name").trim());
}
 
Example 14
Source File: TestDaemonThreadLauncher.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 {
    for(int i=0; i<50; i++) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
        OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
        analyzer.shouldNotContain("ASSERTION FAILED");
    }
}
 
Example 15
Source File: TestDaemonThreadLauncher.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    for(int i=0; i<50; i++) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
        OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
        analyzer.shouldNotContain("ASSERTION FAILED");
    }
}
 
Example 16
Source File: TestDaemonThreadLauncher.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    for(int i=0; i<50; i++) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
        OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
        analyzer.shouldNotContain("ASSERTION FAILED");
    }
}
 
Example 17
Source File: TestJcmdSanity.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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>'.");
}
 
Example 18
Source File: TestDaemonThreadLauncher.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    for(int i=0; i<50; i++) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
        OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
        analyzer.shouldNotContain("ASSERTION FAILED");
    }
}
 
Example 19
Source File: TestDaemonThreadLauncher.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    for(int i=0; i<50; i++) {
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", ".");
        OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());
        analyzer.shouldNotContain("ASSERTION FAILED");
    }
}
 
Example 20
Source File: WeakAlg.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static void checkGenKeyPair(
        String alias, String options, String bad) {

    OutputAnalyzer oa = genkeypair(alias, options);
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning")
                .shouldMatch("The generated certificate.*" + bad + ".*risk");
    }

    oa = kt("-exportcert -alias " + alias + " -file " + alias + ".cert");
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning")
                .shouldMatch("The certificate.*" + bad + ".*risk");
    }

    oa = kt("-exportcert -rfc -alias " + alias + " -file " + alias + ".cert");
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning")
                .shouldMatch("The certificate.*" + bad + ".*risk");
    }

    oa = kt("-printcert -rfc -file " + alias + ".cert");
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning")
                .shouldMatch("The certificate.*" + bad + ".*risk");
    }

    oa = kt("-list -alias " + alias);
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning")
                .shouldMatch("The certificate.*" + bad + ".*risk");
    }

    // With cert content

    oa = kt("-printcert -file " + alias + ".cert");
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning")
                .shouldContain(bad + " (weak)")
                .shouldMatch("The certificate.*" + bad + ".*risk");
    }

    oa = kt("-list -v -alias " + alias);
    if (bad == null) {
        oa.shouldNotContain("Warning");
    } else {
        oa.shouldContain("Warning")
                .shouldContain(bad + " (weak)")
                .shouldMatch("The certificate.*" + bad + ".*risk");
    }
}