langtools/test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java
author pgovereau
Tue, 27 May 2014 22:26:53 +0100
changeset 24610 8b3b718970a9
parent 24399 af1a0220d0fa
child 30730 d3ce7619db2c
permissions -rw-r--r--
8042741: Java 8 compiler throws NullPointerException depending location in source file Reviewed-by: vromero, jlahoda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
     1
/*
23971
f5ff1f5a8dee 8031649: Clean up javadoc tests
jjg
parents: 19920
diff changeset
     2
 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
     4
 *
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
     8
 *
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    13
 * accompanied this code).
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    14
 *
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    18
 *
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    21
 * questions.
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    22
 */
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    23
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    24
/*
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    25
 * @test
19920
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 14262
diff changeset
    26
 * @bug 8000418 8024288
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    27
 * @summary Verify that files use a common Generated By string
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    28
 * @library ../lib
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    29
 * @build JavadocTester
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    30
 * @run main TestGeneratedBy
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    31
 */
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    32
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    33
public class TestGeneratedBy extends JavadocTester {
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    34
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    35
    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
    36
        TestGeneratedBy tester = new TestGeneratedBy();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    37
        tester.runTests();
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    38
    }
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    39
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    40
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    41
    void testTimestamp() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    42
        javadoc("-d", "out-timestamp",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    43
            "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    44
            "pkg");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    45
        checkExit(Exit.OK);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    46
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    47
        checkTimestamps(true);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    48
    }
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    49
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    50
    @Test
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    51
    void testNoTimestamp() {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    52
        javadoc("-d", "out-notimestamp",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    53
            "-notimestamp",
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    54
            "-sourcepath", testSrc,
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    55
            "pkg");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    56
        checkExit(Exit.OK);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    57
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    58
        checkTimestamps(false);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    59
    }
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    60
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    61
    void checkTimestamps(boolean timestamp) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    62
        checkTimestamps(timestamp,
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    63
        "pkg/MyClass.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    64
        "pkg/package-summary.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    65
        "pkg/package-frame.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    66
        "pkg/package-tree.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    67
        "allclasses-noframe.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    68
        "constant-values.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    69
        "allclasses-frame.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    70
        "overview-tree.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    71
        "deprecated-list.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    72
        "serialized-form.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    73
        "help-doc.html",
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    74
        "index-all.html",
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    75
        "index.html");
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    76
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    77
    }
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    78
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    79
    void checkTimestamps(boolean timestamp, String... files) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    80
        String version = System.getProperty("java.version");
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    81
        String genBy = "Generated by javadoc";
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    82
        if (timestamp) genBy += " (" + version + ") on ";
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    83
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    84
        for (String file: files) {
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    85
            // genBy is the current standard "Generated by" text
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    86
            checkOutput(file, true, genBy);
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    87
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    88
            // These are older versions of the "Generated by" text
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    89
            checkOutput(file, false,
19920
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 14262
diff changeset
    90
                (timestamp
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 14262
diff changeset
    91
                    ? "Generated by javadoc (version"
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 14262
diff changeset
    92
                    : "Generated by javadoc ("),
24399
af1a0220d0fa 8038730: Clean up the way JavadocTester is invoked, and checks for errors.
jjg
parents: 24217
diff changeset
    93
                "Generated by javadoc on");
14262
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    94
        }
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    95
    }
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    96
}
058238ba531e 8000418: javadoc should used a standard "generated by javadoc" string
jjg
parents:
diff changeset
    97