jdk/test/tools/jlink/JLinkTest.java
author sundar
Tue, 21 Jun 2016 19:05:34 +0530
changeset 39129 4b2086305b68
parent 37893 f1cc7d17e66b
child 39153 26b3cb81aac9
permissions -rw-r--r--
8159593: Plugin Set<Category> getType() should return a Category Reviewed-by: jlaskey
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
import java.io.IOException;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
import java.io.PrintWriter;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
import java.io.StringWriter;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    27
import java.lang.reflect.Layer;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
import java.nio.file.Files;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
import java.nio.file.Path;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    30
import java.nio.file.Paths;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
import java.util.ArrayList;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
import java.util.Collections;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
import java.util.List;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    34
import java.util.stream.Stream;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
import jdk.tools.jlink.plugin.Plugin;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
import jdk.tools.jlink.internal.PluginRepository;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
import tests.Helper;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
import tests.JImageGenerator;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
import tests.JImageGenerator.InMemoryFile;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    41
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    43
 * @test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
 * @summary Test image creation
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    45
 * @author Jean-Francois Denise
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
 * @library ../lib
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    47
 * @modules java.base/jdk.internal.jimage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
 *          jdk.jdeps/com.sun.tools.classfile
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
 *          jdk.jlink/jdk.tools.jlink.internal
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
 *          jdk.jlink/jdk.tools.jmod
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
 *          jdk.jlink/jdk.tools.jimage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
 *          jdk.compiler
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
 * @build tests.*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
 * @run main/othervm -verbose:gc -Xmx1g JLinkTest
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
public class JLinkTest {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
    public static void main(String[] args) throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    59
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
        Helper helper = Helper.newHelper();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
        if (helper == null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
            System.err.println("Test not run");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
            return;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
        helper.generateDefaultModules();
36757
c859c6feee56 8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents: 36511
diff changeset
    66
        int numPlugins = 13;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
            // number of built-in plugins
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    69
            List<Plugin> builtInPlugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    70
            builtInPlugins.addAll(PluginRepository.getPlugins(Layer.boot()));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    71
            for (Plugin p : builtInPlugins) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
                p.getState();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
                p.getType();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    74
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    75
            if (builtInPlugins.size() != numPlugins) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
                throw new AssertionError("Found plugins doesn't match expected number : " +
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
                        numPlugins + "\n" + builtInPlugins);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    79
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    80
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    81
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    82
            String moduleName = "bug8134651";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    83
            JImageGenerator.getJLinkTask()
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    84
                    .modulePath(helper.defaultModulePath())
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    85
                    .output(helper.createNewImageDir(moduleName))
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    86
                    .addMods("leaf1")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    87
                    .option("")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    88
                    .call().assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    89
            JImageGenerator.getJLinkTask()
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    90
                    .modulePath(helper.defaultModulePath())
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    91
                    .addMods("leaf1")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    92
                    .option("--output")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    93
                    .option("")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    94
                    .call().assertFailure("Error: no value given for --output");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    95
            JImageGenerator.getJLinkTask()
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    96
                    .modulePath("")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    97
                    .output(helper.createNewImageDir(moduleName))
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    98
                    .addMods("leaf1")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    99
                    .option("")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   100
                    .call().assertFailure("Error: no value given for --modulepath");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   101
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   102
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   103
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   104
            String moduleName = "filter";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   105
            Path jmod = helper.generateDefaultJModule(moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   106
            String className = "_A.class";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   107
            JImageGenerator.addFiles(jmod, new InMemoryFile(className, new byte[0]));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   108
            Path image = helper.generateDefaultImage(moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   109
            helper.checkImage(image, moduleName, new String[] {"/" + moduleName + "/" + className}, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   110
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   111
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   112
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   113
            // Help
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   114
            StringWriter writer = new StringWriter();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   115
            jdk.tools.jlink.internal.Main.run(new String[]{"--help"}, new PrintWriter(writer));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   116
            String output = writer.toString();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   117
            if (output.split("\n").length < 10) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   118
                System.err.println(output);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   119
                throw new AssertionError("Help");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   120
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   121
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   122
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   123
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   124
            // License files
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   125
            String copied = "LICENSE";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   126
            String[] arr = copied.split(",");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   127
            String[] copyFiles = new String[2];
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   128
            copyFiles[0] = "--copy-files";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   129
            copyFiles[1] = copied;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   130
            Path imageDir = helper.generateDefaultImage(copyFiles, "composite2").assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   131
            helper.checkImage(imageDir, "composite2", null, null, arr);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   132
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   133
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   134
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   135
            // List plugins
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   136
            StringWriter writer = new StringWriter();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   137
            jdk.tools.jlink.internal.Main.run(new String[]{"--list-plugins"}, new PrintWriter(writer));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   138
            String output = writer.toString();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   139
            long number = Stream.of(output.split("\\R"))
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   140
                    .filter((s) -> s.matches("Plugin Name:.*"))
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   141
                    .count();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   142
            if (number != numPlugins) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   143
                System.err.println(output);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   144
                throw new AssertionError("Found: " + number + " expected " + numPlugins);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   145
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   146
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   147
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   148
        // filter out files and resources + Skip debug + compress
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   149
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   150
            String[] userOptions = {"--compress", "2", "--strip-debug",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   151
                "--exclude-resources", "*.jcov, */META-INF/*", "--exclude-files",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   152
                "*" + Helper.getDebugSymbolsExtension()};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   153
            String moduleName = "excludezipskipdebugcomposite2";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   154
            helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   155
            String[] res = {".jcov", "/META-INF/"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   156
            String[] files = {Helper.getDebugSymbolsExtension()};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   157
            Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   158
            helper.checkImage(imageDir, moduleName, res, files);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   159
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   160
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   161
        // filter out + Skip debug + compress with filter + sort resources
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   162
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   163
            String[] userOptions2 = {"--compress=2:compress-filter=^/java.base/*",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   164
                "--strip-debug", "--exclude-resources",
37893
f1cc7d17e66b 8156781: change to jlink has result in test failure
jlaskey
parents: 37779
diff changeset
   165
                "*.jcov, */META-INF/*", "--order-resources",
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   166
                "*/module-info.class,/sortcomposite2/*,*/javax/management/*"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   167
            String moduleName = "excludezipfilterskipdebugcomposite2";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   168
            helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   169
            String[] res = {".jcov", "/META-INF/"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   170
            Path imageDir = helper.generateDefaultImage(userOptions2, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   171
            helper.checkImage(imageDir, moduleName, res, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   172
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   173
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   174
        // default compress
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   175
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   176
            testCompress(helper, "compresscmdcomposite2", "--compress", "2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   177
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   178
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   179
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   180
            testCompress(helper, "compressfiltercmdcomposite2",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   181
                    "--compress=2:filter=^/java.base/java/lang/*");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   182
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   183
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   184
        // compress 0
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   185
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   186
            testCompress(helper, "compress0filtercmdcomposite2",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   187
                    "--compress=0:filter=^/java.base/java/lang/*");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   188
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   189
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   190
        // compress 1
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   191
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   192
            testCompress(helper, "compress1filtercmdcomposite2",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   193
                    "--compress=1:filter=^/java.base/java/lang/*");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   194
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   195
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   196
        // compress 2
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   197
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   198
            testCompress(helper, "compress2filtercmdcomposite2",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   199
                    "--compress=2:filter=^/java.base/java/lang/*");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   200
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   201
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   202
        // invalid compress level
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   203
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   204
            String[] userOptions = {"--compress", "invalid"};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   205
            String moduleName = "invalidCompressLevel";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   206
            helper.generateDefaultJModule(moduleName, "composite2");
37779
7c84df693837 8154956: Module system implementation refresh (4/2016)
alanb
parents: 36757
diff changeset
   207
            helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: Invalid compression level invalid");
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   208
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   209
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   210
        // @file
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   211
        {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   212
            Path path = Paths.get("embedded.properties");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   213
            Files.write(path, Collections.singletonList("--strip-debug --addmods " +
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   214
                    "toto.unknown --compress UNKNOWN\n"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   215
            String[] userOptions = {"@", path.toAbsolutePath().toString()};
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   216
            String moduleName = "configembeddednocompresscomposite2";
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   217
            helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   218
            Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   219
            helper.checkImage(imageDir, moduleName, null, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   220
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   221
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   222
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   223
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   224
    private static void testCompress(Helper helper, String moduleName, String... userOptions) throws IOException {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   225
        helper.generateDefaultJModule(moduleName, "composite2");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   226
        Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   227
        helper.checkImage(imageDir, moduleName, null, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   228
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   229
}