author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 44545 | jdk/test/tools/jlink/JLinkTest.java@83b611b88ac8 |
child 47464 | 36de9c637393 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
44367
a81c9c6619fb
8174826: jlink support for linking in service provider modules
mchung
parents:
43495
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
36511 | 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 java.io.IOException; |
|
25 |
import java.io.PrintWriter; |
|
26 |
import java.io.StringWriter; |
|
39153
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
27 |
import java.lang.module.ModuleDescriptor; |
36511 | 28 |
import java.nio.file.Files; |
29 |
import java.nio.file.Path; |
|
30 |
import java.nio.file.Paths; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.Collections; |
|
33 |
import java.util.List; |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
34 |
import java.util.spi.ToolProvider; |
36511 | 35 |
import java.util.stream.Stream; |
36 |
||
37 |
import jdk.tools.jlink.plugin.Plugin; |
|
38 |
import jdk.tools.jlink.internal.PluginRepository; |
|
39 |
import tests.Helper; |
|
40 |
import tests.JImageGenerator; |
|
41 |
||
42 |
/* |
|
43 |
* @test |
|
44 |
* @summary Test image creation |
|
45 |
* @author Jean-Francois Denise |
|
46 |
* @library ../lib |
|
47 |
* @modules java.base/jdk.internal.jimage |
|
48 |
* jdk.jdeps/com.sun.tools.classfile |
|
49 |
* jdk.jlink/jdk.tools.jlink.internal |
|
43185 | 50 |
* jdk.jlink/jdk.tools.jlink.plugin |
36511 | 51 |
* jdk.jlink/jdk.tools.jimage |
52 |
* jdk.compiler |
|
53 |
* @build tests.* |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
54 |
* @run main/othervm -Xmx1g JLinkTest |
36511 | 55 |
*/ |
56 |
public class JLinkTest { |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
57 |
static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
58 |
.orElseThrow(() -> |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
59 |
new RuntimeException("jlink tool not found") |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
60 |
); |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
61 |
|
39153
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
62 |
// number of built-in plugins from jdk.jlink module |
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
63 |
private static int getNumJlinkPlugins() { |
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
64 |
ModuleDescriptor desc = Plugin.class.getModule().getDescriptor(); |
42338
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
65 |
return desc.provides().stream() |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
66 |
.filter(p -> p.service().equals(Plugin.class.getName())) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
67 |
.map(p -> p.providers().size()) |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
68 |
.findAny() |
a60f280f803c
8169069: Module system implementation refresh (11/2016)
alanb
parents:
41766
diff
changeset
|
69 |
.orElse(0); |
39153
26b3cb81aac9
8153238: Improve test/tools/jlink/JLinkTest.java not to hard code the number of plugins
sundar
parents:
37893
diff
changeset
|
70 |
} |
36511 | 71 |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
72 |
private static boolean isOfJLinkModule(Plugin p) { |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
73 |
return p.getClass().getModule() == Plugin.class.getModule(); |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
74 |
} |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
75 |
|
36511 | 76 |
public static void main(String[] args) throws Exception { |
77 |
||
78 |
Helper helper = Helper.newHelper(); |
|
79 |
if (helper == null) { |
|
80 |
System.err.println("Test not run"); |
|
81 |
return; |
|
82 |
} |
|
83 |
helper.generateDefaultModules(); |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
84 |
// expected num. of plugins from jdk.jlink module |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
85 |
int expectedJLinkPlugins = getNumJlinkPlugins(); |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
86 |
int totalPlugins = 0; |
36511 | 87 |
{ |
88 |
// number of built-in plugins |
|
89 |
List<Plugin> builtInPlugins = new ArrayList<>(); |
|
44545
83b611b88ac8
8177530: Module system implementation refresh (4/2017)
alanb
parents:
44367
diff
changeset
|
90 |
builtInPlugins.addAll(PluginRepository.getPlugins(ModuleLayer.boot())); |
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
91 |
totalPlugins = builtInPlugins.size(); |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
92 |
// actual num. of plugins loaded from jdk.jlink module |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
93 |
int actualJLinkPlugins = 0; |
36511 | 94 |
for (Plugin p : builtInPlugins) { |
95 |
p.getState(); |
|
96 |
p.getType(); |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
97 |
if (isOfJLinkModule(p)) { |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
98 |
actualJLinkPlugins++; |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
99 |
} |
36511 | 100 |
} |
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
101 |
if (expectedJLinkPlugins != actualJLinkPlugins) { |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
102 |
throw new AssertionError("Actual plugins loaded from jdk.jlink: " + |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
103 |
actualJLinkPlugins + " which doesn't match expected number : " + |
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
104 |
expectedJLinkPlugins); |
36511 | 105 |
} |
106 |
} |
|
107 |
||
108 |
{ |
|
109 |
String moduleName = "bug8134651"; |
|
110 |
JImageGenerator.getJLinkTask() |
|
111 |
.modulePath(helper.defaultModulePath()) |
|
112 |
.output(helper.createNewImageDir(moduleName)) |
|
113 |
.addMods("leaf1") |
|
114 |
.call().assertSuccess(); |
|
115 |
JImageGenerator.getJLinkTask() |
|
116 |
.modulePath(helper.defaultModulePath()) |
|
117 |
.addMods("leaf1") |
|
118 |
.option("--output") |
|
119 |
.call().assertFailure("Error: no value given for --output"); |
|
120 |
JImageGenerator.getJLinkTask() |
|
121 |
.modulePath("") |
|
122 |
.output(helper.createNewImageDir(moduleName)) |
|
123 |
.addMods("leaf1") |
|
40261
86a49ba76f52
8136930: Simplify use of module-system options by custom launchers
mchung
parents:
40209
diff
changeset
|
124 |
.call().assertFailure("Error: no value given for --module-path"); |
36511 | 125 |
} |
126 |
||
127 |
{ |
|
40209
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
128 |
String moduleName = "m"; // 8163382 |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
129 |
Path jmod = helper.generateDefaultJModule(moduleName).assertSuccess(); |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
130 |
JImageGenerator.getJLinkTask() |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
131 |
.modulePath(helper.defaultModulePath()) |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
132 |
.output(helper.createNewImageDir(moduleName)) |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
133 |
.addMods("m") |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
134 |
.call().assertSuccess(); |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
135 |
moduleName = "mod"; |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
136 |
jmod = helper.generateDefaultJModule(moduleName).assertSuccess(); |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
137 |
JImageGenerator.getJLinkTask() |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
138 |
.modulePath(helper.defaultModulePath()) |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
139 |
.output(helper.createNewImageDir(moduleName)) |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
140 |
.addMods("m") |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
141 |
.call().assertSuccess(); |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
142 |
} |
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
143 |
|
68e8944f4424
8163382: ResourcePoolManager.findEntry has a bug in startsWith call
sundar
parents:
39321
diff
changeset
|
144 |
{ |
41212
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
145 |
String moduleName = "m_8165735"; // JDK-8165735 |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
146 |
helper.generateDefaultJModule(moduleName+"dependency").assertSuccess(); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
147 |
Path jmod = helper.generateDefaultJModule(moduleName, moduleName+"dependency").assertSuccess(); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
148 |
JImageGenerator.getJLinkTask() |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
149 |
.modulePath(helper.defaultModulePath()) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
150 |
.repeatedModulePath(".") // second --module-path overrides the first one |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
151 |
.output(helper.createNewImageDir(moduleName)) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
152 |
.addMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
153 |
// second --module-path does not have that module |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
154 |
.call().assertFailure("Error: Module m_8165735 not found"); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
155 |
|
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
156 |
JImageGenerator.getJLinkTask() |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
157 |
.modulePath(".") // first --module-path overridden later |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
158 |
.repeatedModulePath(helper.defaultModulePath()) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
159 |
.output(helper.createNewImageDir(moduleName)) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
160 |
.addMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
161 |
// second --module-path has that module |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
162 |
.call().assertSuccess(); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
163 |
|
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
164 |
JImageGenerator.getJLinkTask() |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
165 |
.modulePath(helper.defaultModulePath()) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
166 |
.output(helper.createNewImageDir(moduleName)) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
167 |
.limitMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
168 |
.repeatedLimitMods("java.base") // second --limit-modules overrides first |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
169 |
.addMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
170 |
.call().assertFailure("Error: Module m_8165735dependency not found, required by m_8165735"); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
171 |
|
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
172 |
JImageGenerator.getJLinkTask() |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
173 |
.modulePath(helper.defaultModulePath()) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
174 |
.output(helper.createNewImageDir(moduleName)) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
175 |
.limitMods("java.base") |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
176 |
.repeatedLimitMods(moduleName) // second --limit-modules overrides first |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
177 |
.addMods(moduleName) |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
178 |
.call().assertSuccess(); |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
179 |
} |
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
180 |
|
54a8bb41b174
8165735: jlink incorrectly accepts multiple --module-path and --limit-modules options
sundar
parents:
40261
diff
changeset
|
181 |
{ |
36511 | 182 |
// Help |
183 |
StringWriter writer = new StringWriter(); |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
184 |
PrintWriter pw = new PrintWriter(writer); |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
185 |
JLINK_TOOL.run(pw, pw, "--help"); |
36511 | 186 |
String output = writer.toString(); |
187 |
if (output.split("\n").length < 10) { |
|
188 |
System.err.println(output); |
|
189 |
throw new AssertionError("Help"); |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
{ |
|
194 |
// List plugins |
|
195 |
StringWriter writer = new StringWriter(); |
|
41484
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
196 |
PrintWriter pw = new PrintWriter(writer); |
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
197 |
|
834b7539ada3
8164689: Retrofit jar, jlink, jmod as a ToolProvider
mchung
parents:
41352
diff
changeset
|
198 |
JLINK_TOOL.run(pw, pw, "--list-plugins"); |
36511 | 199 |
String output = writer.toString(); |
200 |
long number = Stream.of(output.split("\\R")) |
|
201 |
.filter((s) -> s.matches("Plugin Name:.*")) |
|
202 |
.count(); |
|
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
203 |
if (number != totalPlugins) { |
36511 | 204 |
System.err.println(output); |
39304
8d9ceb81a46e
8160346: JLinkTest.java should compute exact number of plugins from jdk.jlink module
sundar
parents:
39153
diff
changeset
|
205 |
throw new AssertionError("Found: " + number + " expected " + totalPlugins); |
36511 | 206 |
} |
207 |
} |
|
208 |
||
209 |
// filter out files and resources + Skip debug + compress |
|
210 |
{ |
|
211 |
String[] userOptions = {"--compress", "2", "--strip-debug", |
|
212 |
"--exclude-resources", "*.jcov, */META-INF/*", "--exclude-files", |
|
213 |
"*" + Helper.getDebugSymbolsExtension()}; |
|
214 |
String moduleName = "excludezipskipdebugcomposite2"; |
|
215 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
216 |
String[] res = {".jcov", "/META-INF/"}; |
|
217 |
String[] files = {Helper.getDebugSymbolsExtension()}; |
|
218 |
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess(); |
|
219 |
helper.checkImage(imageDir, moduleName, res, files); |
|
220 |
} |
|
221 |
||
222 |
// filter out + Skip debug + compress with filter + sort resources |
|
223 |
{ |
|
224 |
String[] userOptions2 = {"--compress=2:compress-filter=^/java.base/*", |
|
225 |
"--strip-debug", "--exclude-resources", |
|
37893
f1cc7d17e66b
8156781: change to jlink has result in test failure
jlaskey
parents:
37779
diff
changeset
|
226 |
"*.jcov, */META-INF/*", "--order-resources", |
36511 | 227 |
"*/module-info.class,/sortcomposite2/*,*/javax/management/*"}; |
228 |
String moduleName = "excludezipfilterskipdebugcomposite2"; |
|
229 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
230 |
String[] res = {".jcov", "/META-INF/"}; |
|
231 |
Path imageDir = helper.generateDefaultImage(userOptions2, moduleName).assertSuccess(); |
|
232 |
helper.checkImage(imageDir, moduleName, res, null); |
|
233 |
} |
|
234 |
||
235 |
// default compress |
|
236 |
{ |
|
237 |
testCompress(helper, "compresscmdcomposite2", "--compress", "2"); |
|
238 |
} |
|
239 |
||
240 |
{ |
|
241 |
testCompress(helper, "compressfiltercmdcomposite2", |
|
242 |
"--compress=2:filter=^/java.base/java/lang/*"); |
|
243 |
} |
|
244 |
||
245 |
// compress 0 |
|
246 |
{ |
|
247 |
testCompress(helper, "compress0filtercmdcomposite2", |
|
248 |
"--compress=0:filter=^/java.base/java/lang/*"); |
|
249 |
} |
|
250 |
||
251 |
// compress 1 |
|
252 |
{ |
|
253 |
testCompress(helper, "compress1filtercmdcomposite2", |
|
254 |
"--compress=1:filter=^/java.base/java/lang/*"); |
|
255 |
} |
|
256 |
||
257 |
// compress 2 |
|
258 |
{ |
|
259 |
testCompress(helper, "compress2filtercmdcomposite2", |
|
260 |
"--compress=2:filter=^/java.base/java/lang/*"); |
|
261 |
} |
|
262 |
||
263 |
// invalid compress level |
|
264 |
{ |
|
265 |
String[] userOptions = {"--compress", "invalid"}; |
|
266 |
String moduleName = "invalidCompressLevel"; |
|
267 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
37779
7c84df693837
8154956: Module system implementation refresh (4/2016)
alanb
parents:
36757
diff
changeset
|
268 |
helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: Invalid compression level invalid"); |
36511 | 269 |
} |
270 |
||
41766 | 271 |
// orphan argument - JDK-8166810 |
36511 | 272 |
{ |
41766 | 273 |
String[] userOptions = {"--compress", "2", "foo" }; |
274 |
String moduleName = "orphanarg1"; |
|
36511 | 275 |
helper.generateDefaultJModule(moduleName, "composite2"); |
44367
a81c9c6619fb
8174826: jlink support for linking in service provider modules
mchung
parents:
43495
diff
changeset
|
276 |
helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: foo"); |
36511 | 277 |
} |
278 |
||
41766 | 279 |
// orphan argument - JDK-8166810 |
280 |
{ |
|
281 |
String[] userOptions = {"--output", "foo", "bar" }; |
|
282 |
String moduleName = "orphanarg2"; |
|
283 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
44367
a81c9c6619fb
8174826: jlink support for linking in service provider modules
mchung
parents:
43495
diff
changeset
|
284 |
helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: bar"); |
41766 | 285 |
} |
43495
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
286 |
|
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
287 |
// basic check for --help - JDK-8173717 |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
288 |
{ |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
289 |
JImageGenerator.getJLinkTask() |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
290 |
.option("--help") |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
291 |
.call().assertSuccess(); |
8255aabd0e09
8173717: jlink --help fails with missing "plugin.opt.plugin-module-path" key in resource bundle
sundar
parents:
43185
diff
changeset
|
292 |
} |
36511 | 293 |
} |
294 |
||
295 |
private static void testCompress(Helper helper, String moduleName, String... userOptions) throws IOException { |
|
296 |
helper.generateDefaultJModule(moduleName, "composite2"); |
|
297 |
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess(); |
|
298 |
helper.checkImage(imageDir, moduleName, null, null); |
|
299 |
} |
|
300 |
} |