author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 43265 | langtools/test/jdk/javadoc/tool/treeapi/TestDocTrees.java@4ec472ee5135 |
permissions | -rw-r--r-- |
43265
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
1 |
/* |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
4 |
* |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
8 |
* |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
14 |
* |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
18 |
* |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
21 |
* questions. |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
22 |
*/ |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
23 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
24 |
/* |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
25 |
* @test |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
26 |
* @bug 8157611 |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
27 |
* @summary test DocTrees is working correctly relative to HTML access |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
28 |
* @modules |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
29 |
* jdk.javadoc/jdk.javadoc.internal.api |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
30 |
* jdk.javadoc/jdk.javadoc.internal.tool |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.api |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.main |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
33 |
* @library /tools/lib |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
34 |
* @build toolbox.ToolBox toolbox.TestRunner |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
35 |
* @run main TestDocTrees |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
36 |
*/ |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
37 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
38 |
import java.io.File; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
39 |
import java.io.IOException; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
40 |
import java.nio.file.Path; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
41 |
import java.nio.file.Paths; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
42 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
43 |
import toolbox.*; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
44 |
import toolbox.Task.Expect; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
45 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
46 |
import static toolbox.Task.OutputKind.*; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
47 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
48 |
/** |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
49 |
* This class is used to test DocTrees functionality relating to |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
50 |
* package and overview HTML files. |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
51 |
*/ |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
52 |
public class TestDocTrees extends TestRunner { |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
53 |
final ToolBox tb; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
54 |
final File testFile; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
55 |
final File testSrc; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
56 |
final File overviewFile; |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
57 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
58 |
TestDocTrees() throws IOException { |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
59 |
super(System.err); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
60 |
tb = new ToolBox(); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
61 |
testSrc = new File(System.getProperty("test.src")); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
62 |
testFile = new File(testSrc, "TestDocTrees.java"); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
63 |
overviewFile = new File(testSrc, "overview.html"); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
64 |
} |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
65 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
66 |
protected void runTests() throws Exception { |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
67 |
runTests(m -> new Object[]{Paths.get(m.getName())}); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
68 |
} |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
69 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
70 |
public static void main(String... args) throws Exception { |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
71 |
new TestDocTrees().runTests(); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
72 |
} |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
73 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
74 |
@Test |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
75 |
public void testOverviewWithRelease8(Path out) { |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
76 |
execTask("-d", out.toString(), |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
77 |
"--release", "8", |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
78 |
"-Xdoclint:all", |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
79 |
"-Xdoclint:-missing", |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
80 |
"-sourcepath", testSrc.getAbsolutePath(), |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
81 |
testFile.getAbsolutePath(), |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
82 |
"-overview", overviewFile.getAbsolutePath()); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
83 |
} |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
84 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
85 |
@Test |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
86 |
public void testOverviewWithoutRelease(Path out) throws Exception { |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
87 |
execTask("-d", out.toString(), |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
88 |
"-Xdoclint:all", |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
89 |
"-Xdoclint:-missing", |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
90 |
"-sourcepath", testSrc.getAbsolutePath(), |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
91 |
testFile.getAbsolutePath(), |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
92 |
"-overview", overviewFile.getAbsolutePath()); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
93 |
} |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
94 |
|
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
95 |
private Task.Result execTask(String... args) { |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
96 |
JavadocTask et = new JavadocTask(tb, Task.Mode.CMDLINE); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
97 |
//args.forEach((a -> System.err.println("arg: " + a))); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
98 |
return et.options(args).run(); |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
99 |
} |
4ec472ee5135
8169608: Compiler Tree API's Doctrees.getDocTreePath needs to accept a PackageElement
ksrini
parents:
diff
changeset
|
100 |
} |