author | prr |
Wed, 29 Nov 2017 09:47:02 -0800 | |
changeset 47982 | 44371ff1ee9a |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
42167
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
1 |
/* |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
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 basic options, i.e. --version, -h |
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 JImageBasicsTest |
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 static jdk.test.lib.Asserts.assertTrue; |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
34 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
35 |
public class JImageBasicsTest extends JImageCliTest { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
36 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
37 |
public void testVersion() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
38 |
jimage("--version") |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
39 |
.assertSuccess() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
40 |
.resultChecker(r -> { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
41 |
assertTrue(r.output.contains(System.getProperty("java.version")), "Contains java version."); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
42 |
}); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
43 |
} |
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 |
public void testFullVersion() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
46 |
jimage("--full-version") |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
47 |
.assertSuccess() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
48 |
.resultChecker(r -> { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
49 |
assertTrue(r.output.contains(System.getProperty("java.version")), "Contains java version."); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
50 |
}); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
51 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
52 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
53 |
public void testHelp() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
54 |
jimage("--help") |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
55 |
.assertSuccess() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
56 |
.resultChecker(r -> verifyHelpOutput(r.output)); |
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 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
59 |
public void testShortHelp() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
60 |
jimage("-h") |
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 -> verifyHelpOutput(r.output)); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
63 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
64 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
65 |
public void testUnknownAction() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
66 |
jimage("unknown") |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
67 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
68 |
.assertShowsError(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
69 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
70 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
71 |
public void testUnknownOption() { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
72 |
jimage("--unknown") |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
73 |
.assertFailure() |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
74 |
.assertShowsError(); |
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 |
|
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
77 |
private void verifyHelpOutput(String output) { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
78 |
assertTrue(output.startsWith("Usage: jimage"), "Usage is printed."); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
79 |
assertTrue(output.contains("extract"), "Option 'extract' is found."); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
80 |
assertTrue(output.contains("info"), "Option 'info' is found."); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
81 |
assertTrue(output.contains("list"), "Option 'list' is found."); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
82 |
assertTrue(output.contains("verify"), "Option 'verify' is found."); |
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 static void main(String[] args) throws Throwable { |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
86 |
new JImageBasicsTest().runTests(); |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
87 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
88 |
} |
312b1ca6b1df
8167240: Write new tests to cover functionality of existing 'jimage' options
dkononenko
parents:
diff
changeset
|
89 |