test/com/sun/javadoc/testGeneratedBy/TestGeneratedBy.java

Mon, 23 Jan 2017 17:03:12 -0800

author
asaha
date
Mon, 23 Jan 2017 17:03:12 -0800
changeset 3376
26c9abc6c440
parent 2006
044721d4d359
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 8000418 8024288
    27  * @summary Verify that files use a common Generated By string
    28  * @library ../lib/
    29  * @build JavadocTester TestGeneratedBy
    30  * @run main TestGeneratedBy
    31  */
    33 public class TestGeneratedBy extends JavadocTester {
    35     private static final String OUTPUT_DIR = "tmp";
    37     private static final String[] FILES = {
    38         "pkg/MyClass.html",
    39         "pkg/package-summary.html",
    40         "pkg/package-frame.html",
    41         "pkg/package-tree.html",
    42         "allclasses-noframe.html",
    43         "constant-values.html",
    44         "allclasses-frame.html",
    45         "overview-tree.html",
    46         "deprecated-list.html",
    47         "serialized-form.html",
    48         "help-doc.html",
    49         "index-all.html",
    50         "index.html"
    51     };
    53     private static final String[] STD_ARGS =
    54         new String[] {
    55             "-d", OUTPUT_DIR,
    56             "-sourcepath", SRC_DIR,
    57             "pkg"
    58         };
    60     private static final String[] NO_TIMESTAMP_ARGS =
    61         new String[] {
    62             "-notimestamp",
    63             "-d", OUTPUT_DIR,
    64             "-sourcepath", SRC_DIR,
    65             "pkg"
    66         };
    68     private static final String BUG_ID = "8000418-8024288";
    70     private static String[][] getTests(boolean timestamp) {
    71         String version = System.getProperty("java.version");
    72         String[][] tests = new String[FILES.length][];
    73         for (int i = 0; i < FILES.length; i++) {
    74             String genBy = "Generated by javadoc";
    75             if (timestamp) genBy += " (" + version + ") on ";
    76             tests[i] = new String[] {
    77                 OUTPUT_DIR + FS + FILES[i], genBy
    78             };
    79         }
    80         return tests;
    81     }
    83     private static String[][] getNegatedTests(boolean timestamp) {
    84         String[][] tests = new String[FILES.length][];
    85         for (int i = 0; i < FILES.length; i++) {
    86             tests[i] = new String[] {
    87                 OUTPUT_DIR + FS + FILES[i],
    88                 (timestamp
    89                     ? "Generated by javadoc (version"
    90                     : "Generated by javadoc ("),
    91                 "Generated by javadoc on"
    92             };
    93         }
    94         return tests;
    95     }
    97     /**
    98      * The entry point of the test.
    99      * @param args the array of command line arguments.
   100      */
   101     public static void main(String[] args) {
   102         TestGeneratedBy tester = new TestGeneratedBy();
   103         int ec1 = run(tester, STD_ARGS, getTests(true), getNegatedTests(true));
   104         int ec2 = run(tester, NO_TIMESTAMP_ARGS, getTests(false), getNegatedTests(false));
   105         tester.printSummary();
   106         if (ec1 != 0 || ec2 != 0) {
   107             throw new Error("Error found while executing Javadoc");
   108         }
   109     }
   111     /**
   112      * {@inheritDoc}
   113      */
   114     public String getBugId() {
   115         return BUG_ID;
   116     }
   118     /**
   119      * {@inheritDoc}
   120      */
   121     public String getBugName() {
   122         return getClass().getName();
   123     }
   124 }

mercurial