author | alanb |
Mon, 19 Feb 2018 19:02:43 +0000 | |
changeset 48915 | b417304c811b |
parent 48699 | f4e628259d1b |
child 50981 | ce27f6e0734d |
permissions | -rw-r--r-- |
42167
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
1 |
/* |
48915
b417304c811b
8198380: tools/jimage/JImageExtractTest.java failing
alanb
parents:
48699
diff
changeset
|
2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
42167
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
4 |
* |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
8 |
* |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
13 |
* accompanied this code). |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
14 |
* |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
18 |
* |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
21 |
* questions. |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
22 |
*/ |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
23 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
24 |
/* |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
25 |
* @test |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
26 |
* @summary Tests to verify jimage 'extract' action |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
27 |
* @library /test/lib |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
28 |
* @modules jdk.jlink/jdk.tools.jimage |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
29 |
* @build jdk.test.lib.Asserts |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
30 |
* @run main/othervm JImageExtractTest |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
31 |
*/ |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
32 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
33 |
import java.io.IOException; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
34 |
import java.nio.file.Files; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
35 |
import java.nio.file.Path; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
36 |
import java.nio.file.Paths; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
37 |
import java.nio.file.attribute.FileAttribute; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
38 |
import java.nio.file.attribute.PosixFilePermission; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
39 |
import java.nio.file.attribute.PosixFilePermissions; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
40 |
import java.util.Arrays; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
41 |
import java.util.HashSet; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
42 |
import java.util.Set; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
43 |
import java.util.stream.Collectors; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
44 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
45 |
import static jdk.test.lib.Asserts.assertEquals; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
46 |
import static jdk.test.lib.Asserts.assertTrue; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
47 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
48 |
public class JImageExtractTest extends JImageCliTest { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
49 |
public void testExtract() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
50 |
jimage("extract", getImagePath()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
51 |
.assertSuccess() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
52 |
.resultChecker(r -> { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
53 |
assertTrue(r.output.isEmpty(), "Output is not expected"); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
54 |
}); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
55 |
verifyExplodedImage(Paths.get(".")); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
56 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
57 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
58 |
public void testExtractHelp() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
59 |
for (String opt : Arrays.asList("-h", "--help")) { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
60 |
jimage("extract", "--help") |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
61 |
.assertSuccess() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
62 |
.resultChecker(r -> { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
63 |
// extract - descriptive text |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
64 |
assertMatches("\\s+extract\\s+-\\s+.*", r.output); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
65 |
}); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
66 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
67 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
68 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
69 |
public void testExtractToDir() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
70 |
Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName()); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
71 |
jimage("extract", "--dir", tmp.toString(), getImagePath()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
72 |
.assertSuccess() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
73 |
.resultChecker(r -> { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
74 |
assertTrue(r.output.isEmpty(), "Output is not expected"); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
75 |
}); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
76 |
verifyExplodedImage(tmp); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
77 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
78 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
79 |
public void testExtractNoImageSpecified() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
80 |
jimage("extract", "") |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
81 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
82 |
.assertShowsError(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
83 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
84 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
85 |
public void testExtractNotAnImage() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
86 |
Path tmp = Files.createTempFile(Paths.get("."), getClass().getName(), "not_an_image"); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
87 |
jimage("extract", tmp.toString()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
88 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
89 |
.assertShowsError(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
90 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
91 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
92 |
public void testExtractNotExistingImage() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
93 |
Path tmp = Paths.get(".", "not_existing_image"); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
94 |
Files.deleteIfExists(tmp); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
95 |
jimage("extract", tmp.toString()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
96 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
97 |
.assertShowsError(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
98 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
99 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
100 |
public void testExtractToUnspecifiedDir() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
101 |
jimage("extract", "--dir", "--", getImagePath()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
102 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
103 |
.assertShowsError(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
104 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
105 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
106 |
public void testExtractToNotExistingDir() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
107 |
Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName()); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
108 |
Files.delete(tmp); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
109 |
jimage("extract", "--dir", tmp.toString(), getImagePath()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
110 |
.assertSuccess() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
111 |
.resultChecker(r -> { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
112 |
assertTrue(r.output.isEmpty(), "Output is not expected"); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
113 |
}); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
114 |
verifyExplodedImage(tmp); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
115 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
116 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
117 |
public void testExtractFromDir() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
118 |
Path imagePath = Paths.get(getImagePath()); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
119 |
Path imageDirPath = imagePath.subpath(0, imagePath.getNameCount() - 1); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
120 |
jimage("extract", imageDirPath.toString()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
121 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
122 |
.assertShowsError(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
123 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
124 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
125 |
public void testExtractToDirBySymlink() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
126 |
Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName()); |
48699
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
127 |
Path symlink; |
42167
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
128 |
try { |
48699
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
129 |
symlink = Files.createSymbolicLink(Paths.get(".", "symlink"), tmp); |
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
130 |
} catch (IOException|UnsupportedOperationException e) { |
42167
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
131 |
// symlinks are not supported |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
132 |
// nothing to test |
48699
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
133 |
return; |
42167
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
134 |
} |
48699
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
135 |
|
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
136 |
jimage("extract", "--dir", symlink.toString(), getImagePath()) |
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
137 |
.assertSuccess() |
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
138 |
.resultChecker(r -> { |
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
139 |
assertTrue(r.output.isEmpty(), "Output is not expected"); |
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
140 |
}); |
f4e628259d1b
8194229: tools/jmod/JmodTest.jtr fails when no privilege to create sym link on windows
mchung
parents:
47216
diff
changeset
|
141 |
verifyExplodedImage(tmp); |
42167
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
142 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
143 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
144 |
public void testExtractToReadOnlyDir() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
145 |
Set<PosixFilePermission> perms = PosixFilePermissions.fromString("r-xr--r--"); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
146 |
FileAttribute<Set<PosixFilePermission>> atts = PosixFilePermissions.asFileAttribute(perms); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
147 |
Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName(), atts); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
148 |
jimage("extract", "--dir", tmp.toString(), getImagePath()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
149 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
150 |
.assertShowsError(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
151 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
152 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
153 |
public void testExtractToNotEmptyDir() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
154 |
Path tmp = Files.createTempDirectory(Paths.get("."), getClass().getName()); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
155 |
Files.createFile(Paths.get(tmp.toString(), ".not_empty")); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
156 |
jimage("extract", "--dir", tmp.toString(), getImagePath()) |
48915
b417304c811b
8198380: tools/jimage/JImageExtractTest.java failing
alanb
parents:
48699
diff
changeset
|
157 |
.assertSuccess() |
b417304c811b
8198380: tools/jimage/JImageExtractTest.java failing
alanb
parents:
48699
diff
changeset
|
158 |
.resultChecker(r -> { |
b417304c811b
8198380: tools/jimage/JImageExtractTest.java failing
alanb
parents:
48699
diff
changeset
|
159 |
assertTrue(r.output.isEmpty(), "Output is not expected"); |
b417304c811b
8198380: tools/jimage/JImageExtractTest.java failing
alanb
parents:
48699
diff
changeset
|
160 |
}); |
42167
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
161 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
162 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
163 |
public void testExtractToFile() throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
164 |
Path tmp = Files.createTempFile(Paths.get("."), getClass().getName(), "not_a_dir"); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
165 |
jimage("extract", "--dir", tmp.toString(), getImagePath()) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
166 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
167 |
.assertShowsError(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
168 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
169 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
170 |
private void verifyExplodedImage(Path imagePath) throws IOException { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
171 |
Set<Path> allModules = Files.walk(imagePath, 1).collect(Collectors.toSet()); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
172 |
assertTrue(allModules.stream().anyMatch(p -> "java.base".equals(p.getFileName().toString())), |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
173 |
"Exploded image contains java.base module."); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
174 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
175 |
Set<Path> badModules = allModules.stream() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
176 |
.filter(p -> !Files.exists(p.resolve("module-info.class"))) |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
177 |
.collect(Collectors.toSet()); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
178 |
assertEquals(badModules, new HashSet<Path>() {{ add(imagePath); }}, |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
179 |
"There are no exploded modules with missing 'module-info.class'"); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
180 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
181 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
182 |
public static void main(String[] args) throws Throwable { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
183 |
new JImageExtractTest().runTests(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
184 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
185 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
186 |