1 /* |
|
2 * Copyright (c) 2018, 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 java.io.File; |
|
25 import java.nio.file.Files; |
|
26 import java.nio.file.Path; |
|
27 import java.nio.file.Paths; |
|
28 import java.util.List; |
|
29 import java.util.stream.Collectors; |
|
30 |
|
31 /* |
|
32 * @test |
|
33 * @summary jpackage create image with --strip-native-commands test |
|
34 * @library ../helpers |
|
35 * @build JPackageHelper |
|
36 * @build JPackagePath |
|
37 * @modules jdk.jpackage |
|
38 * @run main/othervm -Xmx512m JPackageCreateImageStripNativeCommandsTest |
|
39 */ |
|
40 public class JPackageCreateImageStripNativeCommandsTest { |
|
41 private static final String runtimeBinPath = JPackagePath.getRuntimeBin(); |
|
42 |
|
43 private static final String [] CMD = { |
|
44 "create-image", |
|
45 "--input", "input", |
|
46 "--output", "output", |
|
47 "--name", "test", |
|
48 "--main-jar", "hello.jar", |
|
49 "--main-class", "Hello", |
|
50 "--files", "hello.jar", |
|
51 "--overwrite", |
|
52 "--strip-native-commands"}; |
|
53 |
|
54 private static void validate() throws Exception { |
|
55 if (JPackageHelper.isWindows()) { |
|
56 Path binPath = Paths.get(runtimeBinPath).toAbsolutePath(); |
|
57 List<Path> files = Files.walk(binPath).collect(Collectors.toList()); |
|
58 files.forEach((f) -> { |
|
59 if (f.toString().endsWith(".exe")) { |
|
60 throw new AssertionError( |
|
61 "Found executable file in runtime bin folder: " |
|
62 + f.toString()); |
|
63 } |
|
64 }); |
|
65 } else { |
|
66 File binFolder = new File(runtimeBinPath); |
|
67 if (binFolder.exists()) { |
|
68 throw new AssertionError("Found bin folder in runtime: " |
|
69 + binFolder.toString()); |
|
70 } |
|
71 } |
|
72 } |
|
73 |
|
74 private static void testCreateImage() throws Exception { |
|
75 JPackageHelper.executeCLI(true, CMD); |
|
76 validate(); |
|
77 } |
|
78 |
|
79 private static void testCreateImageToolProvider() throws Exception { |
|
80 JPackageHelper.executeToolProvider(true, CMD); |
|
81 validate(); |
|
82 } |
|
83 |
|
84 public static void main(String[] args) throws Exception { |
|
85 JPackageHelper.createHelloImageJar(); |
|
86 testCreateImage(); |
|
87 testCreateImageToolProvider(); |
|
88 } |
|
89 |
|
90 } |
|