Java Code Examples for jdk.test.lib.process.OutputAnalyzer#shouldContain()
The following examples show how to use
jdk.test.lib.process.OutputAnalyzer#shouldContain() .
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: TestHeapDumpForInvokeDynamic.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void attachDumpAndVerify(String heapDumpFileName, long lingeredAppPid) throws Exception { JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); launcher.addToolArg("jmap"); launcher.addToolArg("--binaryheap"); launcher.addToolArg("--dumpfile"); launcher.addToolArg(heapDumpFileName); launcher.addToolArg("--pid"); launcher.addToolArg(Long.toString(lingeredAppPid)); ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.command(launcher.getCommand()); System.out.println( processBuilder.command().stream().collect(Collectors.joining(" "))); OutputAnalyzer SAOutput = ProcessTools.executeProcess(processBuilder); SAOutput.shouldHaveExitValue(0); SAOutput.shouldContain("heap written to"); SAOutput.shouldContain(heapDumpFileName); System.out.println(SAOutput.getOutput()); verifyHeapDump(heapDumpFileName); }
Example 2
Source File: AdaptiveGCBoundary.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-showversion", "-XX:+UseParallelGC", "-XX:+UseAdaptiveGCBoundary", "-XX:+PrintCommandLineFlags", SystemGCCaller.class.getName() ); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("+UseAdaptiveGCBoundary"); output.shouldNotContain("error"); output.shouldHaveExitValue(0); }
Example 3
Source File: TestG1ConcMarkStepDurationMillis.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void runG1ConcMarkStepDurationMillisTest(String expectedValue, int expectedResult) throws Exception { List<String> vmOpts = new ArrayList<>(); Collections.addAll(vmOpts, "-XX:+UseG1GC", "-XX:G1ConcMarkStepDurationMillis="+expectedValue, "-XX:+PrintFlagsFinal", "-version"); ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()])); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(expectedResult == PASS ? 0 : 1); String stdout = output.getStdout(); if (expectedResult == PASS) { checkG1ConcMarkStepDurationMillisConsistency(stdout, expectedValue); } else if (expectedResult == FAIL_IMPROPER_VALUE) { output.shouldContain("Improperly specified VM option"); } else if (expectedResult == FAIL_OUT_RANGE) { output.shouldContain("outside the allowed range"); } }
Example 4
Source File: ObsoleteFlagErrorMessage.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // Case 1: Newly obsolete flags with extra junk appended should not be treated as newly obsolete (8060449) ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:UseOldInliningPlusJunk", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Unrecognized VM option 'UseOldInliningPlusJunk'"); // Must identify bad option. output.shouldHaveExitValue(1); // Case 2: Newly obsolete integer-valued flags should be recognized as newly obsolete (8073989) ProcessBuilder pb2 = ProcessTools.createJavaProcessBuilder( "-XX:NmethodSweepFraction=10", "-version"); OutputAnalyzer output2 = new OutputAnalyzer(pb2.start()); output2.shouldContain("Ignoring option").shouldContain("support was removed"); output2.shouldContain("NmethodSweepFraction"); }
Example 5
Source File: ReserveMemory.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().readReservedMemory(); throw new Exception("Read of reserved/uncommitted memory unexpectedly succeeded, expected crash!"); } ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-Xmx32m", "ReserveMemory", "test"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); if (Platform.isWindows()) { output.shouldContain("EXCEPTION_ACCESS_VIOLATION"); } else if (Platform.isOSX()) { output.shouldContain("SIGBUS"); } else { output.shouldContain("SIGSEGV"); } }
Example 6
Source File: BootAppendTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void testBootAppendDuplicateModuleClass() throws Exception { for (String mode : modes) { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./BootAppendTests.jsa", "-XX:+TraceClassLoading", "-cp", appJar, "-Xbootclasspath/a:" + bootAppendJar, "-Xshare:" + mode, APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("[class,load] org.omg.CORBA.Context source: jrt:/java.corba"); } }
Example 7
Source File: CDSTestUtils.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static OutputAnalyzer checkMatches(OutputAnalyzer output, String... matches) throws Exception { for (String match : matches) { output.shouldContain(match); } return output; }
Example 8
Source File: DirectiveParserTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void nonMatchingBrackets() { String fileName = "non-matching.json"; try (JSONFile file = new JSONFile(fileName)) { file.write(JSONFile.Element.ARRAY) .write(JSONFile.Element.OBJECT) .write(JSONFile.Element.PAIR, "match") .write(JSONFile.Element.VALUE, "\"java/lang/String.*\"") .end(); // don't write matching } } OutputAnalyzer output = HugeDirectiveUtil.execute(fileName); Asserts.assertNE(output.getExitValue(), 0, ERROR_MSG + "non matching " + "brackets"); output.shouldContain(EXPECTED_ERROR_STRING); }
Example 9
Source File: TestDeprecatedPrintFlags.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void testXloggcWithPrintGCDetails() throws Exception { String fileName = "gc-test.log"; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintGCDetails", "-Xloggc:" + fileName, "DoGC"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("-XX:+PrintGCDetails is deprecated. Will use -Xlog:gc* instead."); output.shouldContain("-Xloggc is deprecated. Will use -Xlog:gc:gc-test.log instead."); output.shouldNotContain("PrintGC is deprecated"); output.stdoutShouldNotMatch("\\[info.*\\]\\[gc *\\]"); output.stdoutShouldNotMatch("\\[info.*\\]\\[gc\\,"); output.shouldHaveExitValue(0); String lines = Files.lines(Paths.get(fileName)).collect(Collectors.joining()); OutputAnalyzer outputLog = new OutputAnalyzer(lines, ""); outputLog.stdoutShouldMatch("\\[info.*\\]\\[gc *\\]"); outputLog.stdoutShouldMatch("\\[info.*\\]\\[gc\\,"); }
Example 10
Source File: TestHumongousAllocInitialMark.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UseG1GC", "-Xms" + heapSize + "m", "-Xmx" + heapSize + "m", "-XX:G1HeapRegionSize=" + heapRegionSize + "m", "-XX:InitiatingHeapOccupancyPercent=" + initiatingHeapOccupancyPercent, "-Xlog:gc", HumongousObjectAllocator.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Pause Initial Mark (G1 Humongous Allocation)"); output.shouldNotContain("Full GC"); output.shouldHaveExitValue(0); }
Example 11
Source File: TestStringDeduplicationTools.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void testTableResize() throws Exception { // Test with StringDeduplicationResizeALot OutputAnalyzer output = DeduplicationTest.run(LargeNumberOfStrings, DefaultAgeThreshold, YoungGC, "-Xlog:gc,gc+stringdedup=trace", "-XX:+StringDeduplicationResizeALot"); output.shouldContain("Concurrent String Deduplication"); output.shouldContain("Deduplicated:"); output.shouldNotContain("Resize Count: 0"); output.shouldHaveExitValue(0); }
Example 12
Source File: CtwTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected void check() throws Exception { try (BufferedReader r = Files.newBufferedReader(Paths.get(LOG_FILE), Charset.defaultCharset())) { OutputAnalyzer output = readOutput(r); for (String test : shouldContain) { output.shouldContain(test); } } }
Example 13
Source File: TestCompressedClassFlags.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { if (Platform.is64bit()) { OutputAnalyzer output = runJava("-XX:CompressedClassSpaceSize=1g", "-XX:-UseCompressedClassPointers", "-version"); output.shouldContain("warning"); output.shouldNotContain("error"); output.shouldHaveExitValue(0); } }
Example 14
Source File: TestMaxHeapSizeTools.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void shouldContainOrNot(OutputAnalyzer output, boolean contains, String message) throws Exception { if (contains) { output.shouldContain(message); } else { output.shouldNotContain(message); } }
Example 15
Source File: ClassFileParserBug.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Throwable { System.out.println("Regression test for bug 8040018"); String testsrc = System.getProperty("test.src") + "/"; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-jar", testsrc + File.separator + "test.jar"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.ClassFormatError: Bad length on BootstrapMethods"); output.shouldHaveExitValue(1); }
Example 16
Source File: TestHumongousAllocNearlyFullRegion.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UseG1GC", "-Xms" + heapSize + "m", "-Xmx" + heapSize + "m", "-XX:G1HeapRegionSize=" + heapRegionSize + "m", "-Xlog:gc", HumongousObjectAllocator.class.getName()); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Pause Initial Mark (G1 Humongous Allocation)"); output.shouldHaveExitValue(0); }
Example 17
Source File: TestMultipleStartupRecordings.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static void test(ProcessBuilder pb, String... expectedOutputs) throws Exception { OutputAnalyzer output = new OutputAnalyzer(pb.start()); for (String s : expectedOutputs) { output.shouldContain(s); } }
Example 18
Source File: TestJcmdDumpLimited.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static void testDumpInvalidTime() throws Exception { Path invalidTime = Paths.get("invalidTime.jfr"); OutputAnalyzer output = JcmdHelper.jcmd("JFR.dump", "filename=" + invalidTime.toFile().getAbsolutePath(), "begin=4711"); output.shouldContain("Dump failed, not a valid begin time."); assertMissingFile(invalidTime); }
Example 19
Source File: StackWalkTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
static void analyzeOutputOn(ProcessBuilder pb) throws Exception { OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("Start walking"); output.shouldContain("fill_in_frames"); output.shouldHaveExitValue(0); }
Example 20
Source File: JcmdAsserts.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void assertCouldNotStartDefaultRecording(OutputAnalyzer output) { output.shouldContain( "The only option that can be combined with defaultrecording is settings"); }