< prev index next >

test/serviceability/dcmd/gc/RunGCTest.java

Print this page




  38  * @summary Test of diagnostic command GC.run
  39  * @library /testlibrary
  40  * @build com.oracle.java.testlibrary.*
  41  * @build com.oracle.java.testlibrary.dcmd.*
  42  * @run testng/othervm -XX:+PrintGCDetails -Xloggc:RunGC.gclog -XX:-ExplicitGCInvokesConcurrent RunGCTest
  43  */
  44 public class RunGCTest {
  45     public void run(CommandExecutor executor) {
  46         executor.execute("GC.run");
  47 
  48         Path gcLogPath = Paths.get("RunGC.gclog").toAbsolutePath();
  49         String gcLog = null;
  50 
  51         try {
  52             gcLog = new String(Files.readAllBytes(gcLogPath));
  53         } catch (IOException e) {
  54             Assert.fail("Test error: Could not read GC log file: " + gcLogPath, e);
  55         }
  56 
  57         OutputAnalyzer output = new OutputAnalyzer(gcLog, "");
  58         output.shouldMatch(".*\\[Full GC \\(System(\\.gc\\(\\))?.*");
  59     }
  60 
  61     @Test
  62     public void jmx() {
  63         run(new JMXExecutor());
  64     }
  65 }


  38  * @summary Test of diagnostic command GC.run
  39  * @library /testlibrary
  40  * @build com.oracle.java.testlibrary.*
  41  * @build com.oracle.java.testlibrary.dcmd.*
  42  * @run testng/othervm -XX:+PrintGCDetails -Xloggc:RunGC.gclog -XX:-ExplicitGCInvokesConcurrent RunGCTest
  43  */
  44 public class RunGCTest {
  45     public void run(CommandExecutor executor) {
  46         executor.execute("GC.run");
  47 
  48         Path gcLogPath = Paths.get("RunGC.gclog").toAbsolutePath();
  49         String gcLog = null;
  50 
  51         try {
  52             gcLog = new String(Files.readAllBytes(gcLogPath));
  53         } catch (IOException e) {
  54             Assert.fail("Test error: Could not read GC log file: " + gcLogPath, e);
  55         }
  56 
  57         OutputAnalyzer output = new OutputAnalyzer(gcLog, "");
  58         output.shouldContain("[Full GC (Diagnostic Command)");
  59     }
  60 
  61     @Test
  62     public void jmx() {
  63         run(new JMXExecutor());
  64     }
  65 }
< prev index next >