langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java
author jjg
Wed, 16 Apr 2014 16:17:09 -0700
changeset 23971 f5ff1f5a8dee
parent 20257 9da4f6c30089
child 24065 fc4022e50129
permissions -rw-r--r--
8031649: Clean up javadoc tests Reviewed-by: jjg Contributed-by: neil.toda@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
     2
 * Copyright (c) 2002, 2014, 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
20257
9da4f6c30089 8016328: Regression : Javadoc i18n regression caused by fix for 8012375
bpatel
parents: 14060
diff changeset
    26
 * @bug 4496290 4985072 7006178 7068595 8016328
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
 * @summary A simple test to determine if -use works.
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
 * @author jamieh
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
 * @library ../lib/
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
 * @build JavadocTester
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
 * @build TestUseOption
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * @run main TestUseOption
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
public class TestUseOption extends JavadocTester {
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
14060
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    37
    private static final String BUG_ID = "4496290-4985072-7006178-7068595";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
    //Input for string search tests.
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
    private static final String[] TEST2 = {
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
        "Field in C1.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
        "Field in C2.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
        "Field in C4.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
        "Field in C5.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
        "Field in C6.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
        "Field in C7.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
        "Field in C8.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
        "Method in C1.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
        "Method in C2.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
        "Method in C4.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
        "Method in C5.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
        "Method in C6.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
        "Method in C7.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
        "Method in C8.",
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
8841
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    57
    private static final String[][] TEST3 = {
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
    58
        {BUG_ID + "-3/class-use/UsedInC.html", "Uses of <a href=" +
8841
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    59
                 "\"../UsedInC.html\" title=\"class in &lt;Unnamed&gt;\">" +
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    60
                 "UsedInC</a> in <a href=\"../package-summary.html\">&lt;Unnamed&gt;</a>"
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    61
        },
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
    62
        {BUG_ID + "-3/package-use.html", "<td class=\"colOne\">" +
20257
9da4f6c30089 8016328: Regression : Javadoc i18n regression caused by fix for 8012375
bpatel
parents: 14060
diff changeset
    63
                 "<a href=\"class-use/UsedInC.html#%3CUnnamed%3E\">UsedInC</a>&nbsp;</td>"
8841
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    64
        }
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    65
    };
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    66
14060
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    67
    private static final String[][] TEST4 = {
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
    68
        {BUG_ID + "-4/pkg2/class-use/C3.html", "<a href=" +
14060
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    69
                 "\"../../index.html?pkg2/class-use/C3.html\" target=\"_top\">" +
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    70
                 "Frames</a></li>"
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    71
        }
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    72
    };
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    73
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    private static final String[] ARGS = new String[] {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    private static final String[] ARGS2 = new String[] {
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
        "-d", BUG_ID+"-2", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    };
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
8841
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    82
    private static final String[] ARGS3 = new String[] {
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
    83
        "-d", BUG_ID + "-3", "-sourcepath", SRC_DIR, "-use", SRC_DIR +
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
    84
        "/C.java", SRC_DIR + "/UsedInC.java"
8841
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    85
    };
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
    86
14060
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    87
    private static final String[] ARGS4 = new String[] {
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    88
        "-d", BUG_ID + "-4", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    89
    };
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
    90
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * The entry point of the test.
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * @param args the array of command line arguments.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
    public static void main(String[] args) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        String[][] tests = new String[11][2];
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
        //Eight tests for class use.
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
        for (int i = 0; i < 8; i++) {
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
    99
            tests[i][0] = BUG_ID + "/pkg1/class-use/C1.html";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
            tests[i][1] = "Test " + (i + 1) + " passes";
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        //Three more tests for package use.
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        for (int i = 8, j = 1; i < tests.length; i++, j++) {
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
   104
            tests[i][0] = BUG_ID + "/pkg1/package-use.html";
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            tests[i][1] = "Test " + j + " passes";
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        TestUseOption tester = new TestUseOption();
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        run(tester, ARGS, tests, NO_TEST);
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        tester.printSummary();
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        run(tester, ARGS2, NO_TEST, NO_TEST);
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
   111
        String usePageContents = tester.readFileToString(BUG_ID +
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 20257
diff changeset
   112
            "-2/pkg1/class-use/UsedClass.html");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        int prevIndex = -1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        int currentIndex = -1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        for (int i = 0; i < TEST2.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
            currentIndex = usePageContents.indexOf(TEST2[i]);
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
            System.err.println(TEST2[i] + " at index " + currentIndex);
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
            if (currentIndex < prevIndex)
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
                throw new Exception(TEST2[i] + " is in the wrong order.");
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
            prevIndex = currentIndex;
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        tester.printSummary();
8841
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
   123
        run(tester, ARGS3, TEST3, NO_TEST);
14060
ae69cea86e83 7068595: html files in class-use dir do not get loaded correctly when Frames link is clicked
bpatel
parents: 8841
diff changeset
   124
        run(tester, ARGS4, TEST4, NO_TEST);
8841
b4422fa4f2e6 7006178: findbugs high priority issues in new javadoc
bpatel
parents: 5520
diff changeset
   125
        tester.printSummary();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    public String getBugId() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        return BUG_ID;
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    public String getBugName() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        return getClass().getName();
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
}