|
1 /* |
|
2 * Copyright (c) 2017, 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 |
|
24 /* |
|
25 * @test |
|
26 * @bug 8190003 |
|
27 * @summary Special characters in group names should be escaped |
|
28 * @library /tools/lib ../lib |
|
29 * @modules jdk.javadoc/jdk.javadoc.internal.tool |
|
30 * @build toolbox.ToolBox JavadocTester |
|
31 * @run main TestGroupName |
|
32 */ |
|
33 |
|
34 import java.io.IOException; |
|
35 import java.nio.file.Path; |
|
36 import java.nio.file.Paths; |
|
37 |
|
38 import toolbox.*; |
|
39 |
|
40 public class TestGroupName extends JavadocTester { |
|
41 |
|
42 public final ToolBox tb; |
|
43 public static void main(String... args) throws Exception { |
|
44 TestGroupName tester = new TestGroupName(); |
|
45 tester.runTests(m -> new Object[] { Paths.get(m.getName()) }); |
|
46 } |
|
47 |
|
48 public TestGroupName() { |
|
49 tb = new ToolBox(); |
|
50 } |
|
51 |
|
52 @Test |
|
53 public void testPackageGroups(Path base) throws IOException { |
|
54 Path src = base.resolve("src"); |
|
55 tb.writeJavaFiles(src, |
|
56 "package p1; public class C1 { }", |
|
57 "package p2; public class C2 { }", |
|
58 "package p3; public class C3 { }"); |
|
59 |
|
60 javadoc("-d", base.resolve("out").toString(), |
|
61 "-sourcepath", src.toString(), |
|
62 "-group", "abc < & > def", "p1", |
|
63 "p1", "p2", "p3"); |
|
64 checkExit(Exit.OK); |
|
65 |
|
66 checkOutput("overview-summary.html", true, |
|
67 "summary=\"abc < & > def table", |
|
68 "<span>abc < & > def</span>"); |
|
69 |
|
70 checkOutput("overview-summary.html", false, |
|
71 "abc < & > def");The name should be wrapped in a StringContent node instead. |
|
72 } |
|
73 |
|
74 @Test |
|
75 public void testModuleGroups(Path base) throws IOException { |
|
76 Path src = base.resolve("src"); |
|
77 tb.writeJavaFiles(src.resolve("ma"), |
|
78 "module ma { exports pa1; }", |
|
79 "package pa1; public class CA1 { }", |
|
80 "package pa2; public class CA2 { }", |
|
81 "package pa3; public class CA3 { }"); |
|
82 |
|
83 tb.writeJavaFiles(src.resolve("mb"), |
|
84 "module mb { exports pb1; }", |
|
85 "package pb1; public class CB1 { }", |
|
86 "package pb2; public class CB2 { }", |
|
87 "package pb3; public class CB3 { }"); |
|
88 |
|
89 tb.writeJavaFiles(src.resolve("mc"), |
|
90 "module mc { exports pc1; }", |
|
91 "package pc1; public class CC1 { }", |
|
92 "package pc2; public class CC2 { }", |
|
93 "package pc3; public class CC3 { }"); |
|
94 |
|
95 javadoc("-d", base.resolve("out").toString(), |
|
96 "--module-source-path", src.toString(), |
|
97 "-group", "abc < & > def", "ma", |
|
98 "--module", "ma,mb,mc"); |
|
99 |
|
100 checkExit(Exit.OK); |
|
101 |
|
102 checkOutput("overview-summary.html", true, |
|
103 "summary=\"abc < & > def table", |
|
104 "<span>abc < & > def</span>"); |
|
105 |
|
106 checkOutput("overview-summary.html", false, |
|
107 "abc < & > def"); |
|
108 } |
|
109 } |
|
110 |