test/langtools/jdk/javadoc/doclet/testRelativeLinks/TestRelativeLinks.java
author bpatel
Tue, 06 Mar 2018 10:45:47 -0800
changeset 49139 771616d26ca1
parent 48655 e1876e6b57b6
child 50293 edfb87b2520e
permissions -rw-r--r--
8182765: HTML5 must be the default javadoc codegen mode in the near future Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
48655
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 47216
diff changeset
     2
 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
 * @test
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
    26
 * @bug      4460354 8014636 8043186 8195805 8182765
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary  Test to make sure that relative paths are redirected in the
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 *           output so that they are not broken.
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 * @author   jamieh
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    30
 * @library  ../lib
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    31
 * @modules jdk.javadoc/jdk.javadoc.internal.tool
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * @build    JavadocTester
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * @run main TestRelativeLinks
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
public class TestRelativeLinks extends JavadocTester {
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    38
    public static void main(String... args) throws Exception {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    39
        TestRelativeLinks tester = new TestRelativeLinks();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    40
        tester.runTests();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    41
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    43
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    44
    void test() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    45
        javadoc("-d", "out",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    46
                "-use",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    47
                "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    48
                "pkg", "pkg2");
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
    49
        checkExit(Exit.ERROR);
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
    50
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
    51
        checkOutput(Output.OUT, true,
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
    52
                "attribute not supported in HTML5: name");
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    53
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    54
        // These relative paths should stay relative because they appear
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    55
        // in the right places.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    56
        checkOutput("pkg/C.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    57
            "<a href=\"relative-class-link.html\">relative class link</a>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    58
            "<a href=\"relative-field-link.html\">relative field link</a>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    59
            "<a href=\"relative-method-link.html\">relative method link</a>",
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    60
            " <a href=\"relative-multi-line-link.html\">relative-multi-line-link</a>.");
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    61
        checkOutput("pkg/package-summary.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    62
            "<a href=\"relative-package-link.html\">relative package link</a>");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    64
        // These relative paths should be redirected because they are in different
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    65
        // places.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    66
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    67
        // INDEX PAGE
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    68
        checkOutput("index-all.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    69
            "<a href=\"./pkg/relative-class-link.html\">relative class link</a>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    70
            "<a href=\"./pkg/relative-field-link.html\">relative field link</a>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    71
            "<a href=\"./pkg/relative-method-link.html\">relative method link</a>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    72
            "<a href=\"./pkg/relative-package-link.html\">relative package link</a>",
48655
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 47216
diff changeset
    73
            " <a href=\"./pkg/relative-multi-line-link.html\">relative-multi-line-link</a>.");
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 47216
diff changeset
    74
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 47216
diff changeset
    75
        // This is not a relative path and should not be redirected.
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 47216
diff changeset
    76
        checkOutput("index-all.html", true,
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 47216
diff changeset
    77
            "<div class=\"block\"><a name=\"masters\"></a>");
e1876e6b57b6 8195805: Doclet incorrectly updates all attributes in <a> tags when relocating links
jjg
parents: 47216
diff changeset
    78
        checkOutput("index-all.html", false,
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    79
            "<div class=\"block\"><a name=\"./pkg/masters\"></a>");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    81
        // PACKAGE USE
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    82
        checkOutput("pkg/package-use.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    83
            "<a href=\"../pkg/relative-package-link.html\">relative package link</a>.",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    84
            "<a href=\"../pkg/relative-class-link.html\">relative class link</a>");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    86
        // CLASS_USE
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    87
        checkOutput("pkg/class-use/C.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    88
            "<a href=\"../../pkg/relative-field-link.html\">relative field link</a>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    89
            "<a href=\"../../pkg/relative-method-link.html\">relative method link</a>",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    90
            "<a href=\"../../pkg/relative-package-link.html\">relative package link</a>",
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    91
            " <a href=\"../../pkg/relative-multi-line-link.html\">relative-multi-line-link</a>.");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    93
        // PACKAGE OVERVIEW
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    94
        checkOutput("overview-summary.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24072
diff changeset
    95
            "<a href=\"./pkg/relative-package-link.html\">relative package link</a>");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
    }
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
    97
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
    98
    @Test
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
    99
    void test_html4() {
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
   100
        javadoc("-d", "out-html4",
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
   101
                "-html4",
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
   102
                "-use",
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
   103
                "-sourcepath", testSrc,
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
   104
                "pkg", "pkg2");
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
   105
        checkExit(Exit.OK);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
}
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48655
diff changeset
   107
}