1 /*
2 * Copyright (c) 2015, 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 */
257
258 // compress 2
259 {
260 testCompress(helper, "compress2filtercmdcomposite2",
261 "--compress=2:filter=^/java.base/java/lang/*");
262 }
263
264 // invalid compress level
265 {
266 String[] userOptions = {"--compress", "invalid"};
267 String moduleName = "invalidCompressLevel";
268 helper.generateDefaultJModule(moduleName, "composite2");
269 helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: Invalid compression level invalid");
270 }
271
272 // orphan argument - JDK-8166810
273 {
274 String[] userOptions = {"--compress", "2", "foo" };
275 String moduleName = "orphanarg1";
276 helper.generateDefaultJModule(moduleName, "composite2");
277 helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: orphan argument: foo");
278 }
279
280 // orphan argument - JDK-8166810
281 {
282 String[] userOptions = {"--output", "foo", "bar" };
283 String moduleName = "orphanarg2";
284 helper.generateDefaultJModule(moduleName, "composite2");
285 helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: orphan argument: bar");
286 }
287
288 // basic check for --help - JDK-8173717
289 {
290 JImageGenerator.getJLinkTask()
291 .option("--help")
292 .call().assertSuccess();
293 }
294 }
295
296 private static void testCompress(Helper helper, String moduleName, String... userOptions) throws IOException {
297 helper.generateDefaultJModule(moduleName, "composite2");
298 Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
299 helper.checkImage(imageDir, moduleName, null, null);
300 }
301 }
|
1 /*
2 * Copyright (c) 2015, 2017, 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 */
257
258 // compress 2
259 {
260 testCompress(helper, "compress2filtercmdcomposite2",
261 "--compress=2:filter=^/java.base/java/lang/*");
262 }
263
264 // invalid compress level
265 {
266 String[] userOptions = {"--compress", "invalid"};
267 String moduleName = "invalidCompressLevel";
268 helper.generateDefaultJModule(moduleName, "composite2");
269 helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: Invalid compression level invalid");
270 }
271
272 // orphan argument - JDK-8166810
273 {
274 String[] userOptions = {"--compress", "2", "foo" };
275 String moduleName = "orphanarg1";
276 helper.generateDefaultJModule(moduleName, "composite2");
277 helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: foo");
278 }
279
280 // orphan argument - JDK-8166810
281 {
282 String[] userOptions = {"--output", "foo", "bar" };
283 String moduleName = "orphanarg2";
284 helper.generateDefaultJModule(moduleName, "composite2");
285 helper.generateDefaultImage(userOptions, moduleName).assertFailure("Error: invalid argument: bar");
286 }
287
288 // basic check for --help - JDK-8173717
289 {
290 JImageGenerator.getJLinkTask()
291 .option("--help")
292 .call().assertSuccess();
293 }
294 }
295
296 private static void testCompress(Helper helper, String moduleName, String... userOptions) throws IOException {
297 helper.generateDefaultJModule(moduleName, "composite2");
298 Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
299 helper.checkImage(imageDir, moduleName, null, null);
300 }
301 }
|