author | herrick |
Wed, 23 Oct 2019 10:37:54 -0400 | |
branch | JDK-8200758-branch |
changeset 58762 | 0fe62353385b |
parent 58761 | 88e2753a2334 |
child 58994 | b09ba68c6a19 |
permissions | -rw-r--r-- |
58113 | 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 |
||
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
24 |
import java.io.IOException; |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
25 |
import java.nio.file.Files; |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58113
diff
changeset
|
26 |
import java.nio.file.Path; |
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
27 |
import java.util.HashSet; |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58113
diff
changeset
|
28 |
import java.util.Optional; |
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
29 |
import java.util.Set; |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
30 |
import java.util.stream.Collectors; |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
31 |
import jdk.jpackage.test.*; |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
32 |
import jdk.jpackage.test.Annotations.Test; |
58113 | 33 |
|
34 |
/** |
|
35 |
* Test --runtime-image parameter. |
|
36 |
* Output of the test should be RuntimePackageTest*.* installer. |
|
37 |
* The installer should install Java Runtime without an application. |
|
38 |
* Installation directory should not have "app" subfolder and should not have |
|
39 |
* an application launcher. |
|
40 |
* |
|
41 |
* |
|
42 |
* Windows: |
|
43 |
* |
|
44 |
* Java runtime should be installed in %ProgramFiles%\RuntimePackageTest directory. |
|
45 |
*/ |
|
46 |
||
47 |
/* |
|
48 |
* @test |
|
49 |
* @summary jpackage with --runtime-image |
|
50 |
* @library ../helpers |
|
58761
88e2753a2334
8231972: Build a stable list of jpackager tests for SQE
herrick
parents:
58696
diff
changeset
|
51 |
* @key jpackagePlatformPackage |
58416 | 52 |
* @build jdk.jpackage.test.* |
58113 | 53 |
* @comment Temporary disable for Linux and OSX until functionality implemented |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58113
diff
changeset
|
54 |
* @requires (os.family != "mac") |
58113 | 55 |
* @modules jdk.jpackage/jdk.jpackage.internal |
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
56 |
* @compile RuntimePackageTest.java |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
57 |
* @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
58 |
* --jpt-run=RuntimePackageTest |
58113 | 59 |
*/ |
60 |
public class RuntimePackageTest { |
|
61 |
||
58762
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
62 |
@Test |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
63 |
public static void test() { |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
64 |
new PackageTest() |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
65 |
.addInitializer(cmd -> { |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
66 |
cmd.addArguments("--runtime-image", Optional.ofNullable( |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
67 |
JPackageCommand.DEFAULT_RUNTIME_IMAGE).orElse(Path.of( |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
68 |
System.getProperty("java.home")))); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
69 |
// Remove --input parameter from jpackage command line as we don't |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
70 |
// create input directory in the test and jpackage fails |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
71 |
// if --input references non existant directory. |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
72 |
cmd.removeArgumentWithValue("--input"); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
73 |
}) |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
74 |
.addInstallVerifier(cmd -> { |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
75 |
Set<Path> srcRuntime = listFiles(Path.of(cmd.getArgumentValue("--runtime-image"))); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
76 |
Set<Path> dstRuntime = listFiles(cmd.appRuntimeDirectory()); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
77 |
|
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
78 |
Set<Path> intersection = new HashSet<>(srcRuntime); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
79 |
intersection.retainAll(dstRuntime); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
80 |
|
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
81 |
srcRuntime.removeAll(intersection); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
82 |
dstRuntime.removeAll(intersection); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
83 |
|
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
84 |
assertFileListEmpty(srcRuntime, "Missing"); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
85 |
assertFileListEmpty(dstRuntime, "Unexpected"); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
86 |
}) |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
87 |
.run(); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
88 |
} |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
89 |
|
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
90 |
private static Set<Path> listFiles(Path root) throws IOException { |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
91 |
try (var files = Files.walk(root)) { |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
92 |
return files.map(root::relativize).collect(Collectors.toSet()); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
93 |
} |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
94 |
} |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
95 |
|
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
96 |
private static void assertFileListEmpty(Set<Path> paths, String msg) { |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
97 |
TKit.assertTrue(paths.isEmpty(), String.format( |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
98 |
"Check there are no %s files in installed image", |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
99 |
msg.toLowerCase()), () -> { |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
100 |
String msg2 = String.format("%s %d files", msg, paths.size()); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
101 |
TKit.trace(msg2 + ":"); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
102 |
paths.stream().map(Path::toString).sorted().forEachOrdered( |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
103 |
TKit::trace); |
0fe62353385b
8232281: jpackage is not always reporting an error when no main class specified
herrick
parents:
58761
diff
changeset
|
104 |
TKit.trace("Done"); |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58113
diff
changeset
|
105 |
}); |
58113 | 106 |
} |
107 |
} |