test/hotspot/jtreg/serviceability/dcmd/framework/VMVersionTest.java
changeset 54460 6733a9176cce
parent 53707 67537bbafd7f
equal deleted inserted replaced
54459:e5713cefcf41 54460:6733a9176cce
    31 
    31 
    32 import org.testng.annotations.Test;
    32 import org.testng.annotations.Test;
    33 
    33 
    34 /*
    34 /*
    35  * @test
    35  * @test
       
    36  * @bug 8221730
    36  * @summary Test of diagnostic command VM.version (tests all DCMD executors)
    37  * @summary Test of diagnostic command VM.version (tests all DCMD executors)
    37  * @library /test/lib
    38  * @library /test/lib
    38  *          /vmTestbase
    39  *          /vmTestbase
    39  * @build   TestJavaProcess
       
    40  * @modules java.base/jdk.internal.misc
    40  * @modules java.base/jdk.internal.misc
       
    41  *          java.base/jdk.internal.module
    41  *          java.compiler
    42  *          java.compiler
    42  *          java.management
    43  *          java.management
    43  *          jdk.internal.jvmstat/sun.jvmstat.monitor
    44  *          jdk.internal.jvmstat/sun.jvmstat.monitor
    44  * @run testng/othervm -XX:+UsePerfData VMVersionTest
    45  * @run testng/othervm -XX:+UsePerfData VMVersionTest
    45  */
    46  */
    46 public class VMVersionTest {
    47 public class VMVersionTest {
       
    48 
       
    49     private static final String TEST_PROCESS_CLASS_NAME = process.TestJavaProcess.class.getName();
       
    50 
    47     public void run(CommandExecutor executor) {
    51     public void run(CommandExecutor executor) {
    48         OutputAnalyzer output = executor.execute("VM.version");
    52         OutputAnalyzer output = executor.execute("VM.version");
    49         output.shouldMatch(".*(?:HotSpot|OpenJDK).*VM.*");
    53         output.shouldMatch(".*(?:HotSpot|OpenJDK).*VM.*");
    50     }
    54     }
    51 
    55 
    54         run(new PidJcmdExecutor());
    58         run(new PidJcmdExecutor());
    55     }
    59     }
    56 
    60 
    57     @Test
    61     @Test
    58     public void mainClass() {
    62     public void mainClass() {
    59         TestProcessLauncher t = new TestProcessLauncher(Process.class.getName());
    63         TestProcessLauncher t = new TestProcessLauncher(TEST_PROCESS_CLASS_NAME);
    60         try {
    64         try {
    61             t.launch();
    65             t.launch();
    62             run(new MainClassJcmdExecutor(Process.class.getName()));
    66             run(new MainClassJcmdExecutor(TEST_PROCESS_CLASS_NAME));
       
    67         } finally {
       
    68             t.quit();
       
    69         }
       
    70     }
       
    71 
       
    72     @Test
       
    73     public void mainClassForJar() {
       
    74         TestProcessJarLauncher t = new TestProcessJarLauncher(TEST_PROCESS_CLASS_NAME);
       
    75         try {
       
    76             t.launch();
       
    77             String jarFile = t.getJarFile();
       
    78             run(new MainClassJcmdExecutor(jarFile));
       
    79         } finally {
       
    80             t.quit();
       
    81         }
       
    82     }
       
    83 
       
    84     @Test
       
    85     public void mainClassForModule() {
       
    86         TestProcessModuleLauncher t = new TestProcessModuleLauncher(TEST_PROCESS_CLASS_NAME);
       
    87         try {
       
    88             t.launch();
       
    89             String moduleName = t.getModuleName();
       
    90             run(new MainClassJcmdExecutor(moduleName));
    63         } finally {
    91         } finally {
    64             t.quit();
    92             t.quit();
    65         }
    93         }
    66     }
    94     }
    67 
    95 
    73     @Test
   101     @Test
    74     public void jmx() {
   102     public void jmx() {
    75         run(new JMXExecutor());
   103         run(new JMXExecutor());
    76     }
   104     }
    77 
   105 
    78     private static class Process extends TestJavaProcess{}
       
    79 }
   106 }