jdk/test/sun/tools/jps/TestJps.java
changeset 42101 e75889484926
equal deleted inserted replaced
42100:5590be0da3c8 42101:e75889484926
       
     1 /*
       
     2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 /*
       
    25  * @test
       
    26  * @library /lib/testlibrary /test/lib
       
    27  * @modules jdk.jartool/sun.tools.jar
       
    28  * @build LingeredAppForJps
       
    29  * @build LingeredApp
       
    30  * @run main/othervm TestJps
       
    31  */
       
    32 
       
    33  /*
       
    34   * Notes:
       
    35   *   @modules tag is ignored in driver mode, so need main/othervm
       
    36   *
       
    37   *   Launching the process with relative path to an app jar file is not tested
       
    38   *
       
    39   *   This test resides in default package, so correct appearance
       
    40   *   of the full package name actually is not tested.
       
    41   */
       
    42 
       
    43 import java.util.List;
       
    44 import java.io.File;
       
    45 
       
    46 public class TestJps {
       
    47 
       
    48     public static void testJpsClass() throws Throwable {
       
    49         LingeredApp app = new LingeredAppForJps();
       
    50         try {
       
    51             LingeredApp.startApp(JpsHelper.getVmArgs(), app);
       
    52             JpsHelper.runJpsVariants(app.getPid(),
       
    53                 LingeredAppForJps.getProcessName(), LingeredAppForJps.getFullProcessName(), app.getLockFileName());
       
    54 
       
    55         } finally {
       
    56             LingeredApp.stopApp(app);
       
    57         }
       
    58     }
       
    59 
       
    60     public static void testJpsJar() throws Throwable {
       
    61         // Get any jar exception as early as possible
       
    62         File jar = LingeredAppForJps.buildJar();
       
    63 
       
    64         // Jar created go to the main test
       
    65         LingeredAppForJps app = new LingeredAppForJps();
       
    66         try {
       
    67             LingeredAppForJps.startAppJar(JpsHelper.getVmArgs(), app, jar);
       
    68             JpsHelper.runJpsVariants(app.getPid(),
       
    69                 LingeredAppForJps.getProcessName(jar), LingeredAppForJps.getFullProcessName(jar), app.getLockFileName());
       
    70         } finally {
       
    71             LingeredAppForJps.stopApp(app);
       
    72         }
       
    73 
       
    74     }
       
    75 
       
    76     public static void main(String[] args) throws Throwable {
       
    77         testJpsClass();
       
    78         testJpsJar();
       
    79     }
       
    80 }