test/jdk/tools/jlink/plugins/AddOptionsPluginTest.java
changeset 58842 6c255334120d
equal deleted inserted replaced
58836:31ec3e55fa3d 58842:6c255334120d
       
     1 /*
       
     2  * Copyright (c) 2019, 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 import jdk.test.lib.process.*;
       
    25 
       
    26 import tests.Helper;
       
    27 
       
    28 /* @test
       
    29  * @bug 8232080
       
    30  * @summary Test the --add-options plugin
       
    31  * @library ../../lib
       
    32  * @library /test/lib
       
    33  * @modules java.base/jdk.internal.jimage
       
    34  *          jdk.jdeps/com.sun.tools.classfile
       
    35  *          jdk.jlink/jdk.tools.jlink.internal
       
    36  *          jdk.jlink/jdk.tools.jmod
       
    37  *          jdk.jlink/jdk.tools.jimage
       
    38  *          jdk.compiler
       
    39  * @build tests.*
       
    40  * @run main AddOptionsPluginTest
       
    41  */
       
    42 
       
    43 public class AddOptionsPluginTest {
       
    44 
       
    45     private static final String PROP = "add.options.plugin.test";
       
    46     private static final String VALUE = "xyzzy";
       
    47     private static final String OPTS = "-D" + PROP + "=" + VALUE;
       
    48 
       
    49     public static void main(String[] args) throws Throwable {
       
    50 
       
    51         Helper helper = Helper.newHelper();
       
    52         if (helper == null) {
       
    53             System.err.println("Test not run");
       
    54             return;
       
    55         }
       
    56 
       
    57         var module = "addoptions";
       
    58         helper.generateDefaultJModule(module);
       
    59         var image = helper.generateDefaultImage(new String[] { "--add-options", OPTS },
       
    60                                                 module)
       
    61             .assertSuccess();
       
    62         helper.checkImage(image, module, null, null);
       
    63 
       
    64         var launcher = image.resolve("bin/java"
       
    65                                      + (System.getProperty("os.name").startsWith("Windows")
       
    66                                         ? ".exe" : ""));
       
    67         var oa = ProcessTools.executeProcess(launcher.toString(),
       
    68                                              "-XshowSettings:properties", "--version");
       
    69         oa.stderrShouldMatch("^ +" + PROP + " = " + VALUE + "$");
       
    70 
       
    71     }
       
    72 
       
    73 }