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

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

mercurial