test/langtools/jdk/javadoc/doclet/testLinkOption/TestLinkOption.java
author jjg
Fri, 18 Jan 2019 11:26:30 -0800
changeset 53391 a99bd2570660
parent 53097 2e82ca64b25d
child 53558 fc5a68ff2c0b
permissions -rw-r--r--
8217034: JavadocTester should check for missing files by default Reviewed-by: hannesw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
53391
a99bd2570660 8217034: JavadocTester should check for missing files by default
jjg
parents: 53097
diff changeset
     2
 * Copyright (c) 2002, 2019, 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: 2216
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2216
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
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 49139
diff changeset
    26
 * @bug 4720957 5020118 8026567 8038976 8184969 8164407 8182765 8205593
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary Test to make sure that -link and -linkoffline link to
23974
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
    28
 * right files, and URLs with and without trailing slash are accepted.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 * @author jamieh
53097
2e82ca64b25d 8215516: Move JavadocTester to a named package
jjg
parents: 51861
diff changeset
    30
 * @library ../../lib
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    31
 * @modules jdk.javadoc/jdk.javadoc.internal.tool
53097
2e82ca64b25d 8215516: Move JavadocTester to a named package
jjg
parents: 51861
diff changeset
    32
 * @build javadoc.tester.*
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * @run main TestLinkOption
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
23974
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
    36
import java.io.File;
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
    37
53097
2e82ca64b25d 8215516: Move JavadocTester to a named package
jjg
parents: 51861
diff changeset
    38
import javadoc.tester.JavadocTester;
2e82ca64b25d 8215516: Move JavadocTester to a named package
jjg
parents: 51861
diff changeset
    39
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
public class TestLinkOption extends JavadocTester {
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    41
    /**
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    42
     * The entry point of the test.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    43
     * @param args the array of command line arguments.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    44
     */
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    45
    public static void main(String... args) throws Exception {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    46
        TestLinkOption tester = new TestLinkOption();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    47
        tester.runTests();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    48
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    50
    // The following test runs javadoc multiple times; it is important that the
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    51
    // first one is run first, since the subsequent runs refer to the output
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    52
    // it generates. Therefore we run everything serially in a single @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    53
    // method and not in independent @Test methods.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    54
    @Test
53097
2e82ca64b25d 8215516: Move JavadocTester to a named package
jjg
parents: 51861
diff changeset
    55
    public void test() {
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    56
        String mylib = "mylib";
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    57
        String[] javacArgs = {
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    58
            "-d", mylib, testSrc + "/extra/StringBuilder.java"
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    59
        };
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    60
        com.sun.tools.javac.Main.compile(javacArgs);
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    61
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    62
        // Generate the documentation using -linkoffline and a URL as the first parameter.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    63
        String out1 = "out1";
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    64
        String url = "http://acme.com/jdk/";
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    65
        javadoc("-d", out1,
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 49139
diff changeset
    66
                "-source", "8",
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    67
                "-classpath", mylib,
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    68
                "-sourcepath", testSrc,
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    69
                "-linkoffline", url, testSrc + "/jdk",
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    70
                "-package",
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
    71
                "pkg", "mylib.lang");
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
    72
        checkExit(Exit.ERROR);
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
    73
        checkOutput(Output.OUT, true,
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
    74
                "tag not supported in the generated HTML version: tt");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    76
        checkOutput("pkg/C.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    77
                "<a href=\"" + url + "java/lang/String.html?is-external=true\" "
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
    78
                + "title=\"class or interface in java.lang\" class=\"externalLink\"><code>Link to String Class</code></a>",
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    79
                //Make sure the parameters are indented properly when the -link option is used.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    80
                "(int&nbsp;p1,\n"
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    81
                + "      int&nbsp;p2,\n"
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    82
                + "      int&nbsp;p3)",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    83
                "(int&nbsp;p1,\n"
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    84
                + "      int&nbsp;p2,\n"
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
    85
                + "      <a href=\"" + url + "java/lang/Object.html?is-external=true\" title=\"class or interface in java.lang\" class=\"externalLink\">"
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    86
                + "Object</a>&nbsp;p3)");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    87
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    88
        checkOutput("pkg/B.html", true,
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    89
                "<div class=\"block\">A method with html tag the method "
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
    90
                + "<a href=\"" + url + "java/lang/ClassLoader.html?is-external=true#getSystemClassLoader()\""
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
    91
                + " title=\"class or interface in java.lang\" class=\"externalLink\"><code><tt>getSystemClassLoader()</tt>"
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    92
                + "</code></a> as the parent class loader.</div>",
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    93
                "<div class=\"block\">is equivalent to invoking <code>"
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
    94
                + "<a href=\"#createTempFile(java.lang.String,java.lang.String,java.io.File)\">"
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    95
                + "<code>createTempFile(prefix,&nbsp;suffix,&nbsp;null)</code></a></code>.</div>",
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    96
                "<a href=\"" + url + "java/lang/String.html?is-external=true\" "
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
    97
                + "title=\"class or interface in java.lang\" class=\"externalLink\">Link-Plain to String Class</a>",
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    98
                "<code><tt>getSystemClassLoader()</tt></code>",
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
    99
                "<code>createTempFile(prefix,&nbsp;suffix,&nbsp;null)</code>",
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   100
                "<dd><a href=\"http://www.ietf.org/rfc/rfc2279.txt\"><i>RFC&nbsp;2279: UTF-8, a\n" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   101
                " transformation format of ISO 10646</i></a>, <br><a " +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   102
                "href=\"http://www.ietf.org/rfc/rfc2373.txt\"><i>RFC&nbsp;2373: IPv6 Addressing\n" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   103
                " Architecture</i></a>, <br><a href=\"http://www.ietf.org/rfc/rfc2396.txt\">" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   104
                "<i>RFC&nbsp;2396: Uniform\n" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   105
                " Resource Identifiers (URI): Generic Syntax</i></a>, " +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   106
                "<br><a href=\"http://www.ietf.org/rfc/rfc2732.txt\"><i>RFC&nbsp;2732: Format for\n" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   107
                " Literal IPv6 Addresses in URLs</i></a>, <br><a href=\"URISyntaxException.html\">" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   108
                "URISyntaxException</a></dd>\n" +
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   109
                "</dl>");
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   110
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   111
        checkOutput("mylib/lang/StringBuilderChild.html", true,
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   112
                "<pre>public abstract class <span class=\"typeNameLabel\">StringBuilderChild</span>\n"
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   113
                + "extends <a href=\"" + url + "java/lang/Object.html?is-external=true\" "
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
   114
                + "title=\"class or interface in java.lang\" class=\"externalLink\">Object</a></pre>"
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   115
        );
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   117
        String out1_html4 = "out1-html4";
53391
a99bd2570660 8217034: JavadocTester should check for missing files by default
jjg
parents: 53097
diff changeset
   118
        setAutomaticCheckLinks(false); // The example code has toy/bad links
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   119
        javadoc("-d", out1_html4,
51861
f7d40158eb2f 8205593: Javadoc -link makes broken links if module name matches package name
pmuthuswamy
parents: 49139
diff changeset
   120
                "-source", "8",
49139
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   121
                "-html4",
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   122
                "-classpath", mylib,
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   123
                "-sourcepath", testSrc,
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   124
                "-linkoffline", url, testSrc + "/jdk",
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   125
                "-package",
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   126
                "pkg", "mylib.lang");
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   127
        checkExit(Exit.OK);
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   128
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   129
        checkOutput("pkg/B.html", true,
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   130
                "<div class=\"block\">A method with html tag the method "
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   131
                + "<a href=\"" + url + "java/lang/ClassLoader.html?is-external=true#getSystemClassLoader--\""
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   132
                + " title=\"class or interface in java.lang\" class=\"externalLink\"><code><tt>getSystemClassLoader()</tt>"
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   133
                + "</code></a> as the parent class loader.</div>",
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   134
                "<div class=\"block\">is equivalent to invoking <code>"
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   135
                + "<a href=\"#createTempFile-java.lang.String-java.lang.String-java.io.File-\">"
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   136
                + "<code>createTempFile(prefix,&nbsp;suffix,&nbsp;null)</code></a></code>.</div>");
771616d26ca1 8182765: HTML5 must be the default javadoc codegen mode in the near future
bpatel
parents: 48654
diff changeset
   137
53391
a99bd2570660 8217034: JavadocTester should check for missing files by default
jjg
parents: 53097
diff changeset
   138
        setAutomaticCheckLinks(true); // re-enable checks
a99bd2570660 8217034: JavadocTester should check for missing files by default
jjg
parents: 53097
diff changeset
   139
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   140
        // Generate the documentation using -linkoffline and a relative path as the first parameter.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   141
        // We will try linking to the docs generated in test 1 with a relative path.
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   142
        String out2 = "out2";
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   143
        javadoc("-d", out2,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   144
                "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   145
                "-linkoffline", "../" + out1, out1,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   146
                "-package",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   147
                "pkg2");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   148
        checkExit(Exit.OK);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   149
        checkOutput("pkg2/C2.html", true,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   150
            "This is a link to <a href=\"../../" + out1 + "/pkg/C.html?is-external=true\" " +
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
   151
            "title=\"class or interface in pkg\" class=\"externalLink\"><code>Class C</code></a>."
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   152
        );
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   154
        String out3 = "out3";
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   155
        javadoc(createArguments(out3, out1, true));  // with trailing slash
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   156
        checkExit(Exit.OK);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   158
        String out4 = "out4";
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   159
        javadoc(createArguments(out4, out1, false)); // without trailing slash
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   160
        checkExit(Exit.OK);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   161
        // Note: the following test is very weak, and will fail if ever the text
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   162
        // of the message is changed. We should have a separate test to verify
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   163
        // this is the text that is given when there is a problem with a URL
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 30730
diff changeset
   164
        checkOutput(Output.OUT, false,
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   165
                "warning - Error fetching URL");
46079
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   166
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   167
        // check multiple link options
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   168
        javadoc("-d", "out5",
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   169
                "-sourcepath", testSrc,
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   170
                "-link", "../" + "out1",
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   171
                "-link", "../" + "out2",
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   172
                "pkg3");
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   173
        checkExit(Exit.OK);
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   174
        checkOutput("pkg3/A.html", true,
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   175
                "<pre>public class <span class=\"typeNameLabel\">A</span>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   176
                + "extends java.lang.Object</pre>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   177
                + "<div class=\"block\">Test links.\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   178
                + " <br>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   179
                + " <a href=\"../../out2/pkg2/C2.html?is-external=true\" "
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
   180
                + "title=\"class or interface in pkg2\" class=\"externalLink\"><code>link to pkg2.C2</code></a>\n"
46079
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   181
                + " <br>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   182
                + " <a href=\"../../out1/mylib/lang/StringBuilderChild.html?is-external=true\" "
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
   183
                + "title=\"class or interface in mylib.lang\" class=\"externalLink\">"
46079
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   184
                + "<code>link to mylib.lang.StringBuilderChild</code></a>.</div>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   185
        );
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   186
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   187
        // check multiple linkoffline options
53391
a99bd2570660 8217034: JavadocTester should check for missing files by default
jjg
parents: 53097
diff changeset
   188
        setAutomaticCheckLinks(false); // The example code has toy/bad links
46079
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   189
        javadoc("-d", "out6",
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   190
                "-sourcepath", testSrc,
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   191
                "-linkoffline", "../copy/out1", "out1",
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   192
                "-linkoffline", "../copy/out2", "out2",
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   193
                "pkg3");
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   194
        checkExit(Exit.OK);
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   195
        checkOutput("pkg3/A.html", true,
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   196
                "<pre>public class <span class=\"typeNameLabel\">A</span>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   197
                        + "extends java.lang.Object</pre>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   198
                        + "<div class=\"block\">Test links.\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   199
                        + " <br>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   200
                        + " <a href=\"../../copy/out2/pkg2/C2.html?is-external=true\" "
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
   201
                        + "title=\"class or interface in pkg2\" class=\"externalLink\"><code>link to pkg2.C2</code></a>\n"
46079
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   202
                        + " <br>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   203
                        + " <a href=\"../../copy/out1/mylib/lang/StringBuilderChild.html?is-external=true\" "
48295
c79d31ba84b9 8164407: Add module support for -link and -linkoffline javadoc option
bpatel
parents: 47216
diff changeset
   204
                        + "title=\"class or interface in mylib.lang\" class=\"externalLink\">"
46079
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   205
                        + "<code>link to mylib.lang.StringBuilderChild</code></a>.</div>\n"
059faa5e1267 8184969: Cannot specify multiple -link to jdk9 javadoc
ksrini
parents: 36526
diff changeset
   206
        );
53391
a99bd2570660 8217034: JavadocTester should check for missing files by default
jjg
parents: 53097
diff changeset
   207
a99bd2570660 8217034: JavadocTester should check for missing files by default
jjg
parents: 53097
diff changeset
   208
        setAutomaticCheckLinks(true); // re-enable checks
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   209
    }
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   210
23974
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   211
    /*
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   212
     * Create the documentation using the -link option, vary the behavior with
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   213
     * both trailing and no trailing slash. We are only interested in ensuring
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   214
     * that the command executes with no errors or related warnings.
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   215
     */
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   216
    static String[] createArguments(String outDir, String packageDir, boolean withTrailingSlash) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   217
        String packagePath = new File(packageDir).getAbsolutePath();
23974
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   218
        if (withTrailingSlash) {
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   219
            // add the trailing slash, if it is not present!
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   220
            if (!packagePath.endsWith(FS)) {
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   221
                packagePath = packagePath + FS;
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   222
            }
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   223
        } else {
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   224
            // remove the trailing slash, if it is present!
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   225
            if (packagePath.endsWith(FS)) {
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   226
                packagePath = packagePath.substring(0, packagePath.length() - 1);
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   227
            }
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   228
        }
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   229
        String args[] = {
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   230
            "-d", outDir,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   231
            "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   232
            "-link", "file:///" + packagePath,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   233
            "-package",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
   234
            "pkg2"
23974
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   235
        };
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   236
        System.out.println("packagePath: " + packagePath);
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   237
        return args;
d53628eda3d1 8038976: javadoc requires a trailing / for links where java 7's javadoc didn't
ksrini
parents: 23971
diff changeset
   238
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
}