TestGeneratedBy.java revision 3233:b5d08bc0d224
1/* 2 * Copyright (c) 2012, 2015, 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 */ 23 24/* 25 * @test 26 * @bug 8000418 8024288 27 * @summary Verify that files use a common Generated By string 28 * @library ../lib 29 * @modules jdk.javadoc 30 * @build JavadocTester 31 * @run main TestGeneratedBy 32 */ 33 34public class TestGeneratedBy extends JavadocTester { 35 36 public static void main(String... args) throws Exception { 37 TestGeneratedBy tester = new TestGeneratedBy(); 38 tester.runTests(); 39 } 40 41 @Test 42 void testTimestamp() { 43 javadoc("-d", "out-timestamp", 44 "-sourcepath", testSrc, 45 "pkg"); 46 checkExit(Exit.OK); 47 48 checkTimestamps(true); 49 } 50 51 @Test 52 void testNoTimestamp() { 53 javadoc("-d", "out-notimestamp", 54 "-notimestamp", 55 "-sourcepath", testSrc, 56 "pkg"); 57 checkExit(Exit.OK); 58 59 checkTimestamps(false); 60 } 61 62 void checkTimestamps(boolean timestamp) { 63 checkTimestamps(timestamp, 64 "pkg/MyClass.html", 65 "pkg/package-summary.html", 66 "pkg/package-frame.html", 67 "pkg/package-tree.html", 68 "allclasses-noframe.html", 69 "constant-values.html", 70 "allclasses-frame.html", 71 "overview-tree.html", 72 "deprecated-list.html", 73 "serialized-form.html", 74 "help-doc.html", 75 "index-all.html", 76 "index.html"); 77 78 } 79 80 void checkTimestamps(boolean timestamp, String... files) { 81 String version = System.getProperty("java.version"); 82 String genBy = "Generated by javadoc"; 83 if (timestamp) genBy += " (" + version + ") on "; 84 85 for (String file: files) { 86 // genBy is the current standard "Generated by" text 87 checkOutput(file, true, genBy); 88 89 // These are older versions of the "Generated by" text 90 checkOutput(file, false, 91 (timestamp 92 ? "Generated by javadoc (version" 93 : "Generated by javadoc ("), 94 "Generated by javadoc on"); 95 } 96 } 97} 98 99