24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 4663254 8016328 8025633 8026567 |
26 * @bug 4663254 8016328 8025633 8026567 |
27 * @summary Verify that spaces do not appear in hrefs and anchors. |
27 * @summary Verify that spaces do not appear in hrefs and anchors. |
28 * @author jamieh |
28 * @author jamieh |
29 * @library ../lib/ |
29 * @library ../lib |
30 * @build JavadocTester TestHref |
30 * @build JavadocTester |
31 * @run main TestHref |
31 * @run main TestHref |
32 */ |
32 */ |
33 |
33 |
34 public class TestHref extends JavadocTester { |
34 public class TestHref extends JavadocTester { |
35 |
35 |
36 //Javadoc arguments. |
36 public static void main(String... args) throws Exception { |
37 private static final String[] ARGS = new String[] { |
37 TestHref tester = new TestHref(); |
38 "-d", OUTPUT_DIR, "-sourcepath", SRC_DIR, "-linkoffline", |
38 tester.runTests(); |
39 "http://java.sun.com/j2se/1.4/docs/api/", SRC_DIR, "pkg" |
39 } |
40 }; |
|
41 |
40 |
42 //Input for string search tests. |
41 @Test |
43 private static final String[][] TEST = { |
42 void test() { |
44 //External link. |
43 javadoc("-Xdoclint:none", |
45 { "pkg/C1.html", |
44 "-d", "out", |
46 "href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait-long-int-\"" |
45 "-sourcepath", testSrc, |
47 }, |
46 "-linkoffline", "http://java.sun.com/j2se/1.4/docs/api/", testSrc, |
48 //Member summary table link. |
47 "pkg"); |
49 { "pkg/C1.html", |
48 checkExit(Exit.OK); |
50 "href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\"" |
|
51 }, |
|
52 //Anchor test. |
|
53 { "pkg/C1.html", |
|
54 "<a name=\"method-int-int-java.util.ArrayList-\">\n" + |
|
55 "<!-- -->\n" + |
|
56 "</a>" |
|
57 }, |
|
58 //Backward compatibility anchor test. |
|
59 { "pkg/C1.html", |
|
60 "<a name=\"method-int-int-java.util.ArrayList-\">\n" + |
|
61 "<!-- -->\n" + |
|
62 "</a>" |
|
63 }, |
|
64 //{@link} test. |
|
65 { "pkg/C2.html", |
|
66 "Link: <a href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\">" |
|
67 }, |
|
68 //@see test. |
|
69 { "pkg/C2.html", |
|
70 "See Also:</span></dt>\n" + |
|
71 "<dd><a href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\">" |
|
72 }, |
|
73 |
49 |
74 //Header does not link to the page itself. |
50 checkOutput("pkg/C1.html", true, |
75 { "pkg/C4.html", |
51 //External link. |
76 "Class C4<E extends C4<E>></h2>" |
52 "href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait-long-int-\"", |
77 }, |
53 //Member summary table link. |
|
54 "href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\"", |
|
55 //Anchor test. |
|
56 "<a name=\"method-int-int-java.util.ArrayList-\">\n" |
|
57 + "<!-- -->\n" |
|
58 + "</a>", |
|
59 //Backward compatibility anchor test."pkg/C1.html", |
|
60 "<a name=\"method-int-int-java.util.ArrayList-\">\n" |
|
61 + "<!-- -->\n" |
|
62 + "</a>"); |
78 |
63 |
79 //Signature does not link to the page itself. |
64 checkOutput("pkg/C2.html", true, |
80 { "pkg/C4.html", |
65 //{@link} test. |
81 "public abstract class <span class=\"typeNameLabel\">C4<E extends C4<E>></span>" |
66 "Link: <a href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\">", |
82 }, |
67 //@see test. |
83 }; |
68 "See Also:</span></dt>\n" |
84 private static final String[][] NEGATED_TEST = |
69 + "<dd><a href=\"../pkg/C1.html#method-int-int-java.util.ArrayList-\">" |
85 { |
70 ); |
86 {WARNING_OUTPUT, "<a> tag is malformed"} |
|
87 }; |
|
88 |
71 |
89 /** |
72 checkOutput("pkg/C4.html", true, |
90 * The entry point of the test. |
73 //Header does not link to the page itself. |
91 * @param args the array of command line arguments. |
74 "Class C4<E extends C4<E>></h2>", |
92 */ |
75 //Signature does not link to the page itself. |
93 public static void main(String[] args) { |
76 "public abstract class <span class=\"typeNameLabel\">C4<E extends C4<E>></span>" |
94 TestHref tester = new TestHref(); |
77 ); |
95 tester.run(ARGS, TEST, NEGATED_TEST); |
78 |
96 tester.printSummary(); |
79 checkOutput(Output.WARNING, false, |
|
80 "<a> tag is malformed"); |
97 } |
81 } |
98 } |
82 } |