author | mchung |
Wed, 21 Nov 2018 22:34:01 -0800 | |
changeset 52650 | c16b6cc93272 |
parent 50598 | 8d9d4d91be7f |
permissions | -rw-r--r-- |
41997 | 1 |
/* |
50598 | 2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
41997 | 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 |
/* |
|
25 |
* @test |
|
50598 | 26 |
* @bug 8168386 8205116 |
41997 | 27 |
* @summary Test option validation |
28 |
* @modules jdk.jdeps |
|
29 |
* @library lib |
|
30 |
* @build JdepsRunner |
|
31 |
* @run testng Options |
|
32 |
*/ |
|
33 |
||
34 |
||
35 |
import org.testng.annotations.DataProvider; |
|
36 |
import org.testng.annotations.Test; |
|
37 |
||
38 |
import static org.testng.Assert.assertTrue; |
|
39 |
||
40 |
public class Options { |
|
41 |
private static final String TEST_CLASSES = System.getProperty("test.classes"); |
|
42 |
||
43 |
@DataProvider(name = "errors") |
|
44 |
public Object[][] errors() { |
|
45 |
return new Object[][]{ |
|
46 |
{ |
|
47 |
new String[] { "-summary", "-v", TEST_CLASSES }, |
|
48 |
"-v, -verbose cannot be used with -s, -summary option" |
|
49 |
}, |
|
50 |
{ |
|
51 |
new String[] { "-jdkinternal", "-summary", TEST_CLASSES }, |
|
52 |
"-summary or -verbose cannot be used with -jdkinternals option" |
|
53 |
}, |
|
54 |
{ |
|
55 |
new String[] { "-jdkinternal", "-p", "java.lang", TEST_CLASSES }, |
|
52650
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
56 |
"--package, --regex, --require cannot be used with -jdkinternals option" |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
57 |
}, |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
58 |
{ |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
59 |
new String[] { "--missing-deps", "-summary", TEST_CLASSES }, |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
60 |
"-summary or -verbose cannot be used with --missing-deps option" |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
61 |
}, |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
62 |
{ |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
63 |
new String[] { "--missing-deps", "-p", "java.lang", TEST_CLASSES }, |
c16b6cc93272
8213909: jdeps --print-module-deps should report missing dependences
mchung
parents:
50598
diff
changeset
|
64 |
"--package, --regex, --require cannot be used with --missing-deps option" |
41997 | 65 |
}, |
66 |
{ |
|
67 |
new String[] { "--inverse", TEST_CLASSES }, |
|
68 |
"--package (-p), --regex (-e), --require option must be specified" |
|
69 |
}, |
|
70 |
{ |
|
71 |
new String[] { "--inverse", "-R", TEST_CLASSES }, |
|
72 |
"-R cannot be used with --inverse option" |
|
73 |
}, |
|
74 |
{ |
|
75 |
new String[] { "--generate-module-info", "dots", "-cp", TEST_CLASSES }, |
|
76 |
"-classpath cannot be used with --generate-module-info option" |
|
77 |
}, |
|
78 |
{ |
|
79 |
new String[] { "--list-deps", "-summary", TEST_CLASSES }, |
|
80 |
"--list-deps and --list-reduced-deps options are specified" |
|
81 |
}, |
|
82 |
{ |
|
83 |
new String[] { "--list-deps", "--list-reduced-deps", TEST_CLASSES }, |
|
84 |
"--list-deps and --list-reduced-deps options are specified" |
|
85 |
}, |
|
86 |
}; |
|
87 |
} |
|
88 |
||
89 |
@Test(dataProvider = "errors") |
|
90 |
public void test(String[] options, String expected) { |
|
91 |
jdepsError(options).outputContains(expected); |
|
92 |
} |
|
93 |
||
94 |
||
95 |
public static JdepsRunner jdepsError(String... args) { |
|
96 |
JdepsRunner jdeps = new JdepsRunner(args); |
|
97 |
assertTrue(jdeps.run(true) != 0); |
|
98 |
return jdeps; |
|
99 |
} |
|
50598 | 100 |
|
101 |
@Test |
|
102 |
public void testSystemOption() { |
|
103 |
JdepsRunner jdeps; |
|
104 |
||
105 |
// valid path |
|
106 |
jdeps = new JdepsRunner("--check", "java.base", "--system", System.getProperty("java.home")); |
|
107 |
assertTrue(jdeps.run(true) == 0); |
|
108 |
||
109 |
// invalid path |
|
110 |
jdeps = new JdepsRunner("--check", "java.base", "--system", "bad"); |
|
111 |
assertTrue(jdeps.run(true) != 0); |
|
112 |
jdeps.outputContains("invalid path: bad"); |
|
113 |
} |
|
41997 | 114 |
} |