Java Code Examples for com.oracle.java.testlibrary.OutputAnalyzer#firstMatch()
The following examples show how to use
com.oracle.java.testlibrary.OutputAnalyzer#firstMatch() .
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: TestLargePagesFlags.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void expect(Flag... expectedFlags) throws Exception { if (useFlags == null) { throw new IllegalStateException("Must run use() before expect()"); } OutputAnalyzer output = executeNewJVM(useFlags); for (Flag flag : expectedFlags) { System.out.println("Looking for: " + flag.flagString()); String strValue = output.firstMatch(".* " + flag.name() + " .* :?= (\\S+).*", 1); if (strValue == null) { throw new RuntimeException("Flag " + flag.name() + " couldn't be found"); } if (!flag.value().equals(strValue)) { throw new RuntimeException("Wrong value for: " + flag.name() + " expected: " + flag.value() + " got: " + strValue); } } output.shouldHaveExitValue(0); }
Example 2
Source File: TestLargePagesFlags.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void expect(Flag... expectedFlags) throws Exception { if (useFlags == null) { throw new IllegalStateException("Must run use() before expect()"); } OutputAnalyzer output = executeNewJVM(useFlags); for (Flag flag : expectedFlags) { System.out.println("Looking for: " + flag.flagString()); String strValue = output.firstMatch(".* " + flag.name() + " .* :?= (\\S+).*", 1); if (strValue == null) { throw new RuntimeException("Flag " + flag.name() + " couldn't be found"); } if (!flag.value().equals(strValue)) { throw new RuntimeException("Wrong value for: " + flag.name() + " expected: " + flag.value() + " got: " + strValue); } } output.shouldHaveExitValue(0); }
Example 3
Source File: TestLargePagesFlags.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void expect(Flag... expectedFlags) throws Exception { if (useFlags == null) { throw new IllegalStateException("Must run use() before expect()"); } OutputAnalyzer output = executeNewJVM(useFlags); for (Flag flag : expectedFlags) { System.out.println("Looking for: " + flag.flagString()); String strValue = output.firstMatch(".* " + flag.name() + " .* :?= (\\S+).*", 1); if (strValue == null) { throw new RuntimeException("Flag " + flag.name() + " couldn't be found"); } if (!flag.value().equals(strValue)) { throw new RuntimeException("Wrong value for: " + flag.name() + " expected: " + flag.value() + " got: " + strValue); } } output.shouldHaveExitValue(0); }
Example 4
Source File: TestLargePagesFlags.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void expect(Flag... expectedFlags) throws Exception { if (useFlags == null) { throw new IllegalStateException("Must run use() before expect()"); } OutputAnalyzer output = executeNewJVM(useFlags); for (Flag flag : expectedFlags) { System.out.println("Looking for: " + flag.flagString()); String strValue = output.firstMatch(".* " + flag.name() + " .* :?= (\\S+).*", 1); if (strValue == null) { throw new RuntimeException("Flag " + flag.name() + " couldn't be found"); } if (!flag.value().equals(strValue)) { throw new RuntimeException("Wrong value for: " + flag.name() + " expected: " + flag.value() + " got: " + strValue); } } output.shouldHaveExitValue(0); }
Example 5
Source File: TestLargePagesFlags.java From hottub with GNU General Public License v2.0 | 6 votes |
public void expect(Flag... expectedFlags) throws Exception { if (useFlags == null) { throw new IllegalStateException("Must run use() before expect()"); } OutputAnalyzer output = executeNewJVM(useFlags); for (Flag flag : expectedFlags) { System.out.println("Looking for: " + flag.flagString()); String strValue = output.firstMatch(".* " + flag.name() + " .* :?= (\\S+).*", 1); if (strValue == null) { throw new RuntimeException("Flag " + flag.name() + " couldn't be found"); } if (!flag.value().equals(strValue)) { throw new RuntimeException("Wrong value for: " + flag.name() + " expected: " + flag.value() + " got: " + strValue); } } output.shouldHaveExitValue(0); }
Example 6
Source File: TestLargePagesFlags.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void expect(Flag... expectedFlags) throws Exception { if (useFlags == null) { throw new IllegalStateException("Must run use() before expect()"); } OutputAnalyzer output = executeNewJVM(useFlags); for (Flag flag : expectedFlags) { System.out.println("Looking for: " + flag.flagString()); String strValue = output.firstMatch(".* " + flag.name() + " .* :?= (\\S+).*", 1); if (strValue == null) { throw new RuntimeException("Flag " + flag.name() + " couldn't be found"); } if (!flag.value().equals(strValue)) { throw new RuntimeException("Wrong value for: " + flag.name() + " expected: " + flag.value() + " got: " + strValue); } } output.shouldHaveExitValue(0); }
Example 7
Source File: TestLargePagesFlags.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void expect(Flag... expectedFlags) throws Exception { if (useFlags == null) { throw new IllegalStateException("Must run use() before expect()"); } OutputAnalyzer output = executeNewJVM(useFlags); for (Flag flag : expectedFlags) { System.out.println("Looking for: " + flag.flagString()); String strValue = output.firstMatch(".* " + flag.name() + " .* :?= (\\S+).*", 1); if (strValue == null) { throw new RuntimeException("Flag " + flag.name() + " couldn't be found"); } if (!flag.value().equals(strValue)) { throw new RuntimeException("Wrong value for: " + flag.name() + " expected: " + flag.value() + " got: " + strValue); } } output.shouldHaveExitValue(0); }
Example 8
Source File: TestMetaspaceSizeFlags.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception { OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize); output.shouldNotMatch("Error occurred during initialization of VM\n.*"); String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* := (\\d+).*", 1); String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* := (\\d+).*", 1); return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize), Long.parseLong(stringMetaspaceSize)); }
Example 9
Source File: TestMetaspaceSizeFlags.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception { OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize); output.shouldNotMatch("Error occurred during initialization of VM\n.*"); String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* := (\\d+).*", 1); String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* := (\\d+).*", 1); return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize), Long.parseLong(stringMetaspaceSize)); }
Example 10
Source File: TestMetaspaceSizeFlags.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception { OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize); output.shouldNotMatch("Error occurred during initialization of VM\n.*"); String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* := (\\d+).*", 1); String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* := (\\d+).*", 1); return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize), Long.parseLong(stringMetaspaceSize)); }
Example 11
Source File: TestMetaspaceSizeFlags.java From hottub with GNU General Public License v2.0 | 5 votes |
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception { OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize); output.shouldNotMatch("Error occurred during initialization of VM\n.*"); String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* := (\\d+).*", 1); String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* := (\\d+).*", 1); return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize), Long.parseLong(stringMetaspaceSize)); }
Example 12
Source File: TestAggressiveHeap.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void testFlag() throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( option, "-XX:+PrintFlagsFinal", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); String value = output.firstMatch(parallelGCPattern); if (value == null) { throw new RuntimeException( option + " didn't set UseParallelGC"); } }
Example 13
Source File: TestMetaspaceSizeFlags.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception { OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize); output.shouldNotMatch("Error occurred during initialization of VM\n.*"); String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* := (\\d+).*", 1); String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* := (\\d+).*", 1); return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize), Long.parseLong(stringMetaspaceSize)); }
Example 14
Source File: TestAggressiveHeap.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void testFlag() throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( option, "-XX:+PrintFlagsFinal", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); String value = output.firstMatch(parallelGCPattern); if (value == null) { throw new RuntimeException( option + " didn't set UseParallelGC"); } }
Example 15
Source File: TestMetaspaceSizeFlags.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception { OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize); output.shouldNotMatch("Error occurred during initialization of VM\n.*"); String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* := (\\d+).*", 1); String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* := (\\d+).*", 1); return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize), Long.parseLong(stringMetaspaceSize)); }
Example 16
Source File: TestAggressiveHeap.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static void testFlag() throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( option, "-XX:+PrintFlagsFinal", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); String value = output.firstMatch(parallelGCPattern); if (value == null) { throw new RuntimeException( option + " didn't set UseParallelGC"); } }
Example 17
Source File: TestCrashOnOutOfMemoryError.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { if (args.length == 1) { // This should guarantee to throw: // java.lang.OutOfMemoryError: Requested array size exceeds VM limit try { Object[] oa = new Object[Integer.MAX_VALUE]; throw new Error("OOME not triggered"); } catch (OutOfMemoryError err) { throw new Error("OOME didn't abort JVM!"); } } // else this is the main test ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError", "-Xmx64m", TestCrashOnOutOfMemoryError.class.getName(),"throwOOME"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); int exitValue = output.getExitValue(); if (0 == exitValue) { //expecting a non zero value throw new Error("Expected to get non zero exit value"); } /* Output should look something like this. The actual text will depend on the OS and its core dump processing. Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit # To suppress the following error report, specify this argument # after -XX: or in .hotspotrc: SuppressErrorAt=/debug.cpp:303 # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/home/cheleswer/Desktop/jdk9/dev/hotspot/src/share/vm/utilities/debug.cpp:303), pid=6212, tid=6213 # fatal error: OutOfMemory encountered: Requested array size exceeds VM limit # # JRE version: OpenJDK Runtime Environment (9.0) (build 1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00) # Java VM: OpenJDK 64-Bit Server VM (1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00, mixed mode, tiered, compressed oops, serial gc, linux-amd64) # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/cheleswer/Desktop/core.6212) # # An error report file with more information is saved as: # /home/cheleswer/Desktop/hs_err_pid6212.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # Current thread is 6213 Dumping core ... Aborted (core dumped) */ output.shouldContain("Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit"); // extract hs-err file String hs_err_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1); if (hs_err_file == null) { throw new Error("Did not find hs-err file in output.\n"); } /* * Check if hs_err files exist or not */ File f = new File(hs_err_file); if (!f.exists()) { throw new Error("hs-err file missing at "+ f.getAbsolutePath() + ".\n"); } System.out.println("PASSED"); }
Example 18
Source File: TestCrashOnOutOfMemoryError.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { if (args.length == 1) { // This should guarantee to throw: // java.lang.OutOfMemoryError: Requested array size exceeds VM limit try { Object[] oa = new Object[Integer.MAX_VALUE]; throw new Error("OOME not triggered"); } catch (OutOfMemoryError err) { throw new Error("OOME didn't abort JVM!"); } } // else this is the main test ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError", "-Xmx64m", TestCrashOnOutOfMemoryError.class.getName(),"throwOOME"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); int exitValue = output.getExitValue(); if (0 == exitValue) { //expecting a non zero value throw new Error("Expected to get non zero exit value"); } /* Output should look something like this. The actual text will depend on the OS and its core dump processing. Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit # To suppress the following error report, specify this argument # after -XX: or in .hotspotrc: SuppressErrorAt=/debug.cpp:303 # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/home/cheleswer/Desktop/jdk9/dev/hotspot/src/share/vm/utilities/debug.cpp:303), pid=6212, tid=6213 # fatal error: OutOfMemory encountered: Requested array size exceeds VM limit # # JRE version: OpenJDK Runtime Environment (9.0) (build 1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00) # Java VM: OpenJDK 64-Bit Server VM (1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00, mixed mode, tiered, compressed oops, serial gc, linux-amd64) # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/cheleswer/Desktop/core.6212) # # An error report file with more information is saved as: # /home/cheleswer/Desktop/hs_err_pid6212.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # Current thread is 6213 Dumping core ... Aborted (core dumped) */ output.shouldContain("Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit"); // extract hs-err file String hs_err_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1); if (hs_err_file == null) { throw new Error("Did not find hs-err file in output.\n"); } /* * Check if hs_err files exist or not */ File f = new File(hs_err_file); if (!f.exists()) { throw new Error("hs-err file missing at "+ f.getAbsolutePath() + ".\n"); } System.out.println("PASSED"); }
Example 19
Source File: TestCrashOnOutOfMemoryError.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { if (args.length == 1) { // This should guarantee to throw: // java.lang.OutOfMemoryError: Requested array size exceeds VM limit try { Object[] oa = new Object[Integer.MAX_VALUE]; throw new Error("OOME not triggered"); } catch (OutOfMemoryError err) { throw new Error("OOME didn't abort JVM!"); } } // else this is the main test ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError", "-Xmx64m", TestCrashOnOutOfMemoryError.class.getName(),"throwOOME"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); int exitValue = output.getExitValue(); if (0 == exitValue) { //expecting a non zero value throw new Error("Expected to get non zero exit value"); } /* Output should look something like this. The actual text will depend on the OS and its core dump processing. Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit # To suppress the following error report, specify this argument # after -XX: or in .hotspotrc: SuppressErrorAt=/debug.cpp:303 # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/home/cheleswer/Desktop/jdk9/dev/hotspot/src/share/vm/utilities/debug.cpp:303), pid=6212, tid=6213 # fatal error: OutOfMemory encountered: Requested array size exceeds VM limit # # JRE version: OpenJDK Runtime Environment (9.0) (build 1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00) # Java VM: OpenJDK 64-Bit Server VM (1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00, mixed mode, tiered, compressed oops, serial gc, linux-amd64) # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/cheleswer/Desktop/core.6212) # # An error report file with more information is saved as: # /home/cheleswer/Desktop/hs_err_pid6212.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # Current thread is 6213 Dumping core ... Aborted (core dumped) */ output.shouldContain("Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit"); // extract hs-err file String hs_err_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1); if (hs_err_file == null) { throw new Error("Did not find hs-err file in output.\n"); } /* * Check if hs_err files exist or not */ File f = new File(hs_err_file); if (!f.exists()) { throw new Error("hs-err file missing at "+ f.getAbsolutePath() + ".\n"); } System.out.println("PASSED"); }
Example 20
Source File: TestCrashOnOutOfMemoryError.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) throws Exception { if (args.length == 1) { // This should guarantee to throw: // java.lang.OutOfMemoryError: Requested array size exceeds VM limit try { Object[] oa = new Object[Integer.MAX_VALUE]; throw new Error("OOME not triggered"); } catch (OutOfMemoryError err) { throw new Error("OOME didn't abort JVM!"); } } // else this is the main test ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError", "-Xmx64m", TestCrashOnOutOfMemoryError.class.getName(),"throwOOME"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); int exitValue = output.getExitValue(); if (0 == exitValue) { //expecting a non zero value throw new Error("Expected to get non zero exit value"); } /* Output should look something like this. The actual text will depend on the OS and its core dump processing. Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit # To suppress the following error report, specify this argument # after -XX: or in .hotspotrc: SuppressErrorAt=/debug.cpp:303 # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/home/cheleswer/Desktop/jdk9/dev/hotspot/src/share/vm/utilities/debug.cpp:303), pid=6212, tid=6213 # fatal error: OutOfMemory encountered: Requested array size exceeds VM limit # # JRE version: OpenJDK Runtime Environment (9.0) (build 1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00) # Java VM: OpenJDK 64-Bit Server VM (1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00, mixed mode, tiered, compressed oops, serial gc, linux-amd64) # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/cheleswer/Desktop/core.6212) # # An error report file with more information is saved as: # /home/cheleswer/Desktop/hs_err_pid6212.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # Current thread is 6213 Dumping core ... Aborted (core dumped) */ output.shouldContain("Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit"); // extract hs-err file String hs_err_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1); if (hs_err_file == null) { throw new Error("Did not find hs-err file in output.\n"); } /* * Check if hs_err files exist or not */ File f = new File(hs_err_file); if (!f.exists()) { throw new Error("hs-err file missing at "+ f.getAbsolutePath() + ".\n"); } System.out.println("PASSED"); }